0

给出以下 xml 文档

<root>
  <row>
   <field1/>
   <tax1>10,00</tax1>  
   <tax3>100,00</tax3>  
   <tax2>150,00</tax2>  
   <tax4>50,0</tax4>  
   <field2/>
  </row>
</root>

我需要选择所有税收字段(tax1、tax2、tax3、tax4 并翻译“,”->“。”并将它们相加。这可以在 xpath 1.0 中完成吗?

4

1 回答 1

1

Dimitre Novatchev 在这里为此类问题提供了完整的答案:https://stackoverflow.com/questions/647991/summing-numbers-with-comma-as-decimal-separator-in-xslt.

简而言之,有很多可能的解决方案:

  1. XSLT/XPath 1.0 +EXSLT
  2. FXSL 2.0(特别是transform-and-sum()转型)
  3. XSLT/XPath 2.0

根据您的评论,看起来#1 和#2 会很有趣。

于 2013-04-08T14:33:43.797 回答