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

Re: Can't have both " and ' in an XPath lite

Subject: Re: Can't have both " and ' in an XPath literal
From: rolf@xxxxxxxxxxxx
Date: Sun, 23 Apr 2006 04:45:49 +0200 (CEST)
xpath quot
Thanks for answering Ken, but ...

On 22 Apr, G. Ken Holman wrote:
> At 2006-04-23 02:27 +0200, rolf@xxxxxxxxxxxx wrote:
>>As far as I see, there is no way to have both ' (') and " (")
>>in one XPath literal.
> 
> Correct ... but literal operands can be constructed easily enough.
> 
>>Example:
> 
> (copied and modified below)
> [...] 
> How about the following?
> [...]
> T:\ftemp>type rolf.xml
> <doc>
>    <e att="foo">foo</e>
>    <e att="a&apos;&quot;b">bar</e>
>    <e att="grill">grill</e>
> </doc>
> 
> T:\ftemp>type rolf.xsl
> <?xml version="1.0"?>
> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> 
>    <xsl:template match="doc">
>      <xsl:for-each select="e[@att=concat(&quot;a'&quot;,'&quot;b')]">
>        <xsl:value-of select="."/>
>      </xsl:for-each>
>    </xsl:template>
> 
> </xsl:stylesheet>

Nice workaround for the my example. But as I wrote, that example is not
the real problem. I provided it only to illustrate the underlying
problem, I see with the XPath syntax.

The question (or problem) is not (only) an XSLT one, but more an XPath
problem.

Imagine a script language (in fact, that's the real scenario), which
got a DOM tree and is able to execute XPath expressions on that
tree. Now, the programmer want to select the elements with an
attribute x with an attribute value given by outside (say: user
input). If you want to programmatically create the needed XPath expr
(simplified something like: e[@x='<that random value comming from
elsewhere, you've no control over>']) then the question arises how to
escape the XPath literal delimiter character in that string.

There is no way to escape the XPath literal delimiter character
within a literal with the XPath syntax rules, as you confirm. OK, in
the scribbled case, the programmer could write a complex parsing rule,
to rewrite the wanted expression along the line you showed, but that
is, to word tempered, tedious.

rolf

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-2011 All Rights Reserved.