Subject: [xsl] translate function From: Steve Fitzpatrick <SFitzpatrick@xxxxxxx> Date: Tue, 15 May 2001 22:37:47 -0700 |
Hi, I'm using XSLT to tranform XML into HTML/JavaScript (using Xalan/Xerxes). I am running into problems with quotes/apostrophes when I use XSL in combination with JavaScript. If there is a quote or an apostrophe in the XML that I am taking the value-of, it causes problems with the quotes I am using to declare a string in JavaScript. I have been unable to use the translate() function to solve this problem. Does anyone have any suggestions? See the simplified example below: XML: <?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet type="text/xsl" href="stylesheet.xsl"?> <root> <myNode><![CDATA[It's me]]></myNode> </root> XSL: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:template match="/"> <html> <head><title>Example</title></head> <body> <script language="JavaScript" type="text/javascript"> var myNode = '<xsl:value-of select="root/myNode"/>'; alert(myNode); </script> </body> </html> </xsl:template> </xsl:stylesheet> The resultant HTML page has a javascript error on it because of the apostrophe in <myNode>. Thanks for the help, Steve Fitzpatrick XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Testing type of a param, Michael Kay | Thread | Re: [xsl] translate function, Mike Brown |
Re: [xsl] XPath for number of prece, Michael Strasser | Date | [no subject], Zafer BAYRAKTAR |
Month |