Subject: Re: [xsl] Setting variable based on passed in parameter From: David Carlisle <davidc@xxxxxxxxx> Date: Tue, 30 Nov 2004 16:24:14 GMT |
I'm trying to assign a variable a node-set that depends on a parameter passed into the stylesheet. <xsl:variable name="initialResult"> <xsl:choose> If you use xsl:variable with content rather than a select attribute the result is always a result tree fragment and never a node set. Most XSLT processors have an xx:node-set() extension function that will coerce the result tree fragment to a node set (of one node, a / node of a new tree contating the nodes you have generated) actually in this case you have used value-of so you have only a single string value so your node set would have no element nodes just a root node containing a text node with this string. xsl:value-of when supplied a node set always discards all but the first node, and returns the string value of the first. Both brances of your choose selected the same thing but I suppose that's a cutnpaste error? however I don't think you want to generate new nodes, just select nodes in the source, so: <xsl:variable name="initialResult" select=" /one[$valueSearch='false']/two[three/four[contains(text(),$nodeValue)]] | /one[$valueSearch!='false']/two[three/four[contains(text(),$nodeValue)]] "/> David ________________________________________________________________________ This e-mail has been scanned for all viruses by Star. 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 ________________________________________________________________________
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Setting variable based on pas, Matthew Hailstone | Thread | Re: [xsl] Setting variable based on, Richard Lewis |
[xsl] Setting variable based on pas, Matthew Hailstone | Date | Re: [xsl] how to set the pattern to, que Li |
Month |