|
Subject: Re: [xsl] Problem with Sum function From: Meena Nanjundeswar <meenasargur@xxxxxxxxx> Date: Mon, 22 Aug 2005 14:05:31 -0500 |
Well, the scenario is a little complicated. I have a stylesheet A with
an xml file A. Now, inside stylesheets A, I am displaying some
elements from an external XML file B, based on some values in
stylesheet A.
Eg:
XML A:
<root>
<nodes>
<node>
<node--num>123</node-num>
<child-nodes>
<child-node-num>456</child-node-num>
<child-node-num>789</child-node-num>
</child-nodes>
</node>
</nodes>
</root>
Now, my external xml file B has some additional values based on the
node-num and child-node-num from XML file A.
Eg: XML B would be like this:
<Bnode>
<Bnode-num>123</Bnode-num>
<Bchild-nodes1>
<Bchild-node1>
<Bchild-node-num>456</Bchild-node-num>
<Bchild-node-value>22</Bchild-node-value>
<Bchild-node1>
<Bchild-node1>
<Bchild-node-num>789</Bchild-node-num>
<Bchild-node-value>29</Bchild-node-value>
<Bchild-node1>
</Bchildnodes1>
</Bnode>
Here is what I am doing in my stylesheet A. Now, I have some external
server calls made to match the node-num and child-node-num from XML A
with the correspondng values on XML B and display the
sum(Bchild-node-value).
<xsl:template name="Bnode">
<xsl:param name="mode"/>
<xsl:for-each select="/root/nodes/node[child-nodes]">
<xsl:variable name="node-num">
<xsl:value-of select="node-num"/>
</xsl:variable>
<xsl:for-each select="./child-nodes/child-node-num">
<xsl:variable name="child-node-num">
<xsl:value-of select="."/>
</xsl:variable>
<xsl:apply-templates select="<!--This is servercall-->">
<!-- </xsl:for-each>
</xsl:for-each>
</xsl:template>
<xsl:template match="Bchild-node1">
<xsl:value-of select="sum(Bchild-node-value)"/>
</xsl:template>
Hope this is clear. Please let me know if there is any solution.
Thank you for all your help.
Meena
On 8/22/05, Mukul Gandhi <gandhi.mukul@xxxxxxxxx> wrote:
> Please try
>
> <xsl:template match="/node1">
> <xsl:value-of select="sum(childnode1a/childnode11a/value)" />
> </xsl:template>
>
> Regards,
> Mukul
>
> On 8/22/05, Meena Nanjundeswar <meenasargur@xxxxxxxxx> wrote:
> > Hi:
> >
> > My xml file looks like this:
> >
> > <node1>
> > <childnode1a>
> > <childnode11a>
> > <value></value>
> > </childnode11a>
> > </childnode1a>
> > </node1>
> >
> > There can be any number of <childnode11a> elements containing <value>.
> > Now, I am trying to compute the sum(value). Instead of giving me a
> > total sum of all the rows, it display the values individually. I
> > believe we have to use recursion. Can anyone please help me with this
> > problem?
> >
> > Thanks
>
>
--
NorthWest Airlines
Office: 612-726-0793
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] Problem with Sum function, Mukul Gandhi | Thread | Re: [xsl] Problem with Sum function, Jon Gorman |
| RE: [xsl] MS IXSLProcessor input en, Gabriel K | Date | Re: [xsl] Problem with Sum function, Jon Gorman |
| Month |