xsl-list
[Top] [All Lists]

Re: Tricky inclusion match

2005-03-29 11:13:13
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[(_at_)fieldname='paint']=$luMD_GroupA][generate-id()=generate-id(key('key_paint',field[(_at_)fieldname='paint']))]"
mode="COUNT"/>
</xsl:variable>
<xsl:variable name="groupb_count">
<xsl:apply-templates
select="ancestor::recordset/record[field[(_at_)fieldname='paint']=$luMD_GroupB][generate-id()=generate-id(key('key_paint',field[(_at_)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[(_at_)fieldname='paint']
= current()/field[(_at_)fieldname='paint']]))"/>
</xsl:template>


--~------------------------------------------------------------------
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>