Subject: Re: [xsl] Problem using translate to escape quotes From: Jeff Kenton <jkenton@xxxxxxxxxxxxx> Date: Wed, 04 Dec 2002 11:13:06 -0500 |
I have a string containing single quotes held in a variable. I want to escape each quote by inserting a backslash before it, but I can't get it to work. The translate function appears to be inserting the backslashes without the quotes.
Here's a test version of the stylesheet: -------------------------------------------- <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="html"/>
<xsl:variable name="mystr">this is Kevin's 'string'</xsl:variable>
<xsl:variable name="backSlashQuote">\'</xsl:variable> <xsl:variable name="backSlash">\</xsl:variable> <xsl:variable name="singleQuote">'</xsl:variable> <xsl:variable name="backSlashQuote2"><xsl:value-of select="concat( $backSlash, $singleQuote )"/></xsl:variable>
<xsl:variable name="mystr_escaped"> <xsl:value-of select="translate( $mystr, $singleQuote, $backSlashQuote )"/> </xsl:variable>
<xsl:template match="/"> <html> <body> <xsl:value-of select="$mystr"/> <br/> <xsl:value-of select="$mystr_escaped"/> </body> </html> </xsl:template>
</xsl:stylesheet> --------------------------------------------
-- -------------------------- Jeff Kenton DataPower Technology, Inc.
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Problem using translate to es, Kevin Collins | Thread | Re: [xsl] Problem using translate t, David Carlisle |
[xsl] a*b, sum(c*d), sorted on <sor, Dan Diebolt | Date | RE: [xsl] Element creation, Passin, Tom |
Month |