Re: [xsl] XPath grammar questions

Subject: Re: [xsl] XPath grammar questions
From: Oleg Tkachenko <olegt@xxxxxxxxxxxxx>
Date: Sun, 17 Mar 2002 20:13:25 +0200
Sean Russell wrote:

The first case is in a path submitted by Tobias Reif, that originated, as I recall, from someone on this list:

*[* and not(*/node()) and not(*[not(@style)]) and not(*/@style != */@style)]

Specifically, it's the 'not(*/node())' that I'm having trouble with. The XPath spec states that:

not( boolean ) -> boolean

This would imply that '*/node()' evaluates to a boolean.
No, it says that *required* type of the argument must be boolean. Generally that is FunctionCall production (see http://www.w3.org/TR/xpath.html#NT-FunctionCall):
"A FunctionCall expression is evaluated by using the FunctionName to identify a function in the expression evaluation context function library, evaluating each of the Arguments, converting each argument to the type required by the function, and finally calling the function, passing it the converted arguments."
An argument is converted to boolean type "as if by calling boolean function".


The second (and at this point, more critical) problem I'm having is with function names. Take:

[normalize-space(@name)='x']

If you follow the grammar, the evaluation is:

   Predicate->Expr->OrExpr->AndExpr->EqualityExpr->RelationalExpr->
   AdditiveExpr

at which point it matches the rule:

AdditiveExpr:: AdditiveExpr '-' MultiplicativeExpr

No, it shouldn't.
"normalize-space" is NCName itself and according to the spec "When tokenizing, the longest possible token is always returned.", so lexer must parse it as FunctionName according to "If the character following an NCName (possibly after intervening ExprWhitespace) is (, then the token must be recognized as a NodeType or a FunctionName."



where you effectively have "normalize" "-" "space(@name)='x'".
No, lexer must return the longest token, which is "normalize-space" as NCName.

--
Oleg Tkachenko
Multiconn International, Israel


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



Current Thread