Со следующего XML:Как определить порядок столбцов таблицы в xslt?
<?xml version="1.0"?>
<lieferungen>
<artikel id="3526">
<name>apfel</name>
<preis stueckpreis="true">8.97</preis>
<lieferant>Fa. Krause</lieferant>
</artikel>
<artikel id="7866">
<name>Kirschen</name>
<preis stueckpreis="false">10.45</preis>
<lieferant>Fa. Helbig</lieferant>
</artikel>
<artikel id="3526">
<name>apfel</name>
<preis stueckpreis="true">12.67</preis>
<lieferant>Fa. Liebig</lieferant>
</artikel>
<artikel id="7789">
<name>Ananas</name>
<preis stueckpreis="true">8.60</preis>
<lieferant>Fa. Richard</lieferant>
</artikel>
</lieferungen>
Я хочу, чтобы создать таблицу, которая выглядит следующим образом:
С этой целью я написал следующее XSLT:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs"
version="2.0">
<xsl:template match="lieferungen">
<html>
<head>
<title>
<xsl:text>Lieferungen</xsl:text>
</title>
</head>
<body bgcolor="#ffffff">
<h1>
Lieferungen (Deliveries)
</h1>
<hr/>
<table border="1">
<tr>
<th>Nummer</th>
<th>Article</th>
<th>Price</th>
<th>Supplier</th>
</tr>
<xsl:apply-templates/>
</table>
</body>
<hr/>
<p>
</p>
</html>
</xsl:template>
<xsl:template match="artikel">
<tr>
<td>
<xsl:value-of select="@id"/>
</td>
<xsl:apply-templates/>
</tr>
</xsl:template>
<xsl:template match="name">
<td>
<xsl:value-of select="."/>
</td>
</xsl:template>
<xsl:template match="preis">
<td>
<xsl:value-of select="."/>
</td>
</xsl:template>
<xsl:template match="lieferant">
<td>
<xsl:value-of select="."/>
</td>
</xsl:template>
</xsl:stylesheet>
Код работал нормально, и я получил свою таблицу ... однако теперь я хочу переключать столбцы, в частности, я хочу переключать столбцы 3 д 4. С этой целью, я просто изменить порядок шаблона для «Preis» и «lieferant», т.е. новый порядок теперь:
<xsl:template match="lieferant">
<td>
<xsl:value-of select="."/>
</td>
</xsl:template>
<xsl:template match="preis">
<td>
<xsl:value-of select="."/>
</td>
</xsl:template>
Остальная часть кода является то же самое. Такой подход не сработал, и порядок столбцов в таблице остался прежним.
Мой вопрос таким образом: Как я могу сделать использование компьютера
<xsl:template match="lieferant">
в третьей и
<xsl:template match="preis">
для четвертой колонке таблицы?