[Home] [By Thread] [By Date] [Recent Entries]
I corrected the originally provided transformation, although, as I said before, I still do not know what it is supposed to do! The necessary corrections were the specification of the type of the variable $maxloads and the convertion of all values involved from xs:double to xs:integer Here's the working transformation: <xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xdt="http://www.w3.org/2005/xpath-datatypes"
exclude-result-prefixes="xs xdt"
>
<xsl:output method="xml" omit-xml-declaration="yes" indent="yes"/>
<xsl:key name="grpdatetotal" match="grp"
use="concat(../@name,'+',@name)"/> <xsl:template match="/allloads">
<sums>
<xsl:variable name="maxloads" as="xs:integer*">
<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)
/xs:integer(@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>when it is applied against the originally provided xml document: <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>the result is (I hope) what was required: <sums> <seq>1 1 5 4 1 19 19 3 21 30 23 11 14 16 15</seq> <max>30</max> </sums> -- 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 On 2/9/07, Dimitre Novatchev <dnovatchev@xxxxxxxxx> wrote: On 2/9/07, Kent Seegmiller <hookjaw20@xxxxxxxxxxx> wrote: > 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:
|

Cart



