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

Re: XPath for selecting all text node children?

Subject: Re: XPath for selecting all text node children?
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Fri, 24 Aug 2001 14:52:52 -0400
xpath selecting text nodes
Ilkka:

The most recent preceding component, not including the component your context node is in, is

preceding::component[1]

All text node children of it are

preceding::component[1]/text()

but it sounds like you want

preceding::component[1]//text()

which is short for

preceding::component[position() = 1]/descendent-or-self::node()/child::text()

and includes "all text in the preceding component (no matter how the text nodes are nested)".

Keep in mind, however, that if you ask for the value of that set of text nodes, you'll get the value only of the first one (since the value of a node set is the value of the set's first node in document order). If you want a string that contains all the text node content of the preceding component, concatenated together, just ask for the value of that node itself (since the value of a node is the concatenation of the values of its text node descendents).

So try preceding::component[1]

I hope that helps,
Wendell

At 01:54 PM 8/24/01, you wrote:
Hi!

I've a problem I've been struggling with all day, I have the following XML:

<root>
    <component>
        <element>
            <element>...text here...</element>
        </element>
    </component>
</root>

Now, in xslt, I'd like to get a string from the preceding component (yes,
there are many of them), including all (no matter how the text nodes are
nested) text in the preceding component. I'm doing this inside a for-each
loop. What is the XPath expression for preceding "component"'s all text node
children? Is this even possible?

Regards,
Ilkka Hartikainen


======================================================================
Wendell Piez                            mailto:wapiez@xxxxxxxxxxxxxxxx
Mulberry Technologies, Inc.                http://www.mulberrytech.com
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
----------------------------------------------------------------------
  Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================


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.