-1
我是XSLT新手,我想將我的XML數據轉換爲HTML表格,然後在preis字段上對錶格進行排序:這是我的代碼,但它不起作用。請你告訴我是什麼問題在我的代碼:在XSLT中排序?
<xsl:stylesheet>
<xsl:template match="/">
<html>
<body>
<h1>
Hallo
</h1>
<table border="1">
<xsl:apply-templates>
<xsl:sort select="preis" data-type="number" order="ascending"/>
</xsl:apply-templates>
</table>
</body>
</html>
</xsl:template>
<xsl:template match="artikel">
<tr>
<xsl:apply-templates select="name" />
<xsl:apply-templates select="lieferant" />
<xsl:apply-templates select="preis"/>
</tr>
</xsl:template>
<xsl:template match="name|lieferant|preis">
<td>
<xsl:value-of select="."/>
</td>
</xsl:template>
</xsl:stylesheet>
和XML文件:
<lieferungen>
<artikel id="3526">
<name>apfel</name>
<lieferant>Fa. Krause</lieferant>
<preis stueckpreis="true">8.97</preis>
</artikel>
<artikel id="7866">
<name>Kirschen</name>
<preis stueckpreis="false">10.45</preis>
<lieferant>Fa. Helbig</lieferant>
</artikel>
<artikel id="3526">
<preis stueckpreis="true">12.67</preis>
<lieferant>Fa. Liebig</lieferant>
<name>apfel</name>
</artikel>
<artikel id="7866">
<preis stueckpreis="false">17.67</preis>
<name>Kirschen</name>
<lieferant>Fa. Krause</lieferant>
</artikel>
<artikel id="3627">
<name>apfel</name>
<lieferant>Fa. Mertes</lieferant>
<preis stueckpreis="true">9.54</preis>
</artikel>
<artikel id="7866">
<name>Kirschen</name>
<lieferant>Fa. Hoeller</lieferant>
<preis stueckpreis="false">16.45</preis>
</artikel>
<artikel id="7868">
<preis>3.20</preis>
<name>Kohl</name>
<lieferant>Fa. Hoeller</lieferant>
</artikel>
<artikel id="7866">
<name>Kirschen</name>
<lieferant>Fa. Richard</lieferant>
<preis stueckpreis="false">12.45</preis>
</artikel>
<artikel id="3245">
<preis stueckpreis="false">15.67</preis>
<name>Bananen</name>
<lieferant>Fa. Hoeller</lieferant>
</artikel>
<artikel id="6745">
<name>Kohl</name>
<lieferant>Fa. Reinhardt</lieferant>
<preis stueckpreis="false">3.10</preis>
</artikel>
<artikel id="7789">
<name>Ananas</name>
<preis stueckpreis="true">8.60</preis>
<lieferant>Fa. Richard</lieferant>
</artikel>
</lieferungen>
沒有輸入XML,所需的輸出和實際輸出的一個樣本,我們如何應該知道「不起作用」是什麼意思? – Oded 2012-02-09 10:07:49
我的意思是價格(數量)應該是排序accesnding或descendind – Baper 2012-02-09 10:15:01
現在你正在使事情更混亂。你需要上升還是下降?再說一遍,如果不明白「不行」意味着什麼,我們就無法提供幫助。 – Oded 2012-02-09 10:16:12