W3C home > Mailing lists > Public > www-ql@w3.org > July to September 2003

(non) associativity slash operator

From: Jan Hidders <jan.hidders@ua.ac.be>
Date: Fri, 18 Jul 2003 15:37:50 +0200
To: www-ql@w3.org
Message-ID: <20030718153750.A27773@hmacs.ruca.ua.ac.be>

I have two questions about the associativity of the slash operator.

1. Why is the slash operator in XPath 2.0 defined in a non-associative way?

Having such algebraic identities is obviously important for
query optimization and I am in fact myself studying certain optimization
problems where having this identity would really simplify things. Hence the
question. The reason that the slash operator is not associative at the
moment is that it sets the position() and last() values. However, in XPath
1.0 I don't think you are actually able to use these values. The reason for
that is that after a slash there must be a <Step> expression and in that you
can only call functions inside a predicate, but for such a predicate the
values of position() and last() are overridden. So if I am correct then the
slash operation *is* actually associative in XPath 1.0, even though its
semantic definition seems otherwise. So that makes me wonder about the
reason why such a valuable algebraic identity was dropped.

2. Is the slash operator left- or right-associative?

In XPath 1.0 the slash operator was left-associative because of the way that
the syntax was defined. In the current XPath 2.0 syntax I think this is not
clear anymore, at least not from the syntax definition. If I look at the
normalization rules for the slash operator then there is only a rule for the
binary case (<stepExpr> / <stepExpr>) which means that if I have an
expression of the form

  <stepExpr> / <stepExp> / <stepExpr>

I can choose which slash I am going to normalize first, which makes the
semantics more ambiguous than is probably wanted.

Kind regards,

-- Jan Hidders
Received on Friday, 18 July 2003 09:37:57 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 22:43:42 UTC