xsl-list
[Top] [All Lists]

Re: [xsl] max from sequence problem

2007-02-09 20:07:09
On 2/9/07, Kent Seegmiller <hookjaw20(_at_)comcast(_dot_)net> 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


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>