[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
RE: [xsl] Calculating Column Total
Subject: RE: [xsl] Calculating Column Total From: Shashank Jain <shashankjain@xxxxxxxx> Date: Sun, 28 Mar 2010 23:55:01 -0500 |
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@xxxxxxxxx > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > CC: shashankjain@xxxxxxxx > 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 > _________________________________________________________________ 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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Calculating Column Total, David Carlisle | Thread | Re: [xsl] Calculating Column Total, David Carlisle |
Re: [xsl] Calculating Column Total, David Carlisle | Date | Re: [xsl] Calculating Column Total, David Carlisle |
Month |