Re: XPath questions: QName Reduction and ".." Recursion

Chin Chee Kai <cheekai@alumni.stanford.org> wrote:
> (1) ".." Recursion
> what is the semantics for a repeated use of this parent operator such
> that the parent of the root of document ... is attempted to be evaluated?
> ...
> Current spec doesn't seem to treat this case in any special way,
> so that the result of the above example would return an empty nodeset.

Correct. Section 2.2 says:
    the parent axis contains the parent of the context node, if there is
one;
So, in the context of the root node, the parent axis is empty, and repeated
applications of ".." will still be empty.

> (2) QName Reduction
> There appears to be a reduction-reduction conflict on the PathExpr
> rule when a QName '(' ')' token sequence is found in the input 
> XPath stream.

There is indeed a reduction-reduction conflict in the LR(0) automaton. XPath
cannot be parsed deterministically without lookahead.  Thus, the solution is
to use a lookahead symbol.  Specifically, the second "special tokenization
rule" applies in this case:

    If the character following an NCName (possibly after intervening
    ExprWhitespace) is (, then the token must be recognized as a
    NodeType or a FunctionName.

(and not as a WildcardName).

> My suggestion is that perhaps it would be less confusing to
> implementors and make the intended meaning clearer by 
> specifying that priority should be given to FilterExpr reduction
> over LocationPath in PathExpr.

But what about the cases where the LocationPath reduction is the right one?

-Michael Dyck

Received on Thursday, 19 August 1999 04:25:59 UTC