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

Re: xpath confusion

Subject: Re: xpath confusion
From: David Carlisle <davidc@xxxxxxxxx>
Date: Thu, 3 Jul 2003 11:00:43 +0100
descendant or self

there are 4 possible answers that a compliant system could give to

   XPath: "Root/Keys/Client[@id="abc"]/ descendant-or-self::node()" 
8, 6, 4 or 3

as there there is the Client node itself (as you used descendant-or-self
rather than child) plus 7, 5, 3 or 2 child nodes.

The child nodes are counted as follows:

7: Your XML preserves all white space and comments, and your stylesheet
   isn't discarding white space with xsl:strip-space

5: Your XML parser discards comments but white space is preserved

3: your parser keeps comments but the parser or stylesheet are
   discarding white space

2; your parser discards comments and teh parser or stylesheet is
   dicarding white space.




So it seems that you are discarding white space most likely you have
xsl:strip space somewhere or are using MSXML which takes a cavalier
attitute to (not) preserving space in the input document.



That assumption then explains your remaining queries
  XPath: "Root/Keys/Client[@id="abc"]/ descendant-or-self::comment()"
  selects 1 node

you have one child node, here descendant-or-self::comment
is the same as descendant::comment you don't get 1 extra node from the
current Client  node, as that isn't a comment.


  XPath: "Root/Keys/Client[@id="abc"]/ descendant-or-self::text()"
  selects 0 nodes. 
  
As above on the assumption you've discared the white space, there are no
text node children, and the Client node is an element not text so 0 it
is.


  I would like to select the 3 nodes <Client>, <a /> and <b />. Any help is
  appreciated.

  Root/Keys/Client[@id="abc"]/descendant-or-self::*

will select Client and its element children and return 3 nodes.

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

 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.