[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Escaping quotes in XPath expressions

Subject: Re: Escaping quotes in XPath expressions
From: yguaba@xxxxxxxxxxxx
Date: Mon, 17 Nov 2003 10:37:58 -0200
xpath escape character
On 15 Nov 2003 at 14:53, Dimitre Novatchev wrote:


> translate() can only translate a character into another character or to
> nothing. It is not possible using translate() to translate a character
> into two or more characters.
> 
> For such tasks it is convenient to use the "str-map" template from
> FXSL(...) 

------------------------------

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. In other words, if I didn't want to write obsolete code, my variable would have to 
look something like this:

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

Problem is, in the example above any single-quotes inside the double-quotes would 
also be special characters (used to enclose literals), so I'd have to find a way to escape 
that darned single-quote. Back to square one.

Is it an inescapable truth that there's no way to escape special characters within an 
Xpath string argument? Have I missed something about the creation of variables in 
XSLT 1.1? Help! :-O

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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.