Subject: Re: [xsl] max from sequence problem From: "Dimitre Novatchev" <dnovatchev@xxxxxxxxx> Date: Fri, 9 Feb 2007 19:06:47 -0800 |
I am trying to get the max sum of each grp/@name for each date/@name to scale it to a graph. I am using saxon8.7 xslt2.0 but get the error:
This is quite unclear description. Sum of what? I had to analyze your code (which, BTW, seems too complicated) to find that you ar summing the values of the "count" attribute.
So, could you, please, explain exactly the problem, best provide a small example with the wanted results.
-- Cheers, Dimitre Novatchev --------------------------------------- Truly great madness cannot be achieved without significant intelligence. --------------------------------------- To invent, you need a good imagination and a pile of junk ------------------------------------- You've achieved success in your field when you don't know whether what you're doing is work or play
Error line 19 ... FORG0001: Failure converting {1 1 5 4 1 19 19...} to a number
My source <?xml version="1.0" encoding="UTF-8" ?> <allloads> <firstdate>2007-01-28</firstdate> <group name="PERISHABLE"> <cons name="FROZEN"> <date name="2007-01-28" skipdatecells="0"> <grp name="1" count="1" skipcells="1" /> <grp name="2" count="1" skipcells="0" /> <grp name="3" count="1" skipcells="0" /> </date> <date name="2007-01-29" skipdatecells="0"> <grp name="1" count="2" skipcells="1" /> <grp name="2" count="6" skipcells="0" /> <grp name="3" count="3" skipcells="0" /> </date> <date name="2007-01-30" skipdatecells="0"> <grp name="0" count="7" skipcells="0" /> <grp name="1" count="4" skipcells="0" /> <grp name="2" count="1" skipcells="0" /> </date> <date name="2007-01-31" skipdatecells="0"> <grp name="0" count="2" skipcells="0" /> <grp name="1" count="1" skipcells="0" /> <grp name="2" count="3" skipcells="0" /> </date> </cons> <cons name="DELI"> <date name="2007-01-28" skipdatecells="0"> <grp name="3" count="2" skipcells="3" /> <grp name="4" count="1" skipcells="0" /> <grp name="5" count="1" skipcells="0" /> </date> <date name="2007-01-29" skipdatecells="0"> <grp name="0" count="12" skipcells="0" /> <grp name="1" count="10" skipcells="0" /> <grp name="2" count="7" skipcells="0" /> </date> <date name="2007-01-30" skipdatecells="0"> <grp name="0" count="7" skipcells="0" /> <grp name="1" count="4" skipcells="0" /> <grp name="2" count="1" skipcells="0" /> </date> <date name="2007-01-31" skipdatecells="0"> <grp name="0" count="5" skipcells="0" /> <grp name="1" count="3" skipcells="0" /> <grp name="2" count="3" skipcells="0" /> </date> </cons> </group> <group name="GROC"> <cons name="GROC"> <date name="2007-01-28" skipdatecells="0"> <grp name="3" count="2" skipcells="3" /> <grp name="4" count="3" skipcells="0" /> </date> <date name="2007-01-29" skipdatecells="0"> <grp name="0" count="9" skipcells="0" /> <grp name="1" count="7" skipcells="0" /> <grp name="2" count="6" skipcells="0" /> </date> <date name="2007-01-30" skipdatecells="0"> <grp name="0" count="16" skipcells="0" /> <grp name="1" count="15" skipcells="0" /> <grp name="2" count="9" skipcells="0" /> </date> <date name="2007-01-31" skipdatecells="0"> <grp name="0" count="7" skipcells="0" /> <grp name="1" count="12" skipcells="0" /> <grp name="2" count="9" skipcells="0" /> </date> </cons> </group> </allloads>
And my xsl:
<?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xdt="http://www.w3.org/2005/xpath-datatypes"> <xsl:output method="xml"/> <xsl:key name="grpdatetotal" match="grp" use="concat(../@name,'+',@name)"/> <xsl:template match="/allloads"> <sums> <xsl:variable name="maxloads"> <xsl:for-each-group select="./group/cons/date" group-by="@name"> <xsl:variable name="dategroup" select="current-grouping-key()"/> <xsl:for-each-group select="current-group()" group-by="grp/@name"> <xsl:variable name="groupGrp" select="concat($dategroup,'+',current-grouping-key())"/> <xsl:sequence select="sum(current-group()/key('grpdatetotal',$groupGrp)/@count)"/> </xsl:for-each-group> </xsl:for-each-group> </xsl:variable> <seq><xsl:value-of select="$maxloads"/></seq> <max><xsl:value-of select="max($maxloads)"/></max> </sums> </xsl:template>
</xsl:stylesheet>
What am I overlooking??? TIA
-Kent
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] max from sequence problem, Kent Seegmiller | Thread | Re: [xsl] max from sequence problem, Dimitre Novatchev |
[xsl] max from sequence problem, Kent Seegmiller | Date | Re: [xsl] max from sequence problem, Dimitre Novatchev |
Month |