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

RE: Selecting all siblings and self into a node-set

Subject: RE: Selecting all siblings and self into a node-set
From: <Jarno.Elovirta@xxxxxxxxx>
Date: Mon, 29 Mar 2004 10:27:13 +0300
node set xsl
Hi,

> Then I have a template matching "webpage":
> 
> <xsl:template match="webpage" mode="meta2">
>    <xsl:variable name="menu-names">
>      <xsl:value-of select="preceding-sibling::webpage[*]/name"/>
>      <xsl:value-of select="name" />
>      <xsl:value-of select="following-sibling::webpage[*]/name"/>
>    </xsl:variable>
> 
>    <xsl:value-of select="$menu-names" />
>    <xsl:apply-templates mode="meta2" />
> </xsl:template>

[snip]

> which indicates that each "value-of" operator is only
> picking up one node.
> 
> How can I get _all_ preceding and following
> node's "name" elements into a single node-set?

In the template above you're creating Result Tree Fragment; use the select attribute if you want to bind a variable to a node-set.

  <xsl:variable name="menu-names" select="preceding-sibling::webpage/name | name | following-sibling::webpage/name" />

or simply

  <xsl:variable name="menu-names" select="../webpage/name" />

Note that xsl:value-of will extract the string value and if you give it a node-set, it will return "the string-value of the node in the node-set that is first in document order". Use xsl:for-each to go throught the nodes and output their string values.

Cheers,

Jarno - Hypnoskull: We Know It All - We Know All

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.