xml-xalan-j-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Frank E. Weiss" <fra...@well.com>
Subject Re: Have we disobeyed a cardinal rule?
Date Mon, 07 Oct 2002 22:35:51 GMT
I don't find a problem escaping quotes in attributes. Instead I find the problem when trying
to use text from the input
document within JavaScript string literals. I checked  XPath functions, Xalan functions, and
Xalan extension functions,
but could not find a function to backslash-escape quotes. The ideal solution is to use a custom
extension function.

Here's the test case I used:

<?xml version="1.0"?>
<root>
 <name>Sandy's "Disco"</name>
</root>

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
 <xsl:output method="html" indent="yes" version="4.0" doctype-public="-//W3C//DTD HTML
4.01 Transitional//EN"
/>
 <xsl:template match="/root">
  <html>
  <head>
   <title>urlencode</title>
  </head>
  <body>
   <form name="form1">
    <table>
     <tr><td><xsl:value-of select="name"/></td></tr>
     <tr><td><input type="text" value="{name}"/></td></tr>
     <tr><td><input type="text" name="input1"/></td></tr>
    </table>
   </form>
  </body>
<!-- quotes not escaped for JavaScript -->
  <script language="JavaScript">document.form1.input1.value="<xsl:value-of select="name"/>";</script>
  </html>
 </xsl:template>
</xsl:stylesheet>


Mime
View raw message