让我的头脑卡在一些简单的 XSL 函数上。我需要从这个 XML 返回每个产品的总销售额和平均销售额以及每天的总销售额。
<products>
<product>
<id>1</id>
<brand>Samsung</brand>
<model>Galaxy</model>
<serialno>00345234</serialno>
<sales>
<sale day="20130211">1200</sale>
<sale day="20130212">9000</sale>
<sale day="20130213">5400</sale>
</sales>
</product>
<product>
<id>2</id>
<brand>Sony</brand>
<model>Bravia</model>
<serialno>07432200</serialno>
<sales>
<sale day="20130211">3400</sale>
<sale day="20130212">990</sale>
<sale day="20130213">1400</sale>
</sale>
</product>
</products>
输出
Total sales per day: 21390
Total (S/N 00345234): 15600
Average (S/N 00345234): 5200
Total (S/N 07432200): 5790
Average (S/N 07432200): 1930
Total sales for day 20130212 = 9990
Total sales for day 20130213 = 6800
Total sales for day 20130211 = 4600