RE: [xsl] Re: Escaping quotes in XPath expressions

Subject: RE: [xsl] Re: Escaping quotes in XPath expressions
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Mon, 17 Nov 2003 13:45:12 -0000
> 
> On 15 Nov 2003 at 13:48, Michael Kay wrote:
> 
> > <xsl:variable name="quot">"</xsl:variable>
> > <xsl:variable name="apos">'</xsl:variable>
> > <xsl:value-of select="translate(., $quot, $apos)"/>
> 
> ------------------------------
> 
> First of all, many thanks to Michael and Dimitre for replying 
> to my message.
> 
> I had actually thought of using variables, but besides the 
> problem Dimitre pointed out, 
> I've read that in XSLT 1.1 the value of a variable *must* be 
> contained in a 'select' 
> attribute, or else you'll be creating a result tree fragment, 
> which in XSLT 1.1 would be 
> illegal. 

Firstly, XSLT 1.1 is dead in the water. 

Secondly, the above works fine under XSLT 2.0. It's true that you are
creating temporary trees rather than strings, but they are converted to
strings quite happily when used in a context where a string is expected.

But if you prefer, you could write:

<xsl:variable name="quot" select='"'/>
<xsl:variable name="apos" select="'"/>

Dimitre thought you were actually trying to use translate() to replace
one character by several. If that's the case, then he's right, you can't
do it.

Michael Kay


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread