基于第二个节点的XML节点和
我正在尝试使用匹配类型添加每个用户的总金额。XML示例:基于第二个节点的XML节点和,xml,xslt,Xml,Xslt,我正在尝试使用匹配类型添加每个用户的总金额。XML示例: <Report_Data> <Report_Entry> <Name>Mark</Name> <Pay> <Type>1</Type> <Amount>3013</Amount> </Pay> <
<Report_Data>
<Report_Entry>
<Name>Mark</Name>
<Pay>
<Type>1</Type>
<Amount>3013</Amount>
</Pay>
<Pay>
<Type>1</Type>
<Amount>3013</Amount>
</Pay>
<Pay>
<Type>2</Type>
<Amount>26</Amount>
</Pay>
<Report_Entry>
<Report_Entry>
<Name>Luke</Name>
<Pay>
<Type>1</Type>
<Amount>2600</Amount>
</Pay>
<Pay>
<Type>1</Type>
<Amount>3500</Amount>
</Pay>
<Pay>
<Type>3</Type>
<Amount>1600</Amount>
</Pay>
<Report_Entry>
<Report_Data>
做记号
1.
3013
1.
3013
2.
26
卢克
1.
2600
1.
3500
3.
1600
XSL 2.0
输出应该类似于Name/Type/Amount
马克16026
马克20026
Luke16100
卢克311600
我的格式很好,但是,循环只输出第一种类型
谢谢:)
编辑:这是XSLT代码段。这是300万行xml和600行xslt的一部分。我故意淡化它,因为我只是错过了(正确的)循环
4.
正确的
1.
正确的
4.
正确的
0
如果您使用
<xsl:template match="Report_Entry">
<xsl:for-each-group select="Pay" group-by="Type">
<xsl:value-of select="../Name, current-grouping-key(), sum(current-group()/Amount)"/>
<xsl:text> </xsl:text>
</xsl:for-each-group>
</xsl:template>
而不是
<xsl:with-param name="stringValue">
<xsl:value-of select="$Money/Value"/>
</xsl:with-param>
Hm。。。这在我的“淡化”版本中有效,但在实际数据中,我得到了一个XPTY0004:Required项类型的string-length()的第一个参数是xs:string;提供的值的项类型为xs:double error。如果变量名
stringValue
指示参数的类型必须为xs:string
,则您不会使用string length
函数向我们显示任何代码,您可以尝试
。
<xsl:for-each-group select="//Pay" group-by="wd:Type">
<xsl:for-each-group select="Pay" group-by="wd:Type">
<xsl:for-each-group select=".//Pay" group-by="wd:Type">
<xsl:with-param name="stringValue" select="sum(current-group()/Value)"/>
<xsl:with-param name="stringValue">
<xsl:value-of select="$Money/Value"/>
</xsl:with-param>