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] missing XPath axis

At 2011-09-24 16:58 +0200, Johannes.Lichtenberger wrote:
>I just wandered what was the reason for the authors of the XPath
>recommendations to not include the XPath axis 'child-or-self::' as a
>counterpart to 'descendant-or-self::' in XPath 1.0, 2.0 or at all?
>
>Although I'm not sure if this is the appropriate mailinglist to ask --
>just in case, please point me to the right mailinglist.
>
>I know it's doable via 'expression/(self::node()|node())' but I think
>that's more or less a work around to the lack of the 'child-or-self::' axis.

I suspect you may find that it was the other way around than you 
think:  that Mukul's principle of not duplicating behaviour is a 
better overriding principle unless absolutely necessary.  Don't have 
two ways to do one thing.

So, there is no child-or-self:: axis because one can write (.|node()) 
as Mukul shows ... but that is for XSLT 2.

Why have descendant-or-self:: axis?  I'm guessing it is a necessary 
facility in XPath 1 to implement the "//" abbreviation ... which 
expands as "/descendant-or-self::node()/".

XPath 1 syntax does not allow the use of parentheses after the first 
step in a location path expression, thus 
"/abc/(.|descendant::node())/def/" isn't valid syntax.  If it isn't 
valid, then that can't be the expansion of the "//" abbreviation.

Thus, you need to expand it as "/descendant-or-self::node()/" thus 
requiring an axis ... in this case it isn't duplication since the 
other syntax isn't allowed.  As for ancestor-or-self::, I can't think 
of a syntax reason, but having it might help in the implementation of 
the lang() function where it would be useful.

I wasn't on the XPath committee, so I cannot tell you if this was the 
design decision or not.  But this rationale fits well for my 
accepting that there is a descendant-or-self:: axis but not a 
child-or-self:: axis.

And I can't think of a general use case for child-or-self:: either.

I hope this is considered helpful.

. . . . . . . . .  Ken


--
Contact us for world-wide XML consulting and instructor-led training
Crane Softwrights Ltd.            http://www.CraneSoftwrights.com/x/
G. Ken Holman                   mailto:gkholman@CraneSoftwrights.com
Google+ profile: https://plus.google.com/116832879756988317389/about
Legal business disclaimers:    http://www.CraneSoftwrights.com/legal



[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