[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] newbie xsl questions - grouping date ranges with asso
is it possible to take the xml code below and create a grid with xsl where i can group the mfd ranges (say all dates within now+3 years, then the next 3 years, and then next 3 years) and then sum the ttblack field for those ranges so that a grid would be created with rows as follows: now -2007 2008-2011 2012-2015 TEST 300 200 100 TEST1 30 10 5 Total 330 210 105 the numbers are not correct, but is the idea clear? does a key need to be used to only sum the ranges for certain dates? tia, dk <?xml version="1.0" encoding="ISO-8859-1"?> <?xml-stylesheet type="text/xsl" href="Ed.xsl"?> <Portfilio> <AsOf>11/16/2004</AsOf> <Trade> <TradeId>TEST</TradeId> <Step mfd="11/16/2004" TTBlack="20"/> <Step mfd="05/18/2005" TTBlack="40"/> <Step mfd="11/18/2005" TTBlack="50"/> <Step mfd="11/20/2006" TTBlack="0"/> <Step mfd="05/18/2007" TTBlack="0"/> <Step mfd="11/19/2007" TTBlack="20"/> <Step mfd="05/19/2008" TTBlack="0"/> <Step mfd="11/18/2008" TTBlack="10"/> <Step mfd="05/18/2009" TTBlack="0"/> <TradeId>TEST1</TradeId> <Step mfd="11/16/2004" TTBlack="0"/> <Step mfd="11/18/2004" TTBlack="139"/> <Step mfd="05/18/2005" TTBlack="1,395"/> <Step mfd="11/18/2005" TTBlack="2,035"/> <Step mfd="05/18/2006" TTBlack="2,645"/> <Step mfd="11/20/2006" TTBlack="3,003"/> <Step mfd="05/18/2007" TTBlack="3,475"/> <Step mfd="11/19/2007" TTBlack="3,735"/> <Step mfd="05/19/2008" TTBlack="4,026"/> <Step mfd="11/18/2008" TTBlack="4,205"/> <Step mfd="05/18/2009" TTBlack="4,467"/> </Trade> this xsl below does not work: <?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:template match="Portfilio"> <html> <body> <xsl:for-each select="Step"> <xsl:variable name="currentdate"> <xsl:value-of select="substring(@date,7,4)"/> <xsl:value-of select="substring(@date,1,2)"/> <xsl:value-of select="substring(@date,4,2)"/> </xsl:variable> <xsl:variable name="datebucket1"> <xsl:value-of select="substring(@date,7,4)+3"/> <xsl:value-of select="substring(@date,1,2)"/> <xsl:value-of select="substring(@date,4,2)"/> </xsl:variable> <xsl:variable name="datebucket2"> <xsl:value-of select="substring(@date,7,4)+6"/> <xsl:value-of select="substring(@date,1,2)"/> <xsl:value-of select="substring(@date,4,2)"/> </xsl:variable> <xsl:variable name="datebucket3"> <xsl:value-of select="substring(@date,7,4)+9"/> <xsl:value-of select="substring(@date,1,2)"/> <xsl:value-of select="substring(@date,4,2)"/> </xsl:variable> <!-- <xsl:value-of select="$currentdate"/> <br></br> <xsl:value-of select="$datebucket1"/> <br></br> <xsl:value-of select="$datebucket2"/> <br></br> <xsl:value-of select="$datebucket3"/> --> <br></br> <xsl:variable name="MinFlowDate"> <xsl:value-of select="substring(@MinFlowDate,7,4)"/> <xsl:value-of select="substring(@MinFlowDate,1,2)"/> <xsl:value-of select="substring(@MinFlowDate,4,2)"/> </xsl:variable> <xsl:variable name="amt"> <xsl:value-of select="format-number(translate(@StepCharge_TTBlack, ',', ''), '.00')"/> </xsl:variable> <br></br> <xsl:value-of select="number($MinFlowDate)"/> <br></br> <xsl:value-of select="number($currentdate)"/> <br></br> <!-- <xsl:call-template name="sum"> <xsl:with-param name="node-set" select="$node-set[not(position() = 1)]"/> <xsl:with-param name="sum" select="$sum + $width"/> </xsl:call-template>--> <xsl:param name="asum"/> <xsl:choose> <xsl:when test="number($MinFlowDate) >= number($currentdate) and number($MinFlowDate) <= number($datebucket1)"> 1)<xsl:value-of select="$amt"/> </xsl:when> <xsl:when test="number($MinFlowDate) >= number($datebucket1) and number($MinFlowDate) <= number($datebucket2)"> 2)<xsl:value-of select="$amt"/> </xsl:when> <xsl:when test="number($MinFlowDate) >= number($datebucket2) and number($MinFlowDate) <= number($datebucket3)"> 3)<xsl:value-of select="$amt"/> </xsl:when> <xsl:otherwise> </xsl:otherwise> </xsl:choose> <xsl:value-of select="$asum"/> <br/> </xsl:for-each> </body> </html> </xsl:template> </xsl:stylesheet>
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|