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

Re: xsl Date Sorting referencing ID and data ina diffe

Subject: Re: xsl Date Sorting referencing ID and data ina differentNode
From: "KUMAR NINGASHETTY" <kningashetty@xxxxxxxxxxxxxxxx>
Date: Thu, 09 May 2002 09:12:15 -0400
data ina
Joerg ...
    Sorry , it was my mistake ... It sorts perfectly ..The Closedate within each region is sorting perfectly ...
  I didnt realize i had Region4 and Region2 in source XML and it is supposed to behave this way ...Its my mistake
  that i didnt notice properly ..Sorry if i had wasted your time in looking at it again ...
   My example  html is not valid coz it was just a simple example to see the sorting work .
  However there is 1 issue ...For some reason when i stick this solution in my huge original XSL which is a fullfledged  reports
  with all html structure in it ...it somehow doesnt work ..I am thinking its becoz i am using a separate template where i extract the data..
  well, i am in the process of figuring it out ...

  I will follow your suggestions to not use "//"  .
  Thanks for your time again ..

- kumar

>>> joerg.heinicke@xxxxxx 05/08/02 07:24PM >>>
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="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">

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.

> 	  <tr>
> 	     <xsl:value-of select="region_name"/>
> 	  </tr>
> 	  <xsl:for-each select="key('distinct-region', region_name)">
> 	     <xsl:sort select="key('app-refs',@id)/closedate" order="ascending"/>
> 
> 	   <table>
> 		<tr>
> 		<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>
> 	   </table>
>           </xsl:for-each>
> 	</xsl:for-each>
> </xsl:template>

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

Regards,

Joerg


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list 



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.