Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries [Thread Prev] >Thread Next - Re: Complex grouping based on date sort and sub elements date sort Complex grouping based on date sort and sub elements date sortTo: NULL Date: 7/3/2009 1:16:00 AM Hi Everybody, I am newbie in XSLT. Just wanted to know if my requirement is possible using XSLT. (To be clear) algorithm in words: 1) Select one <ReceiptType> whose <StmtDate> is most recent and display that as first element in HTML output. 2) Below that displayed <ReceiptType>, sort the <StmtDate> of corresponding <ReceiptType> inside XML in descending order. 3) Repeat step #1) and #2) until unique <ReceiptType> is available. So far, I am able to fetch the <ReceiptType> element randomly and its corresponding <StmtDate> elements in a sorted order. Any help or directions to acheive will be very much appreciated. Kindly mail me for more clarifications if any. Thanks in advance!! Jai jaiganesh.kannan@g... My XSLT: <?xml version="1.0" encoding="UTF-8"?> <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"/> <xsl:template match="/"> <HTML> <BODY> <xsl:for-each select="//ReceiptType[not(. = following::ReceiptType)]" > <H1><xsl:value-of select="."/></H1> <xsl:for-each select="//Stmt[ReceiptType=current()]"> <xsl:sort select="substring(StmtDate,1,4)" order="descending" data- type="number" /> <xsl:sort select="substring(StmtDate,6,2)" order="descending" data- type="number" /> <xsl:sort select="substring(StmtDate,9,2)" order="descending" data- type="number" /> <P><xsl:value-of select="StmtDate"/></P> </xsl:for-each> </xsl:for-each> </BODY> </HTML> </xsl:template> </xsl:stylesheet> Sample XML: <?xml version="1.0"?> <StmtHitList> <StmtList> <Stmt> <StmtDate>2010-04-02</StmtDate> <ID1>001</ID1> <ID2>001</ID2> <ReceiptType>Tapestry</ReceiptType> </Stmt> <Stmt> <StmtDate>2009-12-29</StmtDate> <ID1>001</ID1> <ID2>001</ID2> <ReceiptType>Tapestry</ReceiptType> </Stmt> <Stmt> <StmtDate>2008-07-02</StmtDate> <ID1>002</ID1> <ID2>002</ID2> <ReceiptType>Quotential</ReceiptType> </Stmt> <Stmt> <StmtDate>2009-12-30</StmtDate> <ID1>004</ID1> <ID2>004</ID2> <ReceiptType>Retail</ReceiptType> </Stmt> <Stmt> <StmtDate>2009-04-03</StmtDate> <ID1>003</ID1> <ID2>003</ID2> <ReceiptType>Tapestry</ReceiptType> </Stmt> <Stmt> <StmtDate>2008-07-29</StmtDate> <ID1>002</ID1> <ID2>002</ID2> <ReceiptType>Quotential</ReceiptType> </Stmt> <Stmt> <StmtDate>2009-11-30</StmtDate> <ID1>002</ID1> <ID2>002</ID2> <ReceiptType>Quotential</ReceiptType> </Stmt> <Stmt> <StmtDate>2008-07-02</StmtDate> <ID1>002</ID1> <ID2>002</ID2> <ReceiptType>Tapestry</ReceiptType> </Stmt> </StmtList> </StmtHitList> | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
