[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Grouping is not working that great over here
I removed all the nodes without <date>. Still the grouping isn't working. Updated xml/xsl below: thanks, Matts Isuls Michael Kay (11.4.2003 14:32): >I haven't looked through this in detail, but if X has no date child, >then X[date=$date] will always select nothing (any "=" comparison with >an empty node-set returns false). If you want two non-existent dates to >compare equal, force the value to a string: X[string(date)=$date] - do >this wherever you use the date as a grouping key. > >Michael Kay >Software AG >home: Michael.H.Kay@xxxxxxxxxxxx >work: Michael.Kay@xxxxxxxxxxxxxx I get this: ------ 20030404 ::1 ------ 20030405 ::2 ------ 20030101 ::2 ------ 20030202 ::2 20030303 ::1 ------ but would like to get this: ------ 20030404 ::1 ------ 20030404 ::1 20030405 ::2 ------ 20030101 ::2 20030404 ::1 20030405 ::2 ------ 20030202 ::2 20030303 ::1 20030404 ::1 ------ 20030404 ::1 20030405 ::2 ---------- ---XSL---- ---------- <?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"> <xsl:key name="mkey" match="payments/payment" use="date"/> <xsl:template match="/"> <xsl:apply-templates select="parcels" /> </xsl:template> <xsl:template match="parcels"> <xsl:apply-templates select="parcel" /> </xsl:template> <xsl:template match="parcel"> <br/> ------ <xsl:for-each select="payments/payment[count(.|key('mkey',date)[1])=1]"> <xsl:sort select="date" /> <xsl:variable name="date" select="date" /> <xsl:variable name="tot" select="sum(../../payments/payment[date=$date]/amount)" /> <br/><xsl:value-of select="$date" /> ::<xsl:value-of select="$tot" /> </xsl:for-each> </xsl:template> </xsl:stylesheet> ---------- --XML----- ---------- <?xml version="1.0" encoding="UTF-8"?> <parcels> <parcel> <payments> <payment> <date>20030404</date> <amount>1</amount> </payment> </payments> </parcel> <parcel> <payments> <payment> <date>20030404</date> <amount>1</amount> </payment> <payment> <date>20030405</date> <amount>1</amount> </payment> <payment> <date>20030405</date> <amount>1</amount> </payment> </payments> </parcel> <parcel> <payments> <payment> <date>20030101</date> <amount>1</amount> </payment> <payment> <date>20030404</date> <amount>1</amount> </payment> <payment> <date>20030405</date> <amount>1</amount> </payment> <payment> <date>20030101</date> <amount>1</amount> </payment> <payment> <date>20030405</date> <amount>1</amount> </payment> </payments> </parcel> <parcel> <payments> <payment> <date>20030202</date> <amount>1</amount> </payment> <payment> <date>20030303</date> <amount>1</amount> </payment> <payment> <date>20030404</date> <amount>1</amount> </payment> <payment> <date>20030202</date> <amount>1</amount> </payment> </payments> </parcel> <parcel> <payments> <payment> <date>20030404</date> <amount>1</amount> </payment> <payment> <date>20030405</date> <amount>1</amount> </payment> <payment> <date>20030405</date> <amount>1</amount> </payment> </payments> </parcel> </parcels> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
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
|