|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: xsl Date Sorting referencing ID and data in adiffe
Hello Joerg ..
Thanks for your inputs .. I just happened to try this ... It still doesnt seem to sort ...Here is the XSL i wrote
adopting your solution ,.....Please advise ...
XSL:
<?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">
<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))]">
<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>
</xsl:stylesheet>
For XML:
<rep>
<company>
<application id="768">
<region_name><![CDATA[Region 4]]></region_name>
<company_name><![CDATA[ABC Inc.]]></company_name>
<ssn>234567890</ssn>
</application>
<application id="232">
<region_name><![CDATA[Region 4]]></region_name>
<company_name><![CDATA[BBC Inc.]]></company_name>
<ssn>112334556</ssn>
</application>
<application id="455">
<region_name><![CDATA[Region 2]]></region_name>
<company_name><![CDATA[CCC Inc.]]></company_name>
<ssn>667778559</ssn>
</application>
</company>
<stages>
<application idref="768">
<closedate>20020321</closedate>
<current>decline</current>
</application>
<application idref="232">
<closedate>20020411</closedate>
<current>cancel</current>
</application>
<application idref="455">
<closedate>20020227</closedate>
<current>decline</current>
</application>
</stages>
</rep>
Thanks everyone..
-Kumar
>>> joerg.heinicke@xxxxxx 05/07/02 07:57PM >>>
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
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








