This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Global Variable
- From: Mike Brown <mike at skew dot org>
- To: xsl-list at lists dot mulberrytech dot com
- Date: Thu, 15 Aug 2002 00:59:33 -0600 (MDT)
- Subject: Re: [xsl] Global Variable
- Reply-to: xsl-list at lists dot mulberrytech dot com
aruniima.chakrabarti@iflexsolutions.com wrote:
> I was trying something like this... but this won't really work as I want the
> node-list in the param.... Any ideas???
>
> <xsl:param name="Path" select="'p_ptr_str_ln_txn_inq_com'"/>
>
> <xsl:variable name="xpath">
> <xsl:choose>
> <xsl:when test="string-length($Path) != 0">
"string-length($Path) != 0" is longhand for just "$Path" (try it)
> <xsl:value-of select="//Header/*[name()=$Path]"/>
>
> </xsl:when>
> <xsl:otherwise>
>
> <xsl:value-of select="//Header"/>
>
>
> </xsl:otherwise>
> </xsl:choose>
> </xsl:variable>
You want xsl:copy-of, not xsl:value-of, (value-of means 'create a text node
from the string-value of this object, in this case the first node in this
node-set' ... whereas copy-of means 'copy this node-set')
Then $xpath will be a result tree fragment. To access it as a node-set you
will need to convert it to a node-set by passing it as an argument to the
exsl:node-set() extension function or your XSLT vendor's equivalent extension
function (check the docs).
<xsl:variable name="xp-nodeset" select="exsl:node-set($xpath)"
xmlns:exsl="http://exslt.org/common" />
- Mike
____________________________________________________________________________
mike j. brown | xml/xslt: http://skew.org/xml/
denver/boulder, colorado, usa | resume: http://skew.org/~mike/resume/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list