|
Subject: Re: [xsl] Tricky inclusion match From: Karl Stubsjoen <kstubs@xxxxxxxxx> Date: Tue, 29 Mar 2005 11:34:02 -0700 |
groupa_count and groupb_count are really the collection of results
from the match on "record". So the result for group a might be:
<groupa_count>
<value>1</value>
<value>2</value>
<value>1</value>
</groupa_count>
The sum of group a would then be: 4
On Tue, 29 Mar 2005 12:13:13 -0600, Jon Gorman
<jonathan.gorman@xxxxxxxxx> wrote:
> > Here is what I have so far, I have a match on "record". I use a key
> > "key_paint" to count my "group a" items and the same key to count my
> > "groub b" items. Group a and group b items are predifined as part of
> > the xml source. So, I achieve a unique count of "group a" and "group
> > b" items and now I need to evaluate the total of these two. In plain
> > english: "count unique items and then sum the count". (see
> > additional comments inline below)
>
> I have this feeling I must be missing part of the problem, but why not
> just add the variables (ie $groupa_count + $groupb_count) in the
> value-of? (see below)
>
> If you want the sum for both groupa and groupb and then add those
> together can't you simply use sum in a template that similar to the
> "count" template you have?
>
> > <xsl:template match="record">
> >
> > <xsl:variable name="groupa_count">
> >
> > !!comment: right here, instead of a select I'd like to wrap this in a
> > SUM() but not possible... or is it? Using value-of instead doesn't
> > drive my template match and it is impossible to implement the use of a
> > mode.
> >
> > <xsl:apply-templates
> > select="ancestor::recordset/record[field[@fieldname='paint']=$luMD_GroupA][generate-id()=generate-id(key('key_paint',field[@fieldname='paint']))]"
> > mode="COUNT"/>
> > </xsl:variable>
> > <xsl:variable name="groupb_count">
> > <xsl:apply-templates
> > select="ancestor::recordset/record[field[@fieldname='paint']=$luMD_GroupB][generate-id()=generate-id(key('key_paint',field[@fieldname='paint']))]"
> > mode="COUNT"/>
> > </xsl:variable>
>
> <xsl:variable name="total_count">
> <xsl:value-of select="$groupa_count + $groupb_count"/>
> </xsl:variable>
>
> <!-- should probably do something with the variable here, but I'm not
> sure what you want...perhaps just have the xsl:value-of
> select="$groupa_count + $groub_count"? -->
> >
> > </xsl:template>
> >
> > <xsl:template match="record" mode="COUNT">
> > <xsl:value-of select="number(count(ancestor::recordset/record[field[@fieldname='paint']
> > = current()/field[@fieldname='paint']]))"/>
> > </xsl:template>
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] Tricky inclusion match, Jon Gorman | Thread | Re: [xsl] Tricky inclusion match, Aron Bock |
| Re: [xsl] normalize-space problems , G. Ken Holman | Date | RE: [xsl] param weirdness, Michael Kay |
| Month |