Subject: RE: Storing and retrieving html tags in a variable
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Fri, 12 Sep 2003 10:59:27 +0100
|
> This doesn't seem to work:
> <xsl:variable name="doofus">
> <a href="doofus.html">click to go to doofus</a>
> </xsl:variable>
> <xsl:value-of select="$doofus"/>
>
> The resulting output is just "click to go to doofus", not
> "<a href="doofus.html">click to go to doofus</a>."
>
> Any way to store html tags in a variable,
> or to accomplish this by some other means?
Read up about the XPath data model. There is no such thing as a tag in
this model, elements and attributes are represented by nodes. The value
of your variable is a result tree fragment, consisting of a root node,
an <a> element node, an href attribute node, and a text node. You can
copy this tree fragment to the result tree, using a deep copy that
copies all these nodes except the root, by using <xsl:copy-of>. The
<xsl:value-of> instruction converts the argument to a string, and the
string-value of an element node or document root node is the
concatenation of its descendant text nodes.
Michael Kay
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|