[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Creating a temporary tree in memory?

Subject: Re: Creating a temporary tree in memory?
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Fri, 25 Jan 2002 18:16:07 +0000
temporary tree
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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.