tags:

views:

277

answers:

1

So here is my current code:

<xsl:variable name="address">
    <xsl:value-of select="concat(/node1/node2/address.node/street, /node1/node2/address.node/city, /node1/node2/address.node/zip)" />
</xsl:variable>

Now, I'm trying to shorten this down to:

<xsl:variable name="addressNode">
    <xsl:value-of select="/node1/node2/address.node" />
</xsl:variable>

<xsl:variable name="address">
    <xsl:value-of select="concat($addressNode/street, $addressNode/city, $addressNode/zip)" />
</xsl:variable>

However this is not working at all as expected... could anyone point me in the right direction? I tried using copy-to instead of value-of for addressNode, but it still isn't working :(

+3  A: 

When you use xsl:value-of inside xsl:variable you get a variable of type string, not a node. You should use use the select attribute of xsl:variable:

<xsl:variable name="addressNode" select="/node1/node2/address.node" />
Jörn Horstmann
I'll give this a shot and let you know how it goes
Polaris878
This worked, thanks... I'm obviously a bit new to XSL :D
Polaris878
I wish I could give you more rep for this answer haha
Polaris878
The "group of nodes" bit is missing, so I add it here: `select="$addressNode/street|$addressNode/city"`. (The `|` is the XPath "union" operator. It creates a nod-set from separate nodes.)
Tomalak
sweet thanks Tomalak
Polaris878