|
Subject: RE: [xsl] replace multiple distinct strings From: Jarno.Elovirta@xxxxxxxxx Date: Tue, 30 Sep 2003 08:19:01 +0300 |
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
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| [xsl] replace multiple distinct str, Derrick Koes | Thread | [xsl] How should I structure a huge, Anthony Zawacki |
| Re: [xsl] how to match node set wit, G. Ken Holman | Date | Re: [xsl] Multiple input files, S Woodside |
| Month |