Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Re: Complex grouping based on date sort and sub elements date sort >Thread Next - Re: Complex grouping based on date sort and sub elements date sort Re: Complex grouping based on date sort and sub elements date sortTo: NULL Date: 7/13/2009 1:52:00 PM jai wrote: > Thanks for your reply. I am fine with XSLT 2.0 version. > > Here is the expected output HTML: > > <HTML> > <BODY> > <H1>Tapestry</H1> > <P>2010</P> > <P>2010-04-02</P> > <P>2009</P> > <P>2009-12-29</P> > <P>2009-04-03</P> > <P>2008</P> > <P>2008-07-02</P> > <H1>Retail</H1> > <P>2009</P> > <P>2009-12-30</P> > <H1>Quotential</H1> > <P>2009</P> > <P>2009-11-30</P> > <P>2008</P> > <P>2008-07-29</P> > <P>2008-07-02</P> > </BODY> > </HTML> > > Some points that i want to explain to you based on the above HTML: > > 1) Tapestry being the corresponding item for most recent date > "2010-04-02", placed as first element (header), > Next max date corresponding to non Tapestry value is > "2009-12-30" , corresponding item is Retail - this comes second. > Next max date corresponding to non Tapestry/Retail value is > "2009-11-30" , corresponding item is Quotential - this comes third. > > 2) Below each Header (Tapestry or Quotential or Retail), dates come in > sorted format and above the dates come the year sub heading. Here is a stylesheet that should do what you want: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs" version="2.0"> <xsl:output method="html" indent="yes"/> <xsl:template match="/"> <html> <body> <xsl:for-each-group select="StmtHitList/StmtList/Stmt" group-by="ReceiptType"> <xsl:sort select="max(current-group()/StmtDate/xs:date(.))" order="descending"/> <h1><xsl:value-of select="current-grouping-key()"/></h1> <xsl:for-each-group select="current-group()" group-by="year-from-date(xs:date(StmtDate))"> <xsl:sort select="current-grouping-key()" order="descending"/> <p><xsl:value-of select="current-grouping-key()"/></p> <xsl:for-each select="current-group()/StmtDate"> <p><xsl:value-of select="."/></p> </xsl:for-each> </xsl:for-each-group> </xsl:for-each-group> </body> </html> </xsl:template> </xsl:stylesheet> -- Martin Honnen --- MVP XML http://msmvps.com/blogs/martin_honnen/ | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
