User's Guide description of following:: vs following-sibling:: (needs an edit ?)

ComplexPoint's Avatar

ComplexPoint

30 Nov, 2012 05:55 AM

Under Axes, The User's Guide currently reads:

following : Returns nodes following each of the previously matched nodes matching predicate

following-sibling : Same as following axis, but also include current node

(and there's an analogous description of the difference between preceding:: and preceding-sibling::)

Experimentally, however, the real difference within each of these pairs seems to have more to do with something like:

  • all following/previous nodes, vs
  • following/previous siblings only

For example, running a query on the User's Guide itself,

  • /*/Axes/following::@type!=empty finds 306 matches, whereas
  • /*/Axes/following-sibling::@type!=empty finds only the 2 sibling sections: Set Operations and Predicates

Perhaps an edit to the User's Guide is needed ? The behaviour itself seems intuitively right and useful.

  1. 2 Posted by ComplexPoint on 30 Nov, 2012 06:02 AM

    ComplexPoint's Avatar

    For the moment, I've amended my copy to read:

    following

    : Returns all nodes following each of the previously matched nodes

    following-sibling

    : Returns sibling nodes following each of the previously matched nodes

    preceding

    : Returns all nodes preceding each of the previously matched nodes

    preceding-sibling

    : Returns sibling nodes preceding each of the previously matched nodes

  2. Support Staff 3 Posted by Jesse Grosjean on 30 Nov, 2012 04:28 PM

    Jesse Grosjean's Avatar

    Good catch, I've updated the user's guide to match.

  3. 4 Posted by ComplexPoint on 30 Nov, 2012 05:03 PM

    ComplexPoint's Avatar

    Was there perhaps a plan for two additional axes ?

    • following-sibling-or-self::
    • preceding-sibling-or-self::

    (I can see that they would be useful, and symmetrical with the other or-self axes)

  4. Support Staff 5 Posted by Jesse Grosjean on 30 Nov, 2012 05:14 PM

    Jesse Grosjean's Avatar

    No, at least not for the moment. I'm just trying to copy what Xpath provides, and I figure if they didn't need it then neither to do we...

    http://www.w3schools.com/xpath/xpath_axes.asp

    Our course we could add. But for now you should be able to get the same behavior with two paths (one to self and one to self following) and then union those two paths.

  5. 6 Posted by ComplexPoint on 30 Nov, 2012 05:56 PM

    ComplexPoint's Avatar

    Makes sense – standards and a kind of elegant parsimony both sound good :-)

    ( I had just wondered whether the original text had been displaced from elsewhere )

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac