[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

translate function

Subject: translate function
From: Steve Fitzpatrick <SFitzpatrick@xxxxxxx>
Date: Tue, 15 May 2001 22:37:47 -0700
javascript 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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.