[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Calculating Column Total

Subject: RE: Calculating Column Total
From: Shashank Jain <shashankjain@xxxxxxxx>
Date: Fri, 2 Apr 2010 10:25:04 -0500
RE:  Calculating Column Total
Thanks David for correcting and explaining me how to select the context node
in functions.
Your solution really helped me.
Thanks again.


> Date: Tue, 30 Mar 2010 22:49:34 +0100
> From: davidc@xxxxxxxxx
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> CC: shashankjain@xxxxxxxx
> Subject: Re:  Calculating Column Total
> On 30/03/2010 22:20, Shashank Jain wrote:
>> Thanks David for explaining what I was doing wrong.
>> I am still stuck in the calculation for every event.
>> <data>
>> <event_template sp_mand_doctypes="Research Note, Prior Stock Report, Stock
>> <event complete='Y' complete_percent='100.0'/>
>> <event complete='N' complete_percent='0.0'/>
>> </event_template>
>> <event_template sp_mand_doctypes=" Prior Stock Report, Stock
>> Report">
>> <event complete='Y'complete_percent='100.0'/>
>> <event complete='N'complete_percent='0.0'/>
>> <event complete='N'complete_percent='50.0'/>
>> <event
>> complete='Y'/>
>> </event_template>
>> </data>
>> and I am using this xsl
>> <xsl:template match="/">
>>    <xsl:sequence select="sum(//event/fns:f(.))"/>
>> </xsl:template>
>> <xsl:function name="fns:f">
>>    <xsl:param name="x" as="element()"/>
>>    <xsl:choose>
>>        <xsl:when test="$x/@complete='Y'">
>>         <xsl:value-of select="number(0)"/>
> number(0) is the same as 0, but in either case you have converted it to
> a text node with the decimal expansion of the number by using value-of,
> use xsl;sequence instead.
>>         </xsl:when>
>>         <xsl:when test="$x/@complete_percent='0.0'">
>> *********am not able to pass value in the variable
>>          <xsl:variable name="mandatoryDocs"
> you can't evaluate parent::event_template or any relative xpath as there
> is no context node in the body of a function. You want the parent of the
> $x parameter so that's select="$x/../@sp_mand_doctypes
>>          <xsl:variable name="strArray"
>>          <xsl:value-of select="number(count($strArray))"/>
> again there's no point in applying number() to count() as it's already
> an integer, but don't apply xsl:value-of to that.
>>         </xsl:when>
>>    </xsl:choose>
>> </xsl:function>

Hotmail is redefining busy with tools for the New Busy. Get more from your

Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.