This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Creating a temporary tree in memory?
- From: Jeni Tennison <jeni at jenitennison dot com>
- To: "Khalid" <k_ali at telusplanet dot net>
- Cc: XSL-List at lists dot mulberrytech dot com
- Date: Fri, 25 Jan 2002 18:16:07 +0000
- Subject: Re: [xsl] Creating a temporary tree in memory?
- Organization: Jeni Tennison Consulting Ltd
- References: <3c5190b2.51a1.0@telusplanet.net>
- Reply-to: xsl-list at lists dot mulberrytech dot com
Hi Khalid,
> Can I create a tree, like the one below using xslt
>
> <root-node>
> <node>1</node>
> <node>2</node>
> <node>3</node>
> </root-node>
>
> and then get sum of all of the above nodes.something like sum(node)
> that would return 6.
If you need to dynamically create this tree, then you can build the
tree with:
<xsl:variable name="node-rtf">
<node>1</node>
<node>2</node>
<node>3</node>
</xsl:variable>
But you then need to use the appropriate node-set() extension function
for your processor to convert the result tree fragment to a node set,
in order to sum the values of the node elements. For example with
MSXML this would be:
sum(msxsl:node-set($node-rtf)/node)
If you don't need to dynamically create the tree, then you can just
include it at the top level of your stylesheet (though you'll have to
put the root-node element in a namespace) and access it through the
document() function:
sum(document('')/xsl:stylesheet/my:root-node/node)
Cheers,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list