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

Re: "self" axis for an attribute context node

  • From: David Carlisle <davidc@n...>
  • To: olpa@x...
  • Date: Mon, 12 Mar 2007 10:33:01 GMT

Re:  "self" axis for an attribute context node

> I thought that the following XPath steps are equivanent:
> something[name()='lalala']
> something[self::lalala]
> However, it isn't so.

No, over on xsl-list we regularly have to steer people towards using
self:: (which is namespace-aware) rather than testing name() (which is
not) so even for elemnets (when they may both work in some cases) self::
is preferable.

For attributes (and other node types) self:: doesn't work at all as the
principle node type is element, so @*[self::type] means select all
attributes that are element nodes with name type, which is empty.
This is unfortunate as it means in XSLT1 to say "all attributes
except xlink:href"  you are more or less led to use
which forces you to fix a prefix, or to use local-name() and
namespace-uri and test the namepsace URI explictly)
In Xpath2 you can say 
@* except @link:href
which is a bit more readable, and safe for other prefixes.


[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


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.
First Name
Last Name
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.