xsl-list
[Top] [All Lists]

RE: [xsl] Calculating Column Total

2010-03-28 23:55:26

Thanks David for this.
 
But I want to pass the value of the variable which follow certain conditions. 
In my previous post I made the conditions too simple (sorry about that).
Also thanks for correcting me that I was matching my template to the document 
node.
I am trying to run 
 
 
<xsl:template match="/">
   <xsl:value-of select="fns:sumMissing_template(event_template)"/>
</xsl:template>
 
<xsl:function name="fns:sumMissing_template">
<xsl:param name="eventTemplate " as="element()*"/>
  <xsl:variable name="Num_Docs_Missing">
   <xsl:choose>
     <xsl:when test="@complete='Y'">
        *****Some Calculations**********
     </xsl:when>
     <xsl:otherwise>
       *****Some Calculations**********
     </xsl:otherwise>
   </xsl:choose>
  </xsl:variable>
<xsl:sequence select="sum(for $x in $eventTemplate return(count(($x/event) * 
$Num_Docs_Missing)))"/>
</xsl:function>
 
Here is my XML again
 
<data>
    <event_template sp_doctypes="Research Note, Prior Stock Report, Stock 
Report">
        <event complete='Y'/>
        <event complete='N'/>
    </event_template>
    <event_template sp_doctypes=" Prior Stock Report, Stock Report">
        <event complete='Y'/>
        <event complete='N'/>
        <event complete='N'/>
        <event complete='Y'/>
    </event_template>
</data>
 
I am trying to achieve is the total of event*(Num_Docs_Missing) for all the 
event_template.
 
 Thanks 
 Shashank

----------------------------------------
Date: Mon, 29 Mar 2010 02:20:38 +0100
From: davidc(_at_)nag(_dot_)co(_dot_)uk
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
CC: shashankjain(_at_)live(_dot_)com
Subject: Re: [xsl] Calculating Column Total

On 29/03/2010 01:57, Shashank Jain wrote:

All,

I am stuck in calculating total of another column.

My XML is



























This is the xsl I am using




















I am trying to calculate the sum of $Num_Docs_Missing for all the events.
Please let me know where I am doing wrong.

Thanks
Shashank

if you use xsl;variable without an as attribute you generate a document
node containing a text node, and simlarly if you use value-of you always
generate a text node. If you want a numeric valued function it is far
better to use numbers rather than text nodes.

in



you pass your function the sequence of event children of the document
node, but the only child of that node has name data, so this is the
empty sequence.

It appears that you just want





David



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

                                          
_________________________________________________________________
Hotmail has tools for the New Busy. Search, chat and e-mail from your inbox.
http://www.windowslive.com/campaign/thenewbusy?ocid=PID27925::T:WLMTAGL:ON:WL:en-US:WM_HMP:032010_1
--~------------------------------------------------------------------
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>
--~--