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

RE: How to select for ' in XPATH?

Subject: RE: How to select for ' in XPATH?
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Wed, 5 Aug 2009 18:20:11 +0100
RE:  How to select for &apos; in XPATH?
I don't really know anything about the shell that you are using and any
escaping or unescaping that it is doing, so it's a bit hard to tell. The
general rule in XPath 2.0 is that if a string literal is enclosed in single
quotes, an apostrophe should be represented as a pair of adjacent
apostrophes.

Regards,

Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay 

 

> -----Original Message-----
> From: Hermann Stamm-Wilbrandt [mailto:STAMMW@xxxxxxxxxx] 
> Sent: 05 August 2009 18:04
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  How to select for &apos; in XPATH?
> 
> 
> Hello,
> 
> I tried to select for special characters with XPATH below.
> While I succeeded for some I am unable to select for the 
> &apos; character (') and got an error message.
> 
> Any hint how this can be done?
> 
> $ xmlsh
> $ cat tst.html
> <html><body>
> <p>lt and gt: &lt; &gt; </p>
> <p>apos and quot: &apos; &quot; </p>
> </body></html>
> $ tidy -q -xml tst.html;
> <html>
>   <body>
>     <p>lt and gt: &lt; &gt;</p>
>     <p>apos and quot: ' "</p>
>   </body>
> </html>
> 
> $ xpath "/*/*/*[contains(normalize-space(.),'<')]" <tst.html 
> <p>lt and gt: &lt; &gt; </p> $ xpath 
> "/*/*/*[contains(normalize-space(.),'>')]" <tst.html <p>lt 
> and gt: &lt; &gt; </p> $ xpath 
> "/*/*/*[contains(normalize-space(.),'\"')]" <tst.html <p>apos 
> and quot: ' " </p> $ xpath 
> "/*/*/*[contains(normalize-space(.),'\'')]" <tst.html 
> Exception running: xpath
> net.sf.saxon.s9api.SaxonApiException: XPath syntax error at char 34 in
> {...ontains(normalize-space(.),...}:
>     Unmatched quote in expression
> $
> 
> 
> Mit besten Gruessen / Best wishes,
> 
> Hermann Stamm-Wilbrandt
> Developer, XML Compiler
> WebSphere DataPower SOA Appliances
> ----------------------------------------------------------------------
> IBM Deutschland Research & Development GmbH Vorsitzender des 
> Aufsichtsrats: Martin Jetter
> Geschaeftsfuehrung: Erich Baier
> Sitz der Gesellschaft: Boeblingen
> Registergericht: Amtsgericht Stuttgart, HRB 243294

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.