This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: xsl:variable containing xsl:element
- To: xsl-list at lists dot mulberrytech dot com
- Subject: Re: [xsl] xsl:variable containing xsl:element
- From: David Carlisle <davidc at nag dot co dot uk>
- Date: Fri, 26 Jan 2001 14:52:58 GMT
- References: <31767643794BD411977600D0B747AC76016A7088@zwicky.gva.hp.com>
- Reply-To: xsl-list at lists dot mulberrytech dot com
> I have the following problem when assigning a string to a variable.
You don't want a string, you want a node set.
// This works fine - displaying the number bold
This is my account <xsl:element name="b">123.456</xsl:element> now
closed
it would have been simpler to use <b>123.456</b> rather than
xsl:element.
<xsl:variable name="wholestring">This is my account <xsl:element
name="b">123.456</xsl:element> now closed</xsl:variable>
same there, you could have used <b>
That doesn't make $wholestring a string it makes it a reseult tree
fragment consisting of a tree of five nodes
root: /
text: "This is my account "
element: b
text: "123.456"
text: " now closed"
<xsl:value-of select="string($wholestring)"/>
value-of gives the string value of is argument, so the above is
equivalent to
<xsl:value-of select="$wholestring"/>
the string value of a result tree fragment is just the character data.
You want a copy of the tree itself.
<xsl:copy-of select="$wholestring"/>
which will wok, although looks confusing as the variable is called
wholestring, but isn't a string.
David
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list