xsl-list
[Top] [All Lists]

[xsl] (Re-)Escaping entities in input text

2008-08-20 08:50:53
Hi,

I was wondering whether there is an efficient way of "reescaping" the data read 
from the input file when saving it to an xs:string...

Here's the problem: my input is an XML file which contains text nodes, which in 
turn may contain escaped entities like < (<) and such. Upon reading 
it, xsl:value-of (AFAIK) automatically converts these to the corresponding 
characters '<' etc -- this is completely transparent to the user agent, and in 
most cases this is sensible. However, in my case, I'm building a string which 
is actually XML code and whose text nodes are the nodes I've found in my input 
file. This XML string is then passed on to an external processor (Java class) 
for further processing. That means, whatever was escaped in my input file 
should still be escaped in the string, otherwise the string might not be 
well-formed, and my external processor won't be able to parse it. 

Of course, there is the possibility of replacing all 5 entities "by hand" by 
calling a transform function, however this might not be very efficient when the 
string is getting big. Is there either:
- a way of disabling entity interpretation with xsl:value-of (actually getting 
"&lt;" when it's written like this in the input file)
- a function to "reescape" a piece of text so that it's usable in an XML 
file/string? 

I know XSLT also escapes metacharacters automatically when outputting to a 
file, but since I'm only working internally with a string, this doesn't apply 
to me. "disable-output-escaping" is also not a solution, since it does pretty 
much exactly the contrary from what I'm trying to do... 

thx in advance for any help! :-)

cheers

David


      

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>