Hi im new to XSL and im trying to output a table that shows the customer ID and the number of cars purchased, of customers that have purchased more than 1 car based on my XML file. An example output would be:
Customer
3
4
Number of Cars
3
2
但现在的情况是:
Customer
3
3
3
4
4
9
Number of Cars
null
null
null
null
null
null
这里是我的XML档案。
<cars>
<car>
<carID>
3
</carID>
<mobileNumber>
<areaCode>
00353
</areaCode>
<number>
8723059
</number>
</mobileNumber>
<customerID>
3
</customerID>
<purchaseDate>
<dayPurchased>
6
</dayPurchased>
<monthPurchased>
April
</monthPurchased>
<yearPurchased>
2011
</yearPurchased>
</purchaseDate>
</car>
<car>
<carID>
4
</carID>
<mobileNumber>
<areaCode>
00353
</areaCode>
<number>
8723099
</number>
</mobileNumber>
<customerID>
3
</customerID>
<purchaseDate>
<dayPurchased>
6
</dayPurchased>
<monthPurchased>
April
</monthPurchased>
<yearPurchased>
2011
</yearPurchased>
</purchaseDate>
</car>
<car>
<carID>
5
</carID>
<mobileNumber>
<areaCode>
00353
</areaCode>
<number>
8723777
</number>
</mobileNumber>
<customerID>
3
</customerID>
<purchaseDate>
<dayPurchased>
6
</dayPurchased>
<monthPurchased>
April
</monthPurchased>
<yearPurchased>
2011
</yearPurchased>
</purchaseDate>
</car>
<car>
<carID>
16
</carID>
<mobileNumber>
<areaCode>
00353
</areaCode>
<number>
8721777
</number>
</mobileNumber>
<customerID>
4
</customerID>
<purchaseDate>
<dayPurchased>
6
</dayPurchased>
<monthPurchased>
April
</monthPurchased>
<yearPurchased>
2011
</yearPurchased>
</purchaseDate>
</car>
<car>
<carID>
166
</carID>
<mobileNumber>
<areaCode>
00353
</areaCode>
<number>
8722777
</number>
</mobileNumber>
<customerID>
4
</customerID>
<purchaseDate>
<dayPurchased>
6
</dayPurchased>
<monthPurchased>
April
</monthPurchased>
<yearPurchased>
2011
</yearPurchased>
</purchaseDate>
</car>
<car>
<carID>
169
</carID>
<mobileNumber>
<areaCode>
00353
</areaCode>
<number>
8721787
</number>
</mobileNumber>
<customerID>
9
</customerID>
<purchaseDate>
<dayPurchased>
6
</dayPurchased>
<monthPurchased>
April
</monthPurchased>
<yearPurchased>
2011
</yearPurchased>
</purchaseDate>
</car>
</cars>
这里是我的SL档案。
<?xml version="1.0"?>
<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html> <head><title>Customers</title></head> <body> <table rules="all">
<thead><tr><th>Customer</th><th>Number of Cars Purchased</th></tr></thead>
<xsl:for-each select="cars/car">
<tr><td> <xsl:apply-templates select="customerID"/> </td>
</xsl:for-each>
</table></body></html>
</xsl:template>
</xsl:transform>
提前感谢。