Re: [xsl] Sorting Problem

Subject: Re: [xsl] Sorting Problem
From: puja thakral <puja_thakral@xxxxxxxxx>
Date: Thu, 16 Oct 2003 09:12:17 -0700 (PDT)
Thanks everyone.
Thanks for  the references.I'll look into them.
Besides that my xml is

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="example2.xsl"?>
<dataroot
xmlns:od="urn:schemas-microsoft-com:officedata"
generated="2003-10-15T12:22:08">


<GrantNet>
<Issue_x0020_Number>0005</Issue_x0020_Number>
<Handout_x0020_Number>111</Handout_x0020_Number>
<fldCatID>GS</fldCatID>
<fldSponsorDesc>American Association of University
Women</fldSponsorDesc>
<Program>2000-2001 American Fellowships</Program>
<URL>http://www.aauw.org/3000/fdnfelgra.html</URL>
<Description>American Fellowships </Description>
<Deadline_x0020_Date>1999-11-15T00:00:00</Deadline_x0020_Date>
<Program_x0020_Source>Web</Program_x0020_Source>
<Date_x0020_of_x0020_Notice>1999-10-11T00:00:00</Date_x0020_of_x0020_Notice>
<Annual_x0020_Program>0</Annual_x0020_Program>
</GrantNet>

<GrantNet>
<Issue_x0020_Number>0103</Issue_x0020_Number>
<Handout_x0020_Number>752</Handout_x0020_Number>
<fldCatID>ID</fldCatID>
<fldSponsorDesc>American Council of Learned
Societies</fldSponsorDesc>
<Program>Library of Congress Fellowships in
International Studies</Program>
<URL>http://www.acls.org</URL>
<Description></Description>
<Deadline_x0020_Date>2000-10-02T00:00:00</Deadline_x0020_Date>
<Program_x0020_Source>Mailing from
Sponsor</Program_x0020_Source>
<Date_x0020_of_x0020_Notice>2000-08-25T00:00:00</Date_x0020_of_x0020_Notice>
<Annual_x0020_Program>0</Annual_x0020_Program>
</GrantNet>

<GrantNet>
<Issue_x0020_Number>0103</Issue_x0020_Number>
<Handout_x0020_Number>753</Handout_x0020_Number>
<fldCatID>ID</fldCatID>
<fldSponsorDesc>American Council of Learned
Societies</fldSponsorDesc>
<Program>Contemplative Practice Fellowships</Program>
<URL>http://www.acls.org</URL>
<Description></Description>
<Deadline_x0020_Date>2000-11-01T00:00:00</Deadline_x0020_Date>
<Program_x0020_Source>Mailing from
Sponsor</Program_x0020_Source>
<Date_x0020_of_x0020_Notice>2000-08-25T00:00:00</Date_x0020_of_x0020_Notice>
<Annual_x0020_Program>1</Annual_x0020_Program>
</GrantNet>

<GrantNet>
<Issue_x0020_Number>0101</Issue_x0020_Number>
<Handout_x0020_Number>606</Handout_x0020_Number>
<fldCatID>SB</fldCatID>
<fldSponsorDesc>A.L. Mailman Family Foundation,
Inc.</fldSponsorDesc>
<Program>Foundation Grants</Program>
<URL>http://www.mailman.org</URL>
<Description>
Goals 
</Description>
<Program_x0020_Source>Other</Program_x0020_Source>
<Date_x0020_of_x0020_Notice>2000-06-26T00:00:00</Date_x0020_of_x0020_Notice>
<Annual_x0020_Program>0</Annual_x0020_Program>
</GrantNet>

</dataroot>

xsl is

<?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";
xmlns:xlink="http://www.w3.org/1999/xlink";>
<xsl:output omit-xml-declaration="yes" indent="yes"/> 
<xsl:template match="/">

<HTML>
<HEAD>
  <TITLE>GrantNet</TITLE>
</HEAD>
<BODY>

<A NAME="TOP"/>	
<h2 align="center"><font color="#800000">Office Of
Research and Sponsored Programs<BR/><BR/>GrantNet
Month 2003</font></h2><BR/>
<p align="left"><font color="#004080" face="Times New
Roman"><a name="Sorted by Disciplines"><big>Sorted by
Disciplines</big></a></font></p>
<p align="left"><font color="#004080" face="Times New
Roman">

<xsl:for-each select="dataroot/GrantNet">
<xsl:sort select="fldCatID"/>
<a href="#{generate-id(fldCatID)}"><xsl:value-of
select="fldCatID"/></a><br/>
</xsl:for-each>
</font></p>

<xsl:for-each select="dataroot/GrantNet">
<xsl:sort select="fldCatID"/>
</xsl:for-each>

<xsl:for-each select="dataroot/GrantNet">
<P><B><center><strong><font color="#000080"><big><big>
<a name="{generate-id(fldCatID)}">
<xsl:value-of select="fldCatID"/>
</a></big></big></font></strong></center></B></P>
<P>
<B><xsl:value-of select="fldCatID"/>-<xsl:value-of
select="Handout_x0020_Number"/></B><BR/>
<font color="#0000FF"><xsl:value-of
select="fldSponsorDesc"/></font><BR/>
<B><U><xsl:value-of select="Program"/></U></B></P>
<xsl:value-of select="Description"/>
<BR><I><font color="#0000FF"><a href="@">
<xsl:value-of select="URL"/></a>
</font></I>
<BR><B>Deadline:<xsl:value-of
select="Deadline_x0020_Date"/></B></BR></BR>
<hr/>

<p><center>[<a href="#TOP">TOP</a>]</center></p><hr/>
</xsl:for-each>

</BODY>
</HTML>
</xsl:template>
</xsl:stylesheet>

I want to view the output such that GrantNet with
flCatID 'GS' should appear oneafter the other and
GrantNet with fldCatId 'ID' should appear after that
in ascending order.

<GrantNet>
 <fldCatID>GS</fldCatID>
......
</GrantNet>

<GrantNet>
 <fldCatId>ID</fldCatId>
......
</GrantNet>


--- Mukul Gandhi <mukulgw3@xxxxxxxxx> wrote:
> Hi Puja,
> It will be nice, if you can post the XML, with which
> you are working. Also, please post the desired
> output,
> specifying how you wish to do sorting.
> 
> Regarding question about xsl:for-each and
> xsl:template
> match, these are basic syntax of XSL. 
> 
> Please look at the site --
> http://www.w3schools.com/xsl/default.asp, &
> http://www.w3schools.com/xpath/default.asp
> 
> for a nice beginner help on XSLT and XPath..
> 
> Dave Pawson's Q & A site is also quite useful --
> http://www.dpawson.co.uk/xsl/sect2/sect21.html
> 
> Regards,
> Mukul
> 


__________________________________
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com

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


Current Thread