[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
[Recent Entries]
[Reply To This Message]
Re: max from sequence problem
Subject: Re: max from sequence problem
From: "Dimitre Novatchev" <dnovatchev@xxxxxxxxx>
Date: Fri, 9 Feb 2007 19:06:47 -0800
|
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:
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
|
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
RSS 2.0 |
|
Atom 0.3 |
|
|