gpt4 book ai didi

xml - xslt 中文化特定值的总和

转载 作者:数据小太阳 更新时间:2023-10-29 02:37:54 25 4
gpt4 key购买 nike

我有一个像

这样的xml
<MainNode>
<Data SubjectID="19233">
<SubNode CS="100,1" >
<AB V="PSDF"/>
</SubNode>
</Data>
<Data SubjectID="19234">
<SubNode CS="111,1">
<AB V="PSDF" />
</SubNode>
</Data>
</MainNode>

当我尝试对属性“@CS”的值求和时,我得到的结果是“NaN”。谁能帮我解决这个问题。

提前致谢普拉迪普

最佳答案

我认为这太复杂了,但您可以尝试:

<xsl:template name="sum_helper">
<xsl:param name="current" select="0" />
<xsl:param name="rest" />
<xsl:choose>
<xsl:when test="count($rest) &gt; 0">
<xsl:call-template name="sum_helper">
<xsl:with-param name="current"
select="$current + translate($rest[1],',','.')" />
<xsl:with-param name="rest" select="$rest[position()&gt;1]" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$current" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>

...
<xsl:call-template name="sum_helper">
<xsl:with-param name="rest" select="//SubNode/@CS" />
</xsl:call-template>
...

关于xml - xslt 中文化特定值的总和,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3278656/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com