Dear Group,
I am new to XSL technology. I have a quite difficult doubt.
I was working on an XSLT code that will group based on an element and
sort their corresponding dates below them.
I am unable to find a way/solution to achieve it in XSLT 2.0.
What I am trying to do?
1) To sort the <ReceiptType> whose date is most recent (descending) and
keep the order.
2) To get the corresponding dates <StmtDate> below the grouped
<ReceiptType> and sort them.
3) Also, based on the year, another grouping to be done just above the
dates <StmtDate> and below the <ReceiptType>.
4) The output should be like below.
5) As of now, I am able to get the random <ReceiptType> and sorted dates
below them. I have posted my half baked XSLT code, most below.
Any help in guiding me to achieve this will be much appreciated.
Regards,
Jai
Sample input XML:
<?xml version=3D"1.0"?>
<StmtHitList>
<StmtList>
<Stmt>
<StmtDate>2010-04-02</StmtDate>
<ReceiptType>Tapestry</ReceiptType>
</Stmt>
<Stmt>
<StmtDate>2009-12-29</StmtDate>
<ReceiptType>Tapestry</ReceiptType>
</Stmt>
<Stmt>
<StmtDate>2008-07-02</StmtDate>
<ReceiptType>Quotential</ReceiptType>
</Stmt>
<Stmt>
<StmtDate>2009-12-30</StmtDate>
<ReceiptType>Retail</ReceiptType>
</Stmt>
<Stmt>
<StmtDate>2009-04-03</StmtDate>
<ReceiptType>Tapestry</ReceiptType>
</Stmt>
<Stmt>
<StmtDate>2008-07-29</StmtDate>
<ReceiptType>Quotential</ReceiptType>
</Stmt>
<Stmt>
<StmtDate>2009-11-30</StmtDate>
<ReceiptType>Quotential</ReceiptType>
</Stmt>
<Stmt>
<StmtDate>2008-07-02</StmtDate>
<ReceiptType>Tapestry</ReceiptType>
</Stmt>
</StmtList>
</StmtHitList>
Expected Output HTML after applying XSLT to the above XML:
Tapestry
2010
2010-04-02
2009
2009-12-29
2009-04-03
2008
2008-07-02
Retail
2009
2009-12-30
Quotential
2009
2009-11-30
2008
2008-07-29
2008-07-02
XSLT code that I have now:
<?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>
Notice: All email and instant messages (including attachments) sent to
or from Franklin Templeton Investments (FTI) personnel may be retained,
monitored and/or reviewed by FTI and its agents, or authorized
law enforcement personnel, without further notice or consent.
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--