|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] recursive addition
I have a structure (much like a file system) where elements of the same type are linked together via IDs rather than the XML structure--i.e. all directory elements are at the same level.
For an arbitrary directory level element, I want to sum a numeric attribute for all linked elements and so on down the tree.
Is there any way to do this? I know that recursion is the first step, but what I don't know how to sum an arbitrary number of parallel level attributes in different elements.
Here's an example:
<root>
<folder files="2" id="dir0">
<file id="dir1" />
<file id="dir4" />
</folder>
<folder files="4" id="dir1">
<file id="dir2" />
<file id="dir3" />
</folder>
<folder files="3" id="dir2" />
<folder files="6" id="dir3" />
<folder files="7" id="dir4" />
<folder files="5" id="dir5" />
</root>
If my arbitrary element id is "dir1", then the result should be 9. (folder[@id='dir2']/@files + folder[@id='dir3']/@files)
How do I do that with xsl?
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








