At 2011-05-12 15:58 -0400, Mike Sokolov wrote:
>On 05/12/2011 02:52 PM, Evan Lenz wrote:
> > I think most beginners expect .//foo to be short for descendant::foo
> > (which I'm guessing is what you meant), especially since in examples
> > like that they return the exact same results. // is only a gotcha when
> > you start using positional predicates (so be suspicious whenever you
> > see them together without parentheses).
>
>Actually I did mean ./descendant-or-self::foo, since
>
>./descendant-or-self::foo[1] is actually the same as (.//foo)[1]
>
>(isn't it?)

No, it is not the same.

>whereas (as you pointed out)
>
>.//foo[1] is the same as ./descendant-or-self::node()/self::foo[1]

Yes, Evan is correct.

>I think I have it right :)

I think you have it wrong.  I teach what Evan believes to be true.

Consider what the return node set is if the current node is the element <foo>:

   (1) - ./descendant-or-self::foo[1] returns the current node
   (2) - (.//foo)[1] does not return the current node

I hope this example helps.

. . . . . . . Ken

--
Contact us for world-wide XML consulting & instructor-led training
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/q/
G. Ken Holman                 mailto:[email protected]
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal

_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to