我需要按日期对以下交易进行分组,并计算每个日期的所有交易的总和和数量。
输入:
<transactions>
<transaction id="1">
<element key="2" name="Amount">3.00</element>
<element key="3" name="Date">01.01.2010</element>
</transaction>
<transaction id="2">
<element key="2" name="Amount">4.00</element>
<element key="3" name="Date">01.01.2010</element>
</transaction>
<transaction id="3">
<element key="2" name="Amount">5.00</element>
<element key="3" name="Date">01.01.2011</element>
</transaction>
<transaction id="4">
<element key="2" name="Amount">6.00</element>
<element key="3" name="Date">01.01.2011</element>
</transaction>
期望的输出:
<transactions>
<date value="01.01.2010">
<sum>7.00</sum>
<numberOfTrans>2</numberOfTrans>
<transaction id="1">
<element key="2" name="Amount">3.00</element>
</transaction>
<transaction id="2">
<element key="2" name="Amount">4.00</element>
</transaction>
</date>
<date value="01.01.2011">
<sum>11.00</sum>
<numberOfTrans>2</numberOfTrans>
<transaction id="3">
<element key="2" name="Amount">5.00</element>
</transaction>
<transaction id="4">
<element key="2" name="Amount">6.00</element>
</transaction>
</date>
如何使用 XSLT 1.0 做到这一点?
谢谢!