[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: David Carlisle <davidc@xxxxxxxxx>
Date: Tue, 23 Sep 2003 12:29:46 +0100
xsl variable node name
> Nevertheless, this doesn't work if '$nodename' is a nodeset with a
> condition, for example:

Nodestes themselves don't have conditions, although a condition may have
been used to select the nodes. the variable stores the result (the set of
nodes) not the expression used to select it.

It does work, local-name() = $nodename is a string valued equality test
so $node-name will be coerced to a string by taking the string value of
the first node in document order in the set and comparing it with
local-name().

Howevr the variable binding you showed does not generate a nodeset at
all.
<xsl:variable name="nodename">PEOPLE/PERSON[NAME != 'Carlos']</xsl:variable>
just makes a result tree fragment with a root node and a text node with
the string "PEOPLE/PERSON[NAME != 'Carlos']" there is no way in XSLT to
evaluate an Xpath that is contained in a string, although some systems
have extension functions to do that.
However perhaps you want the node set selected by that expressuion,
which would be

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

then 
<xsl:for-each select="*[local-name() = $nodename]"/>

would work and be the same as

<xsl:for-each select="*[local-name() = current()/PEOPLE/PERSON[NAME != 'Carlos']]"/>

which would select all teh child elements whose local name was teh same
as the string value of the first PEOPLE/PERSON child whose NAME was not
Carlos.

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

 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.