xslt 2.0 sum()与浮点值的工作方式不正确

时间:2015-10-22 18:15:39

标签: xml excel sum xslt-2.0 obiee

我有一个源xml,如:

 <group>
           <group_type_id>1</group_type_id>
           <measure1>4324.44352</measure1>
           <measure2>0</measure2>
           <measure3>55.3</measure3>
         </group>
         <group>
           <group_type_id>1</group_type_id>
           <measure1>535.777</measure1>
           <measure2>0.509</measure2>
           <measure3>707</measure3>
         </group>
         <group>
           <group_type_id>2</group_type_id>
           <measure1>3345.6</measure1>
           <measure2>0.1301</measure2>
           <measure3>1000.03</measure3>
         </group>
         <group>
           <group_type_id>2</group_type_id>
           <measure1>3478.1</measure1>
           <measure2>654.754634</measure2>
           <measure3>890</measure3>
         </group>

我想将它转换为excel可读的.x​​ml,总和为measure1,2,3。我尝试使用这个xslt代码:

<xsl:for-each-group select="group" group-by="group_type_id">
<Row>
<Cell ss:Style="someStyle">
<Data ss:Type="Number">
 <xsl:value-of select="sum(current-group()/measure1)" />  
</Data>
</Cell>
<Cell ss:Style="someStyle">
<Data ss:Type="Number">
 <xsl:value-of select="sum(current-group()/measure2)" />  
</Data>
</Cell>
<Cell ss:Style="someStyle">
<Data ss:Type="Number">
 <xsl:value-of select="sum(current-group()/measure3)" />  
</Data>
</Cell>
</Row>
</xsl:for-each-group> 

但是在结果中我接受了我的单元格值,丢失了数字分数。对于group_type_id = 1中的度量1的总和,它必须 是4324.44352 + 535.777 = 4860.22052。但我得到的东西像4860220520000000。 我尝试过不同的功能,如:

sum(current-group()/measure1/text())
sum(number(current-group()/measure1/text()))
sum(number-format(current-group()/measure1/text()),'####.####')

e.t.c。 但这一切都给了我相同的结果。 我做错了什么?

0 个答案:

没有答案