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

Re: Using variables to determine nodesets with conditi

Subject: Re: Using variables to determine nodesets with conditions
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Tue, 23 Sep 2003 12:16:17 +0100
xsl using variable node sets
Hi Paulo,

> I'm beginning to use variables to determine criteria for selecting nodes
> with
> <xsl:for-each select="*[local-name() = $nodename]"/>
>
> Nevertheless, this doesn't work if '$nodename' is a nodeset with a
> condition, for example:
> <xsl:variable name="nodename">PEOPLE/PERSON[NAME != 'Carlos']</xsl:variable>

In the above variable declaration, the $nodename variable is set to a
result tree fragment whose string value is "PEOPLE/PERSON[NAME !=
'Carlos']". If you want to set it to contain a node-set, then you
should use the select attribute of <xsl:variable>, not its content:

<xsl:variable name="nodename"
              select="PEOPLE/PERSON[NAME != 'Carlos']" />

When you set a variable using the select attribute, the XPath
expression held in the select attribute is evaluated and the variable
is set to the result. In this case, the $nodename variable to the
node-set of <PERSON> elements whose <NAME> element child is not equal
to 'Carlos'.

On the other hand, when you set a variable using its content, the
content is treated as a content constructor; any literal text is used
to create a text node, not evaluated as an XPath expression.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 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.