1
好像我无法理解的时刻,所以我需要寻求帮助的Munechian分组..总和组XSLT“Munechian分组”
我试着去总结我的人1型要素的价格。
我的XML文件看起来像这样。
<autoads>
<ad>
<type>1</type>
<name>Honda</name>
<model>XL 1000 V</model>
<regyear>2001</regyear>
<price>129900</price>
<addate>20020115</addate>
<volume>1000</volume>
<category></category>
</ad>
<ad>
<type>2</type>
<name>Nissan</name>
<model>Almera 1.4S</model>
<regyear>1997</regyear>
<price>119000</price>
<addate>20020118</addate>
<volume>0</volume>
<category>5 dörrar</category>
</ad>
....
</autoads>
所以我需要的是人组的1型和总结的价格为他们的人:
这是伊夫在我的XSL文件迄今所做
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>Fordon</h2>
<table border="1">
<tr bgcolor="#ccc">
<th>Namn</th>
<th>Modell</th>
<th>Beskrivning</th>
<th>Typ</th>
</tr>
<xsl:for-each select="//ad[type != '1']" >
<xsl:sort select="type" order="descending" />
<xsl:sort select="name"/>
<xsl:sort select="model"/>
<tr>
<td><xsl:value-of select="name" /></td>
<td><xsl:value-of select="model" /></td>
<td><xsl:value-of select="adtext" /></td>
<td><xsl:value-of select="type" /></td>
</tr>
</xsl:for-each>
</table>
<p>Summan av fordon är <xsl:value-of select="sum(//price)" /> SEK</p>
Antal bilar är <xsl:value-of select="count(/*/*/type[. = 2])"/><br />
</body>
</html>
</xsl:template>
</xsl:stylesheet>
我的问题是,我真的不知道在哪里放行,所以他们不会打扰我的代码的其余部分。
感谢
我只是解决了我的问题,这只是字符串 的 但是我仍然没有得到分组:) –
Dymond
2011-12-20 23:27:55
不知道为什么你需要分组任何东西。 – 2011-12-21 04:06:29