This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: XPath for selecting all text node children?
- To: xsl-list at lists dot mulberrytech dot com
- Subject: Re: [xsl] XPath for selecting all text node children?
- From: Wendell Piez <wapiez at mulberrytech dot com>
- Date: Fri, 24 Aug 2001 14:52:52 -0400
- Reply-To: xsl-list at lists dot mulberrytech dot com
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@mulberrytech.com
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