|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Creating a temporary tree in memory?
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








