Subject: Re: [xsl] (Re-)Escaping entities in input text From: "Andrew Welch" <andrew.j.welch@xxxxxxxxx> Date: Wed, 20 Aug 2008 15:21:18 +0100 |
> 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: _never_ do that... it's the first step down the wrong road which is long and painful. > - a way of disabling entity interpretation with xsl:value-of (actually getting "<" when it's written like this in the input file) xsl:value-of simply creates text nodes in the result tree, there is no interpretation going on - that only happens during parsing/serialisation > - a function to "reescape" a piece of text so that it's usable in an XML file/string? that happens during serialisation... for example: <foo> a < b </foo> when that's parsed you will get a node "foo" with a single text node child "a < b". If you do xsl:value-of on that text node, it will add to the result tree. It's still "a < b" at this point. Then the serializer operates on the result tree which knows that "<" in a text node must be escaped, so after that step it becomes "a < b"... It sounds like you might be skipping the serialization step - perhaps you're constructing a String and just writing that to disk? eg String xml = "<foo>" + someValue = "</foo>"; ...which would give you: <foo> a < b </foo>. ...hence the question? Doing it that way is A Bad Thing - the golden rule is to always read and write XML using proper XML readers and writers. -- Andrew Welch http://andrewjwelch.com Kernow: http://kernowforsaxon.sf.net/
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] (Re-)Escaping entities in inp, David Vergnaud | Thread | Re: [xsl] (Re-)Escaping entities in, David Vergnaud |
[xsl] (Re-)Escaping entities in inp, David Vergnaud | Date | Re: [xsl] (Re-)Escaping entities in, David Vergnaud |
Month |