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

Re: Problem with Sum function

Subject: Re: Problem with Sum function
From: Jon Gorman <jonathan.gorman@xxxxxxxxx>
Date: Mon, 22 Aug 2005 16:52:30 -0500
gorman function
I think I need a little alarm that beeps whenever one of my postings
gets longer than a page.  My last email might have been a little
confusing, and in my haste to get a reply off and get back to work I
might have let it run longer than I should have.  I apologize to all..

To summarize:

Your problem is essentially what I and the others guessed earlier.
You're using for-each loops and iterating through the whole set,
summing each node instead of summing values of multiple nodes.

Now, your example xml was a bit broken, and I'm just going to assume
that the server call takes care of calling the right Bnode.  If the I
take the example xml to be a somewhat accurate representation of your
paths, you should be able to do something like the below instead of
the current Bnode processing you have now.

<xsl:template name="Bnode">
  <xsl:variable name="sumNodes"
select="Bchild-nodes1/Bchild-node1[Bchild-node-num =
/root/nodes/node/child-nodes/child-node-num]"/>
  <xsl:value-of select="sum($sumNodes/Bchild-node-value)" />
</xsl:template>

This creates a node set of all the Bchild-node1 nodes that have a
node-num found in the root document's child-node-nums, based off the
path you had before.

It then simply gets the sum, without doing any calls to any other templates.


For that matter, I have a feeling that your server calls are a bit
more complex then needed as well.  However, I could imagine a system
where they would be cool to have.  Seeing as I have no idea what they
look like or how they work, can't tell you much in this vein though.

Of course, if you're also doing something else with your for-each
loops you can go ahead and do that separately from the sum.

Jon Gorman.

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.