[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: xsl:variable?

Subject: RE: xsl:variable?
From: "Martinez, Brian" <brian.martinez@xxxxxxxxxxx>
Date: Wed, 26 Nov 2003 10:15:06 -0700
tix tree variable
> From: Nicolas Toper [mailto:ntoper@xxxxxxxx]
> Sent: Wednesday, November 26, 2003 9:45 AM
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  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.martinez@xxxxxxxxxxx |
| 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


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.