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"?>
 <name>Sandy's "Disco"</name>

<?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">
   <form name="form1">
     <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>
<!-- quotes not escaped for JavaScript -->
  <script language="JavaScript">document.form1.input1.value="<xsl:value-of select="name"/>";</script>

View raw message