|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: replace multiple distinct strings
Hi,
> I'm attempting to write a javascript escape function like
> template in xsl.
> I wish to escape text to it's URL escaped form (i.e. %xx
> where x is a hex
> digit).
>
> I've tried two different style sheets that I think should
> accomplish the
> same thing. However, I end up with the following error:
> javax.xml.transform.TransformerException: java.lang.RuntimeException:
> Invalid conversion from 'reference' to 'java.lang.String'.
Probably a Xalan bug. Try out something in the lines of
<xsl:key name="hex" match="replace" use="from"/>
<xsl:template name="js:escape">
<xsl:param name="text"/>
<xsl:for-each select="document('replace.xml')">
<xsl:call-template name="js:escape.recursion">
<xsl:with-param name="text" select="$text"/>
</xsl:call-template>
</xsl:for-each>
</xsl:template>
<xsl:template name="js:escape.recursion">
<xsl:param name="text"/>
<xsl:choose>
<xsl:when test="not($text)"/>
<xsl:when test="key('hex', substring($text, 1, 1))">
<xsl:value-of select="key('hex', substring($text, 1, 1))/to"/>
<xsl:call-template name="js:escape.recursion">
<xsl:with-param name="text" select="substring($text, 2)"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="substring($text, 1, 1)"/>
<xsl:call-template name="js:escape.recursion">
<xsl:with-param name="text" select="substring($text, 2)"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
Cheers,
Jarno - Nick Sentience: March 2003 Mix
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








