Subject: Re: [xsl] Trouble sorting with <xsl:sort> From: "Jagdishwar B" <jagdishwar.beemanati@xxxxxxxxx> Date: Thu, 15 Jun 2006 15:18:58 +0200 |
you seem to use the sort element at wrong place. i think you have to sort the entire rows, and not just the elements within a specific row.
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/sty le/style.css"/>
cellpadding="0" border="0"<title>Talefod projekt</title> </head> <body> <table width="100%" cellspacing="1"
select="talefod/fioniabank"/>style="padding:3px"> <xsl:apply-templates
name="href">?departmentId=<xsl:value-of</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="colspan">select="@id"/></xsl:attribute> <tr class="tr_top"> <td class="tblColumnHd"> <xsl:attribute
<xsl:value-ofselect="10"/>
select="@title"/></xsl:attribute> <xsl:value-of
</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"/> replace the above statement by following: --> <xsl:apply-templates select="//selectcustomers/data/row"> <xsl:sort select="elements/item[@field=$sortby]" order="ascending"/> </xsl:apply-templates>
</xsl:if>class="tblColumnHd"><xsl:value-of select="@title"/></td>
<tr> <td height="10"/> </tr> </xsl:template>
<xsl:template match="headers"> <tr class="tr_top"> <xsl:for-each select="item"> <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"/> <!-- no need of sorting here, as your row contains only one element-->
/></td><xsl:for-each select="item"> <td><xsl:value-of select="."
</xsl:for-each> </xsl:for-each> </tr> </xsl:template>
</xsl:stylesheet>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Trouble sorting with <xsl, søren jepsen | Thread | [xsl] table value, Andrew Neiderer |
[xsl] RE : [xsl] selecting the ENTI, Florent Georges | Date | [xsl] xsl select, Esteban Paz |
Month |