xsl-list
[Top] [All Lists]

Re: Setting variable based on passed in parameter

2004-11-30 09:24:14

  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
________________________________________________________________________

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--