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

xsl Date Sorting referencing ID and data in a differen

Subject: xsl Date Sorting referencing ID and data in a different Node
From: "KUMAR NINGASHETTY" <kningashetty@xxxxxxxxxxxxxxxx>
Date: Tue, 07 May 2002 17:52:33 -0400
xsl date
Hi,

    Given a straight xml and with no ID and IDref's to refer i can Sort end result Datewise .
    IN the following XML i am having problem to sort by 'closedate' which is in  different node .
    In my XSL i use keys to group the data by Regions and display corresponding data beneath ..
    It seems to be little tricky to sort by <closedate> which is child of <stages> node by preserving 
    the exsiting key technique .
   Note : if the <closedate> is part of  /company/application then i am able to sort it though ...

  Any help appreciated ..

    Following is the XML and XSL i am having presently ...

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 4]]></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 appsysidref="455">
	    <closedate>20020227</closedate>
	    <current>decline</current>
	</application>
 </stages>
</rep>


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


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.