|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] translate function
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








