xsl-list
[Top] [All Lists]

RE: Calculating Sum in XSLT 1.0

2004-12-22 11:23:39
will this work with xalan? because i tried to use
something like this and it gave me an error. 

also i tried using this
<xsl:template match="currentnode"
...
...

<xsl:variable name="Total">
        <xsl:for-each
select="preceding-sibling::sibling[(_at_)value]">
            <SubTotal>
              <xsl:value-of select="(@value)"/>
            </SubTotal>
          </xsl:for-each>
</xsl:variable>

<p>
  <xsl:value-of
select="sum(xalan:nodeset($Total)/SubTotal)"/>
<br/>
</p>

</xsl:template>

and it gives me an error 

"function not in namespaceError in Xpath expression,
function not in namespace"

Please let me know.
Thanks,
Abhi



--- Michael Kay <mike(_at_)saxonica(_dot_)com> wrote:

sum(preceding-sibling::sibling/@value)

Michael Kay
http://www.saxonica.com/ 

-----Original Message-----
From: Abhijit Junnare [mailto:mavlaabhi(_at_)yahoo(_dot_)com]

Sent: 22 December 2004 17:09
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Calculating Sum in XSLT 1.0

I am trying to generate a sum of attribute values
of
sibling nodes via XSLT 1.0

My XML looks like this

<sibling value="5"/>
<sibling value="7">
<sibling value="9">
<sibling value="13">
<currentnode>some text</currentnode>

When I am processing the template for currentnode
I
want to calculate the sum of the "value" attribute
of
all its previous sibling nodes i.e. I want to find
the
sum of 5,7,9 and 13. The names of the sibling node
and
current node are different. 
I know there isn't a direction function to do
this. If
anyone has written template or come accross the
problem then please let me know how did you solve
it. 
Thank you for your help and Merry Christmas.
Abhi



            
__________________________________ 
Do you Yahoo!? 
Read only the mail you want - Yahoo! Mail
SpamGuard. 
http://promotions.yahoo.com/new_mail 



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





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





                
__________________________________ 
Do you Yahoo!? 
Yahoo! Mail - Easier than ever with enhanced search. Learn more.
http://info.mail.yahoo.com/mail_250

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