From: Nicolas Toper [mailto:ntoper(_at_)jouve(_dot_)fr]
Sent: Wednesday, November 26, 2003 9:45 AM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] xsl:variable?
Hi,
I'm trying to put a node-set in a a variable but I can't make
it work...
Here is a snippet of my code:
<xsl:variable name="t">
<a href=".."><xsl:value-of select="y"></a>
</...
<xsl:value-of select="concat($t,...)...
I get only y as an output. Any idea please?
Assuming you're working with XSLT 1.0, this is an extreme FAQ. Variables
that contain template bodies always return a result tree fragment (RTF)--and
there is no way to cast such variables to a node-set without resorting to
the node-set() extension function that's available with most processors.
One way to fix this would be to use a select attribute on the variable:
<xsl:variable name="t" select="y"/>
Assuming y is a valid node in your input, you can now write:
<a href="..."><xsl:copy-of select="$t"/></a>
copy-of will write $t including its child nodes to the result tree; value-of
will only copy its textual content--child elements are ignored.
hth,
b.
| brian martinez
brian(_dot_)martinez(_at_)cendant(_dot_)com |
| lead gui programmer 303.357.3548 |
| cheap tickets, part of trip network fax 303.357.3380 |
| 6560 greenwood plaza blvd., suite 400 englewood, co 80111 |
| cendant travel distribution services http://www.cheaptickets.com/ |
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list