View Full Version : can XSL escape?

02-02-2003, 03:48 PM
I'm making this up, but what I want amounts to:

<xsl:escape-output><xsl:value-of select="node_data"/></xsl:escape-output>

Or maybe there's an XPath way. Any ideas?

Alex Vincent
02-04-2003, 03:08 PM
I'm not sure I follow. Isn't that what CDATA sections are for?

02-04-2003, 03:19 PM
Well I'm generating js variables. eg:



var greeting = "hello";

But if the XML has

<greeting>"Hello", he said, "it's nice to see you"</greeting>

How do I turn that into JS without getting errors?

Alex Vincent
02-05-2003, 01:57 AM
Hm. Maybe by using &amp;quot; or &amp;apos; . I think these are valid in XML.

02-05-2003, 02:58 AM
Originally posted by Alex Vincent
Hm. Maybe by using &amp;quot; or &amp;apos; . I think these are valid in XML.


02-05-2003, 04:41 AM
You could also the \x escape sequence with hex codes. This is valid in JS:

var greeting = "\x22Hello\x22, he said, \x22it\x27s nice to see you\x22";

02-05-2003, 09:52 AM
I tried those entitites - but they get parsed back into " and ' in the transformation ... end result is the same.

But hex codes I haven't tried. Thanks - I'll try that now :thumbsup: