This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: Tree Fragment - How do I test it AND output it?
- From: "Michael Kay" <michael dot h dot kay at ntlworld dot com>
- To: <xsl-list at lists dot mulberrytech dot com>
- Date: Tue, 18 Dec 2001 09:35:20 -0000
- Subject: RE: [xsl] Tree Fragment - How do I test it AND output it?
- Reply-to: xsl-list at lists dot mulberrytech dot com
> How do I both test the "return" value from a template, and
> output some of the result nodes?
>
You put the result in a variable (a "result tree fragment" or temporary
tree):
<xsl:variable name="tree">
<xsl:call-template name="make-tree"/>
</xsl:variable>
You can copy this tree to the result tree using copy-of:
<xsl:copy-of select="$tree"/>
You can access the string value of the tree tree directly (that is, the
concatenation of its text nodes):
<xsl:if test="string($tree)='tangerine'"/>
To access the detailed structure of the tree you need the xx:node-set
extension:
<xsl:variable name="root" select="xx:node-set($tree)"/>
You can then use path expressions or xsl:apply-templates to manipulate the
tree in the same way as a source tree:
<xsl:apply-templates select="$root" mode="temp-tree"/>
Mike Kay
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list