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

Re: missing XPath axis

  • From: "G. Ken Holman" <gkholman@CraneSoftwrights.com>
  • To: "xml-dev@lists.xml.org" <xml-dev@lists.xml.org>
  • Date: Sat, 24 Sep 2011 12:06:06 -0400

Re:  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


  • References:
    • missing XPath axis
      • From: "Johannes.Lichtenberger" <Johannes.Lichtenberger@uni-konstanz.de>

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


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.