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?


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


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

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

(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 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 15:45:10 UTC