This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Hello Kumar,

you can add a further key to easily access the application-elements with 
closedate:

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

With this key it's a bit easier to access the nodes, with which you want 
to sort your application-elements.

And I would change your first key so, that you are directly getting the 
application-element. I think the region_name is more or less 
uninteresting, it's only for grouping.

At the end the stylesheet looks like:

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

<xsl:template match="/">
   <xsl:for-each 
select="rep/company/application[generate-id()=generate-id(key('distinct-region', 
region_name))]">
     <xsl:value-of select="region_name"/>
     <xsl:for-each select="key('distinct-region', region_name)">
         <xsl:sort select="key('app-refs',@id)/closedate"/>
     	<xsl:value-of select="ssn"/>
     	<xsl:value-of select="key('app-refs',@id)/closedate"/>
     	<xsl:value-of select="key('app-refs',@id)/current"/>
     </xsl:for-each>
   </xsl:for-each>
</xsl:template>

Regards,

Joerg

> XSL:
> 
> <?xml version="1.0" encoding="iso-8859-1"?>
> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
> 
> <xsl:key name="distinct-region"  match="rep/company/application/region_name"  use="text()"/>
> <xsl:template match="/">
> <xsl:for-each select="rep/company/application/region_name[generate-id()=generate-id(key('distinct-region', text()))]">
>     <xsl:value-of select="text()"/>
>     
>     
>     <xsl:for-each select="key('distinct-region', text())">
>     
>         <xsl:variable name="appid" select="parent::application/@id"/>
>         
>     	<xsl:value-of select="parent::application/ssn"/>
>     	<xsl:value-of select="ancestor::rep/stages/application[@idref=$appid]/closedate"/>
>     	<xsl:value-of select="ancestor::rep/stages/application[@idref=$appid]/current"/>
>     
>     </xsl:for-each>
> 
> </xsl:for-each>
> </xsl:stylesheet>
> 
> </xsl:template>
> 
> 
> Thanks in advance ..
> -Kumar


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]