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

Re: Apostrophe escaping in contains().

Subject: Re: Apostrophe escaping in contains().
From: David Carlisle <davidc@xxxxxxxxx>
Date: Tue, 2 Dec 2003 17:30:08 GMT
xpath apostrophe
>	I've searched the FAQs, and they report that I'm escaping the apostrophe 
> correctly.

No they don't: Your snippet is not well formed XML, so it will not have
got as far as the XSLT engine:

<xsl:when test="contains($text, '"&apos;"')> some stuff </xsl:when>
               ^                 ^

You can not have an " in an XML attribute that is delimuted by ", you
have to quote the " Although actually your attribute isn't delimited at
all it has a " at the start and nothing at the end

so to make that well formed XML you'd have to have
<xsl:when test="contains($text, '&quot;&apos;&quot;')"> some stuff </xsl:when>
   
But that means the XML parser would pass on the attribute value

contains($text, '"'"')

which is an Xpath error as you can't have a ' in a '-delimted XPath
string.

So working backwards, you want the Xpath



contains($text, "'")

which you then need to put into an XML attribute, either like this
test="contains($text, &quot;'&quot;)"
or like this
test='contains($text, "&apos;")'
remember that as far as the XML parser is concerned, Xpath syntax is
nothing, you just follow the XML rules: either wrap it in " and quote
any contained ", or wrap it in ' and quote any contained '.

David


-- 
http://www.dcarlisle.demon.co.uk/matthew

________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

 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.