XML.orgXML.org
FOCUS AREAS |XML-DEV |XML.org DAILY NEWSLINK |REGISTRY |RESOURCES |ABOUT
OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
Re: [xml-dev] "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
@*[not(name()='xlink:href')]
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.
 

David




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


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 1993-2007 XML.org. This site is hosted by OASIS