Changing text "in place"

Subject: Changing text "in place"
From: Michel Goossens <Michel.Goossens@xxxxxxx>
Date: Sat, 1 May 1999 19:21:23 +0200 (METDST)
I am presently working on writing an XSL stylesheet translating an XML
document (the XML spec, in fact) into LaTeX. However, I have a problem
to get some characters that are "special" for LaTeX into a form that is
acceptable (e.g., $, %, #, &, etc. have a special meaning). So the easiest
would be to escape such characters when they get transferred to the result
tree, _if necessary_. The latter is important, since inside verbatim-like
environments the characters can be used as-is, so I have to handle the 
text nodes depending on their parents. Before I go off and write a set
of Java routines using xt's extension mechanism, I wonder wether something 
simpler is possible. As an example, consider the following extract from
the XML spec:

<scrap>
....
<prod id="NT-PubidLiteral"><lhs>PubidLiteral</lhs>
<rhs>'"' <nt def='NT-PubidChar'>PubidChar</nt>* 
'"' 
| "'" (<nt def='NT-PubidChar'>PubidChar</nt> - "'")* "'"</rhs>
</prod>
<prod id="NT-PubidChar"><lhs>PubidChar</lhs>
<rhs>#x20 | #xD | #xA 
|&nbsp;[a-zA-Z0-9]
|&nbsp;[-'()+,./:=?;!*#@$_%]</rhs>
</prod>
</scrap>

Inside a scrap element (but not inside, for instance, an eg element)
I would like to escape #, $, %, _, amongst others, by preceding them
with a \ escape character. I have tried to see how to use the translate
function on a text node, but that maps only characters one-to-one. 
Also, I have not found how to stream the content of the input (source)
tree text note through a "filter" to the output (result) tree text node.
Any help would be appreciated. m

----------------------------------------------------
Dr. Michel Goossens         Phone: (+41 22) 767-5028
IT Division                 Fax:   (+41 22) 767-8630
CERN                        Email:  goossens@xxxxxxx
CH-1211 Geneva 23    F-01631 CERN Cedex
Switzerland          France




 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread