[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Calculating Column Total
On 29/03/2010 05:55, Shashank Jain wrote:
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) </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"> This is ineffficient it's better to add as="xs:integer" (or xs:double, or whatever type you need) <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 $Num_Docs_Missing *( sum(for $x in $eventTemplate return(count(($x/event)) except that if (as I think you intended) $eventTemplate was a sequence of event elements, $x/event would be empty as event elements don't have event children. </xsl:function> It would appear that you want the calculation done for every event, so it needs to be a function of event nodes, not a variable. <xsl:function name="fns:f" as="xs:integer"> <xsl;param name="x" as="element()"/> <xsl:choose> <xsl:when... <xsl:sequence select=... ... </xsl:function> then <xsl:temmplate match="/"> <xsl:sequence select="sum(//event/fns:f(.))"/> </xsl:template> David Here is my XML again
This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. ________________________________________________________________________
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|