W3C home > Mailing lists > Public > public-qt-comments@w3.org > September 2002

RE: XPath 2.0 -- StepExpr question

From: Kay, Michael <Michael.Kay@softwareag.com>
Date: Mon, 23 Sep 2002 20:50:02 +0200
Message-ID: <DFF2AC9E3583D511A21F0008C7E621060453DBB1@daemsg02.software-ag.de>
To: Jeff Kenton <jkenton@datapower.com>, "Kay, Michael" <Michael.Kay@softwareag.com>
Cc: public-qt-comments@w3.org

> Michael,
> 
> Thanks for the quick reply.
> 
> Perhaps I chose a bad example.  I still don't see the use of 
> allowing a 
> PrimaryExpr as a StepExpr.  Since it was just added to the 
> WD, I assume 
> there was a good use for it.  Can you show an example?
> 

Sure,

(1)   document('a.xml')/id('a123')
(2)   book/(chapter|appendix)/section

Also

(3)   $x/(/)
though we also provide the more comfortable syntax xf:root($x) for this
one...

Basically, there is no good reason to treat "/" differently from any other
operator. Syntactically, its operands can be any expression, and restricting
the operands is done through type rules, not by using the grammar.

There is one slightly unfortunate consequence, which is that it's legal to
write things on the rhs of "/" that don't depend on the context node, for
example

(4)  document('a.xml')/document('b.xml')
(5)  book/$param   {--legal if $param is a node-sequence --}

In this case, the lh operand is effectively ignored. I think there's a good
case for implementations to produce warnings when such constructs are used:
it's similar to the problem that occurs in XSLT 1.0 when people write
<xsl:sort select="$param"/>, and the most likely explanation is the same -
because of the "$" sign, many beginners imagine that variables are macros.

Michael Kay
Received on Monday, 23 September 2002 14:50:09 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 27 March 2012 18:14:23 GMT