<xsl:sort select="item[field=$sortby]" order="ascending"/>
I think that should be
<xsl:sort select="item[(_at_)field=$sortby]" order="ascending"/>
(If you used schema-aware processing, such errors would be spotted by the
compiler)
Michael Kay
http://www.saxonica.com/
-----Original Message-----
From: søren jepsen [mailto:demon3d2(_at_)hotmail(_dot_)com]
Sent: 15 June 2006 09:27
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Trouble sorting with <xsl:sort>
Hi People!
I'm having trouble making xsl:sort element working on some xml data.
Nomatter what i try i can't get the sort function to work.
The sort parameter is based on <xsl:param name="sortby"
select=3D3D"'Kundenavn'"/> (Defined in the start of the xsl)
Any ideas ?
My XSL:
Look at <xsl:template match="row">...
<?xml version="1.0" encoding="iso-8859-1"?> <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="no"/>
<xsl:strip-space elements="*"/>
<xsl:param name="sortby" select="'Kundenavn'"/>
<xsl:param name="advisorId" select="'t178509'"/>
<xsl:param name="departmentId" select="1"/>
<xsl:template match="/">
<html>
<head>
<link rel="stylesheet"
href="http://fioniaportalen/package/fioniabank/medarbejderport
al/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/fioniabank"/>
</table>
</body>
</html>
</xsl:template>
<xsl:template match="fioniabank">
<xsl:apply-templates select="departments"/>
</xsl:template>
<xsl:template match="departments">
<xsl:for-each select="department">
<a>
<xsl:attribute
name="href">?departmentId=<xsl:value-of
select="@id"/></xsl:attribute>
<tr class="tr_top">
<td class="tblColumnHd">
<xsl:attribute
name="colspan">
<xsl:value-of select="10"/>
</xsl:attribute>
<xsl:value-of
select="@title"/>
</td>
</tr>
</a>
<xsl:if test="@id = $departmentId">
<xsl:apply-templates select="advisor"/>
</xsl:if>
<tr>
<td height="10">
</td>
</tr>
</xsl:for-each>
</xsl:template>
<xsl:template match="advisor">
<a>
<xsl:attribute
name="href">?advisorId=<xsl:value-of
select="@id"/>&departmentId=<xsl:value-of
select="../@id"/></xsl:attribute>
<tr class="tr_top">
<td class="tblColumnHd">
<xsl:attribute name="colspan">
<xsl:value-of
select="10"/>
</xsl:attribute>
<xsl:value-of select="."/>
</td>
</tr>
</a>
<xsl:if test="@id = $advisorId">
<xsl:apply-templates
select="//selectcustomers/headers"/>
<xsl:apply-templates
select="//selectcustomers/data/row"/>
</xsl:if>
<tr>
<td height="10"/>
</tr>
</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">
<tr class="evenrowno">
<xsl:for-each select="elements">
<xsl:sort
select="item[field=$sortby]" order="ascending"/>
<xsl:for-each select="item">
<td><xsl:value-of
select="." /></td>
</xsl:for-each>
</xsl:for-each>
</tr>
</xsl:template>
</xsl:stylesheet>
My XML:
<?xml version="1.0" encoding="utf-8"?>
<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>
<departments>
<department title="OdenseCity" id="1">
<advisor
id="t178509">Rådgiver: Søren Jepsen0</advisor>
<advisor
id="t178510">Rådgiver: Søren Jepsen1</advisor>
<advisor
id="t178511">Rådgiver: Søren Jepsen2</advisor>
</department>
<department title="Kirkeby" id="2">
<advisor
id="t178512">Rådgiver: Søren Jepsen3</advisor>
<advisor
id="t178513">Rådgiver: Søren Jepsen4</advisor>
<advisor
id="t178514">Rådgiver: Søren Jepsen5</advisor>
</department>
</departments>
</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" sortable="false"/>
</headers>
<data> <!-- customer data based on 'ridgiverId' -->
<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>
<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">
Viggo Mortensen
<!-- Kundenavn -->
</item>
<item field="Event">
Årlig afd. 06
<!-- Event -->
</item>
<item field="Status">
Møde <!--Status -->
</item>
<item field="Emne">
Mulighed <!--Emne -->
</item>
<item>
Pension,
e-boks<!--Fritekst -->
</item>
</elements>
</row>
</data>
</selectcustomers>
</talefod>
_________________________________________________________________
Ta' på udsalg året rundt på MSN Shopping:
http://shopping.msn.dk - her finder du altid de bedste priser
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--