Problemer med at sortere data fra xml via <xsl:sort>
Jeg forsøger at sortere en række data i <row><elements><item>..Men jeg kan ikke helt regne ud, hvorfor sorteringen ikke fungerer :/
Hvad er der galt med følgende eksempel:
XML:
<talefod>
<!-- All intern Fionia Bank data is located in <fioniabank>-tags -->
<fioniabank>
<details title="???"> <!-- no title="xxx" means no header -->
<detailitems>
<item type="text" title="Intern kreditkode:">
123412345
</item>
<item type="text" title="RKI kode:">
1234512345
</item>
</detailitems>
</details>
</fioniabank>
<!-- end -->
<selectcustomers>
<headers>
<item title="Dato"/>
<item title="CPR"/>
<item title="Kundenavn"/>
<item title="Event"/>
<item title="Status"/>
<item title="Emne"/>
<item title="Fritekst"/>
</headers>
<advisors>
<advisor title="Rådgiver: Søren Jepsen">
<row>
<elements>
<item field="Dato"> <!-- when type="xxxx" is not defined we default to using type="text" -->
01.05.06 <!-- Dato -->
</item>
<item field="CPR">
XXXXXX-XXXX <!-- CPR -->
</item>
<item field="Kundenavn">
Anna Jakob Jensen <!-- Kundenavn -->
</item>
<item field="Event">
Årlig afd. 06 <!-- Event -->
</item>
<item field="Status">
Kontakt <!--Status -->
</item>
<item field="Emne">
R-Utilfreds <!--Emne -->
</item>
<item>
<!--Fritekst -->
</item>
</elements>
</row>
<row>
<elements>
<item field="Dato"> <!-- when type="xxxx" is not defined we default to using type="text" -->
01.05.06 <!-- Dato -->
</item>
<item field="CPR">
XXXXXX-XXXX <!-- CPR -->
</item>
<item field="Kundenavn">
Pernille Thorling <!-- Kundenavn -->
</item>
<item field="Event">
Årlig afd. 06 <!-- Event -->
</item>
<item field="Status">
E-mail <!--Status -->
</item>
<item field="Emne">
B-Utilfreds <!--Emne -->
</item>
<item>
<!--Fritekst -->
</item>
</elements>
</row>
<row>
<elements>
</row>
</advisor>
</advisors>
</selectcustomers>
</talefod>
XSL:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" omit-xml-declaration="yes" version="1.0" encoding="iso-8859-1" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:param name="sortby" select="."/>
<xsl:template match="/">
<html>
<head>
<link rel="stylesheet" href="http://fioniaportalen/package/fioniabank/medarbejderportal/external/style/style.css"/>
<title>Talefod projekt</title>
</head>
<body>
<table width="100%" cellspacing="1" cellpadding="0" border="0" style="padding:3px">
<xsl:apply-templates select="talefod/selectcustomers"/>
</table>
</body>
</html>
</xsl:template>
<xsl:template match="selectcustomers">
<xsl:apply-templates select="advisors"/>
</xsl:template>
<xsl:template match="advisors">
<xsl:for-each select="advisor">
<tr class="tr_top">
<td class="tblColumnHd">
<xsl:attribute name="colspan">
<xsl:value-of select="count(../../headers/item)"/>
</xsl:attribute>
<xsl:value-of select="@title"/>
<xsl:value-of select="position()"/>
</td>
</tr>
<xsl:apply-templates select="../../headers"/>
<xsl:apply-templates select="row"/>
<tr>
<td>
<br/>
</td>
</tr>
</xsl:for-each>
</xsl:template>
<xsl:template match="headers">
<tr class="tr_top">
<xsl:for-each select="item">
<td class="tblColumnHd">
<xsl:value-of select="@title"/>
</td>
</xsl:for-each>
</tr>
</xsl:template>
<xsl:template match="row">
<xsl:variable name="xxx" select="'Emne'"/>
<tr class="evenrowno">
<xsl:for-each select="elements">
<xsl:sort select="item[field=$xxx]" order="ascending"/>
<xsl:for-each select="item">
<td>
<xsl:value-of select="." />
</td>
</xsl:for-each>
</xsl:for-each>
</tr>
</xsl:template>
</xsl:stylesheet>