Subject: RE: [xsl] xpath confusion From: "Michael Kay" <mhk@xxxxxxxxx> Date: Thu, 3 Jul 2003 12:08:34 +0100 |
> > 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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] xpath confusion, David Carlisle | Thread | Re: [xsl] xpath confusion, David Carlisle |
[xsl] xslt 2. index-of, nodes, David . Pawson | Date | Re: [xsl] url query works with mozi, William S. |
Month |