xsl中的和值 [英] sum values in xsl

查看:108
本文介绍了xsl中的和值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好, 我有一个xml,其中有一个我需要求和的字段,问题是当使用时:


< xsl:value-of select =" sum(// activity [包含(赞助商/赞助商/赞助商名称,'ITALY MAE')] /赞助商/赞助商/金额)" />总和不完整。


我试图对这些值求和,但我不能将它们相加


     < xsl:variable name =" totalItalyMae" />
$
    &NBSP; < xsl:for-each select =" //赞助商/赞助商"> 


    &NBSP;&NBSP;&NBSP; &NBSP;&NBSP;&NBSP;  < xsl:if test =" contains(sponsor-name,'ITALY MAE')"> b
    &NBSP;&NBSP;&NBSP; &NBSP;&NBSP;&NBSP;&NBSP; &NBSP;&NBSP;&NBSP; < xsl:variable name =" PartialItalyMae" select =" amount" />
$
    &NBSP;&NBSP;&NBSP; &NBSP;&NBSP;&NBSP; &NBSP;< / XSL:如果>&NBSP;&NBSP;&NBSP; &NBSP;&NBSP;&NBSP; &NBSP;&NBSP;&NBSP; &NBSP;&NBSP;&NBSP;&NBSP; &NBSP;&NBSP;&NBSP; &NBSP;&NBSP;&NBSP; &NBSP;&NBSP;&NBSP;&NBSP; &NBSP;&NBSP;&NBSP; &NBSP;&NBSP;&NBSP;


    &NBSP;&NBSP;&NBSP; < / xsl:for-each>


使用此循环我可以得到正确的值,但我无法求和它们,因为当我添加值时,totalItalyMae不会改变。


有没有办法对这些值求和。


谢谢。

解决方案

< blockquote>请发布最小但完整的样本,以便我们理解并重现问题。我们至少需要查看您正在尝试处理的XML输入,并清楚地口头描述您想要采用的总和。 如果您的
代码无法按预期工作,那么请向我们展示代码并告诉我们您获得的结果以及您想要的结果。我担心"总和不完整"。没有告诉我们您想要的结果以及您得到的结果。


Hi,  i have an xml where i there is a field that i have to sum, the problem is that when using:

<xsl:value-of select="sum(//activity[contains(sponsors/sponsor/sponsor-name,'ITALY MAE')]  /sponsors/sponsor/amount)" /> the sum is not complete.

I tried to sum the values but i can't sum them

     <xsl:variable name="totalItalyMae" />
      <xsl:for-each select="//sponsors/sponsor"> 
             <xsl:if test="contains(sponsor-name,'ITALY MAE')">
                 <xsl:variable name="PartialItalyMae" select= "amount" />
             </xsl:if>                                     
        </xsl:for-each>

with this cycle i can get the right values but i can't sum them because totalItalyMae doesn't change when i add values.

Is there any way to sum this values.

Thank you.

解决方案

Please post minimal but complete samples allowing us to understand and reproduce the problem. We at least need to see the XML input you are trying to process and a clear verbal description of which elements you want to take the sum of.  And if you have code that is not working as expected then show us the code and tell us exactly which result you get and which result you want. I am afraid "sum is not complete" does not tell us which result you want and which result you get.


这篇关于xsl中的和值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆