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

RE: xpath confusion

Subject: RE: xpath confusion
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Thu, 3 Jul 2003 12:08:34 +0100
xpath root
> 
> With the following xml:
> 
> <Root>
>     <Keys>
>          <Client id="abc">
>               <a />
>               <!-- a /--> 
>               <b />
>          </Client>
>     </Keys>
> </Root>

>From your results, it seems that whitespace text nodes have been
stripped from the data model. This happens when you say
<xsl:strip-space="*"/>, or in the case of Microsoft, it happens by
default. 
> 
> XPath: "Root/Keys/Client[@id="abc"]/ descendant-or-self::node()" 
> selects 4 nodes

The four nodes are the <Client> element, the <a> element, the comment,
and the <b> element.
> 
> XPath: "Root/Keys/Client[@id="abc"]/ 
> descendant-or-self::comment()" selects 1 node

This is the comment node.
> 
> XPath: "Root/Keys/Client[@id="abc"]/ 
> descendant-or-self::text()" selects 0 nodes. 
> 
> Please can someone explain to me why the last xpath doesn't 
> select 3 nodes.

Because none of the four nodes selected by descendant-or-self::node()
are text nodes. You would get some (whitespace-only) text nodes if you
hadn't stripped them from the data model.
> 
> I would like to select the 3 nodes <Client>, <a /> and <b />. 
> Any help is appreciated.
> 
Use descendant-or-self::*. The "*" selects all the nodes that are
elements.

Michael Kay


 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.