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

Re: quoting of special characters within XPath string

Subject: Re: quoting of special characters within XPath string
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 5 Apr 2000 17:48:15 +0100 (BST)
xpath string quote
> I can not guarantee that variableString does not contain single or double
> quotes. It might even contain both kinds of quotes. How do I have to escape
> (?) those quotes to get a well-formed XPath string?

there are some examples of this in the archive, but...

First just consider the xpath syntax.

You can use " or ' to delimit a string literal, so if you only want one
then you can delimit with the other.
  "'"  or '"'
if you want both then you can not do it directly in a string literal but
you can construct the string '" using
translate('a"','a',"'")
or
concat("'",'"')
or if you drop out of xpath, to xslt
<xsl:variable name="x">'"</xsl:variable>
then use $x as this result tree fragment will coerce to a string.

Then you need to get one of those expressions into an XML attribute
If you use " to delimit the attribute value then you need to quote "
so you end up with

select="translate('a&quot;','a',&quot;'&quot;)"

which looks a bit odd but the XML parser eats that and gives the xpath
system translate('a"','a',"'") which takes the string a" and replaces
the a by '.

   I was thinkin about something like

	selectNodesParametrized (node, "/element[@attr ='$$']", variableString);

isn't that just

select="/element[@attr = $variableString]" ?

or perhaps I didn't understand the question.

David


 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.