[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: XPath grammar questions

Subject: Re: XPath grammar questions
From: "David N Bertoni/Cambridge/IBM" <david_n_bertoni@xxxxxxxxxx>
Date: Sun, 17 Mar 2002 12:02:44 -0800
subtraction xpath
> 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.  However, it
also
> states that paths such as:
>
>   ancestor::node()
>
> evaluates to a set of matching nodes.  Further, I had assumed that the
path:
>
>   */node()
>
> by itself would also result in a set of nodes.
>
> I have a group of theories about this, but I'm not quite grokking the
intent
> of XPath.  I don't see how the same path should evaluate to two different

> results.  In any case, there have been a number of successful
implementations
> of XPath, so I know I'm missing something.

The rules for conversion are spelled out in the XPath recommendation,
although can get prettty convoluted.  In this case, an empty node-set is
converted to the boolean value false, while a non-empty node-set is
converted to the boolean value true.

> 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

> where you effectively have "normalize" "-" "space(@name)='x'".

Your tokenization is incorrect -- normalize-space is one token. See:

   http://www.w3.org/TR/xpath#exprlex

In particular:

   "When tokenizing, the longest possible token is always returned"

Also, see:

   http://www.w3.org/TR/xpath#numbers

   "The - operator performs subtraction.

   NOTE: Since XML allows - in names, the - operator typically needs to be
   preceded by whitespace. For example, foo-bar evaluates to a node-set
   containing the child elements named foo-bar; foo - bar evaluates to the
   difference of the result of converting the string-value of the first foo
   child element to a number and the result of converting the string-value
   of the first bar child to a number."

Dave



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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.