Subject: Re: [xsl] Calculating Column Total From: David Carlisle <davidc@xxxxxxxxx> Date: Mon, 29 Mar 2010 09:54:54 +0100 |
the only child of / is the elementwith name data, so you are passing an empty sequence to your function. I think you intended to pass a sequence of event elements which would be "fns:sumMissing_template(//event)
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>
using an xsl:variable with content but no as attribute makes a document node with a text node with the decimal expansion of a number.<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)))"/>the value of the variable $Num_Docs_Missing is calcuated before the loop so the above is the same as
</xsl:function>
<xsl:function name="fns:f" as="xs:integer"> <xsl;param name="x" as="element()"/> <xsl:choose> <xsl:when... <xsl:sequence select=... ... </xsl:function>
<xsl:temmplate match="/"> <xsl:sequence select="sum(//event/fns:f(.))"/> </xsl:template>
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.
________________________________________________________________________ The Numerical Algorithms Group Ltd is a company registered in England and Wales with company number 1249803. The registered office is: Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Calculating Column Total, Shashank Jain | Thread | RE: [xsl] Calculating Column Total, Shashank Jain |
RE: [xsl] Calculating Column Total, Shashank Jain | Date | [xsl] Referring to imported variabl, Christian Roth |
Month |