Subject: Re: [xsl] Problem with Sum function From: Jon Gorman <jonathan.gorman@xxxxxxxxx> Date: Mon, 22 Aug 2005 16:52:30 -0500 |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Problem with Sum function, Jon Gorman | Thread | RE: [xsl] Problem with Sum function, cknell |
[xsl] xsl:sort clarification, Jack Matheson | Date | Re: [xsl] xsl:sort clarification, David Carlisle |
Month |