我需要一种方法来计算每个客户的发票总数,(添加三张发票,然后相应地显示总数),尝试过 sum(/*/(PriceUnit*Ordered)),但它不起作用,.---[一张发票的总和=PriceUnit*Ordered],.so总结三张发票然后显示结果,.这对我来说很难所以请帮忙
样本输入文件
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="Nom.xslt"?>
<customers>
<customer>
<clientname>troy madison</clientname>
<invoices>
<invoiceDate>8/8/98</invoiceDate>
<product>
<PriceUnit>1000</PriceUnit>
<Ordered>2</Ordered>
</product>
<product>
<PriceUnit>5400</PriceUnit>
<Ordered>3</Ordered>
</product>
</invoices>
<invoices>
<invoiceDate>1/4/98</invoiceDate>
<product>
<PriceUnit>300</PriceUnit>
<Ordered>4</Ordered>
</product>
<product>
<PriceUnit>6000</PriceUnit>
<Ordered>1</Ordered>
</product>
</invoices>
<invoices>
<invoiceDate>03/5/99</invoiceDate>
<product>
<PriceUnit>549</PriceUnit>
<Ordered>1</Ordered>
</product>
<product>
<PriceUnit>320</PriceUnit>
<Ordered>2</Ordered>
</product>
</invoices>
</customer>
<customer>
<clientname>Morris</clientname>
<invoices>
<invoiceDate>1/1/00</invoiceDate>
<product>
<PriceUnit>59</PriceUnit>
<Ordered>3</Ordered>
</product>
<product>
<PriceUnit>55</PriceUnit>
<Ordered>1</Ordered>
</product>
</invoices>
<invoices>
<invoiceDate>11/1/01</invoiceDate>
<product>
<PriceUnit>10</PriceUnit>
<Ordered>2</Ordered>
</product>
<product>
<PriceUnit>54</PriceUnit>
<Ordered>1</Ordered>
</product>
</invoices>
<invoices>
<invoiceDate>03/2/01</invoiceDate>
<product>
<PriceUnit>30</PriceUnit>
<Ordered>1</Ordered>
</product>
<product>
<PriceUnit>299</PriceUnit>
<Ordered>1</Ordered>
</product>
</invoices>
</customer>
</customers>
预期产出
[OP 在此处列出预期输出。]
到目前为止我尝试过的样式表
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="customers">
<html>
<head>
<h1>CUSTOMER REFERENCE</h1>
</head>
<body bgcolor="#DAF52C">
<table border="1">
<tr>
<th width="50">NAME</th>
<th width="50">INVOICE DATE</th>
<th width="50">PRODUCT UNIT</th>
<th width="50">ORDERED </th>
<th width="50">PRODUCT UNIT</th>
<th width="50">ORDERED </th>
<th width="50">INVOICE DATE</th>
<th width="50">PRODUCT UNIT</th>
<th width="50">ORDERED </th>
<th width="50">PRODUCT UNIT</th>
<th width="50">ORDERED </th>
<th width="50">INVOICE DATE</th>
<th width="50">PRODUCT UNIT</th>
<th width="50">ORDERED </th>
<th width="50">PRODUCT UNIT</th>
<th width="50">ORDERED </th>
<th width="50">INVOICE TOTAL</th>
</tr>
<xsl:for-each select="customer">
<tr>
<td><xsl:value-of select="clientname"/></td>
<xsl:for-each select="invoices">
<td><xsl:value-of select="invoiceDate"/></td>
<xsl:for-each select="product">
<td><xsl:value-of select="PriceUnit"/></td>
<td><xsl:value-of select="Ordered"/></td>
</xsl:for-each>
</xsl:for-each>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>