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

RE: [XPath] is it legal ?


xpath select nothing
> as everything is a node, one can match a node like this :
>      node()

I assume we're talking about XPath path expressions here, not XSLT match
patterns: so it might be better to use the verb "select" rather than
"match".

Yes, node() is short for child::node(), it selects any node on the child
axis.

> which works well in the axis that are walking through the tree
> what about other axis ?
>      @node()
>      namespace::node()
> which would give the same as (respectively) :
>      @*
>      namespace::*

Correct.

> and above all what about :
>      @comment()
>      @text()
>      @p-i(target)
>      namespace::comment()
>      namespace::text()
>      namespace::p-i(target)
> which are all empty if they are legal
> 
> but are they legal ?

Yes, they are legal in XPath 1.0. They all select an empty set of nodes. In
XPath 2.0, with static typing, they have a static type of empty-sequence(),
which is a type error that can be reported at compile time if the processor
chooses to do static type checking.

> 
> here are the last ones :
>      /@*
>      /namespace::*
> 
Again these are legal, and select nothing. The same applies to, for example,
@*/@*

> 
> 
> Will you be hurted if someone (like me) was writting 
> something like this :
>      $foo/@bar/@oof
> 
If your data conforms to the XPath data model, then this will select
nothing. If you want to design a language similar to XPath that works on a
different data model, for example one in which attributes can have
attributes, then you are free to do so (but please don't call it XPath).

Michael Kay
http://www.saxonica.com/



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
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

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.