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

Re: xpath question

Subject: Re: xpath question
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Fri, 4 Jul 2003 12:27:40 +0100
xpath strip whitespace
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
  • xpath question
    • abbouh - Fri, 4 Jul 2003 07:02:54 -0400 (EDT)
      • David Carlisle - Fri, 4 Jul 2003 07:24:44 -0400 (EDT)
      • Jeni Tennison - Fri, 4 Jul 2003 07:27:53 -0400 (EDT) <=
      • <Possible follow-ups>
      • abbouh - Wed, 9 Jul 2003 09:29:46 -0400 (EDT)

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.