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

Re: //* and position()

Subject: Re: //* and position()
From: Gary L Peskin <garyp@xxxxxxxxxxxx>
Date: Wed, 06 Sep 2000 23:35:12 -0700
Re: //* and position()
Mike Brown wrote:
> 
> Someone explain this to me:
> 
> [snip]

Mike --

This points out the difference between using a predicate as part of a
location step (Xpath production [4]) and using a predicate as part of a
FilterExpr (Xpath production [20]).

In the case of //*[position() &lt; 3], this is an abbreviation for

	/descendents-or-self::node()/child::*[position() &lt; 3]

In other words, this will select any node that is one of the first two
children of another node.  This is how a predicate is used as part of a
location step.

In the case of $all_elements[position() &lt; 3] (equivalent to
(//*)[position() &lt; 3]), this will select the first two items in the
node-set $all-elements.

As Mike Kay mentions in his excellent book (at p. 382 at the bottom), []
binds more tightly than /.

>The first and 3rd methods return all elements, regardless of position.

Well, not really, depending on your input XML.  They any node that is
one of the first two children of another node.  If none of your nodes
have more than two children, the first and 3rd methods will return all
elements.  Try adding a third child to one of your nodes and you'll see
that it won't be returned.

HTH,
Gary


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

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
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.