Subject: Re: [xsl] xpath question From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx> Date: Fri, 4 Jul 2003 12:27:40 +0100 |
Hi Abbouh, > what is the difference between these xpaths: > //table/tgroup/tbody/row[1]/entry[1]/child::node()[1] > and > //table/tgroup/tbody/row[1]/entry[1]/ce[1] > //table/tgroup/tbody/row[1]/entry[1]/para[1] The first selects the first of all the child nodes of the <entry> element. In your example: > <entry colname="col1"> > <ce>aaaaa</ce> > <ce>(1)</ce> > </entry> the first child of the <entry> element is a whitespace-only text node, containing a newline character, between the start tag of the <entry> element and the start tag of the <ce> element. If you want to get the first element within the <entry> element then use: //table/tgroup/tbody/row[1]/entry[1]/*[1] Or you could strip the whitespace-only text nodes from within the <entry> elements by adding: <xsl:strip-space elements="entry" /> at the top level of your stylesheet. The reason that you get different results in Xalan and XML Spy (which uses MSXML) is that MSXML by default automatically strips all whitespace-only text nodes from a document, whereas Xalan doesn't. Cheers, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] xpath question, David Carlisle | Thread | [xsl] xpath question, abbouh |
Re: [xsl] xpath question, David Carlisle | Date | Re: [xsl] Re: Re: XSLT Architecture, David Carlisle |
Month |