RE: [xsl] xpath confusion

Subject: RE: [xsl] xpath confusion
From: Jarno.Elovirta@xxxxxxxxx
Date: Thu, 3 Jul 2003 12:59:30 +0300
Hi,

> With the following xml:
> 
> <Root>
>     <Keys>
>          <Client id="abc">
>               <a />
>               <!-- a /--> 
>               <b />
>          </Client>
>     </Keys>
> </Root>
> 
> XPath: "Root/Keys/Client[@id="abc"]/ descendant-or-self::node()" 
> selects 4 nodes
> 
> XPath: "Root/Keys/Client[@id="abc"]/ descendant-or-self::comment()"
> selects 1 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 you have whitespace stipping turned on. It the whitespace was preserved, the first expression should return 8 and the third one 4.

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

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

Cheers,

Jarno - Various Artists: Leather Strip - Lies to Tell (Mix by Lights of Euphoria)

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


Current Thread