Re: [xsl] xsl Date Sorting referencing ID and data in a differentNode

Subject: Re: [xsl] xsl Date Sorting referencing ID and data in a differentNode
From: Joerg Heinicke <joerg.heinicke@xxxxxx>
Date: Thu, 09 May 2002 01:24:23 +0200
Hello Kumar,

the stylesheet works exactly as I expected it. I read your first mail and thought you want to sort all applications of one region by closedate. This works. But what do YOU want to sort the stylesheet by? Maybe the regions itself too? Then a <xsl:sort select="region_name"/> at the first <xsl:for-each> does what you want. Otherwise tell it me.

I want to add a few comments to your stylesheet:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl=""; xmlns:fo="";>

You don't need the XSL FO namespace, you can remove it.

   <xsl:key name="distinct-region" match="//company/application" use="region_name"/>
   <xsl:key name="app-refs" match="//stages/application" use="@idref"/>

<xsl:key> searches the whole file for the match patterns, the '//' can be removed too.

   <xsl:template match="/">
     <xsl:for-each select="//rep/company/application[generate-id()=generate-id(key('distinct-region', region_name))]">

Again you should remove '//' here. The rep is the root element of your tree, so it must not be searched in the whole file at any level depth. This costs only processing time, because *all* elements will be searched, which match on this expression.

Furthermore if you want to sort the applications by their region_names add <xsl:sort select="region_name"/> here.

	     <xsl:value-of select="region_name"/>
	  <xsl:for-each select="key('distinct-region', region_name)">
	     <xsl:sort select="key('app-refs',@id)/closedate" order="ascending"/>

<td><xsl:value-of select="./@id"/> ~</td>
<td><xsl:value-of select="ssn"/> ~</td>
<td><xsl:value-of select="key('app-refs',@id)/closedate"/></td> </tr>

You are creating "a bit invalid" HTML table. Or is this in other parts of the stylesheet?



XSL-List info and archive:

Current Thread