Subject: Re: Calculating Column Total
From: Mukul Gandhi <gandhi.mukul@xxxxxxxxx>
Date: Thu, 25 Mar 2010 09:07:54 +0530
|
you may write a XSLT function as following, for this need:
<xsl:function name="my:sumEvent_template" as="xs:nonNegativeInteger">
<xsl:param name="eventTempl" as="element()*" />
<xsl:sequence select="sum(for $x in $eventTempl return
(count($x/event) * count(tokenize($x/@sp_doctypes,','))))" />
</xsl:function>
and call it as following:
<xsl:value-of select="my:sumEvent_template(event_template)" />
PS: this is not tested.
On Thu, Mar 25, 2010 at 1:03 AM, Shashank Jain <shashankjain@xxxxxxxx> wrote:
>
> HI All,
>
>
>
> I am trying to calculate the total of all the columns which I am
>
> creating dynamically.
>
>
>
> My XML is
>
>
>
> <data>
>
> <event_template sp_doctypes="Research Note, Prior Stock Report, Stock
> B Report">
>
> B B B B <event B r_version_label="[1.0, CURRENT]" />
>
> B B B B <event B r_version_label="[2.0, CURRENT]" />
>
> B B B B </event_template>
>
> B B <event_template sp_doctypes=" Prior Stock Report, Stock Report"
>>
>
> B B B B <event B r_version_label="[1.0, CURRENT]" />
>
> B B B B <event B r_version_label="[2.0, CURRENT]" />
>
> B B B B <event B r_version_label="[1.0, CURRENT]" />
>
> B B B B <event B r_version_label="[2.0, CURRENT]" />
>
> B </event_template>
>
> B </data>
>
>
>
> and this is the template I am using
>
>
>
> <xsl:template name="Col_Total_Num_Mand">
>
> B B B B B <xsl:for-each select="event_template ">
>
> B B B B B <xsl:variable name="MandatoryDocs" select="@sp_doctypes"/>
>
> B B B B B <xsl:variable name="StrArray"
select="tokenize($MandatoryDocsStr,',')"/>
>
> B B B B B <xsl:variable name="test" select="count($StrArray)"/>
>
> B B B <xsl:value-of select="count(child::event)*$test"/>
>
> B B B </xsl:for-each>
>
> </xsl:template>
>
>
>
> What I am trying to achieve is the total of events*(test) for all the
>
> event_template.
>
> I am able to do it for individual event_template but not able to add
> them all.
>
>
>
> Thanks
--
Regards,
Mukul Gandhi
|