[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Trouble sorting with <xsl:sort>

Subject: Trouble sorting with <xsl:sort>
From: "søren jepsen" <demon3d2@xxxxxxxxxxx>
Date: Thu, 15 Jun 2006 08:26:57 +0000
fioniaportalen
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/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/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"/>&amp;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">Redgiver: Sxren Jepsen0</advisor>
					<advisor id="t178510">Redgiver: Sxren Jepsen1</advisor>
					<advisor id="t178511">Redgiver: Sxren Jepsen2</advisor>
			</department>
			<department title="Kirkeby" id="2">
					<advisor id="t178512">Redgiver: Sxren Jepsen3</advisor>
					<advisor id="t178513">Redgiver: Sxren Jepsen4</advisor>
					<advisor id="t178514">Redgiver: Sxren 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">
Erlig 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">
Erlig 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">
Erlig afd. 06 <!-- Event -->
</item>
<item field="Status">
Mxde <!--Status -->
</item>
<item field="Emne">
Mulighed <!--Emne -->
</item>
<item>
Pension, e-boks<!--Fritekst -->
</item>
</elements>
</row>
</data>
</selectcustomers>
</talefod>


_________________________________________________________________
Ta' pe udsalg eret rundt pe MSN Shopping: http://shopping.msn.dk - her finder du altid de bedste priser


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.