Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

sum() function in XSL

Posted on 2003-03-26
5
Medium Priority
?
586 Views
Last Modified: 2012-06-21
Hi all,

I am tryig to find the sum of "MoneyAccountValue". But I donot get anykind of o/p nor i get anykind of error.

Here is the XSL code...

Total : <xsl:variable name="total" select="sum(Accounts/BrokerageAccount/@MoneyAccountValue)" />


and the XML code is...........


<Accounts>
<BrokerageAccount Name="Account1" Number="1234" Registration="CMA Direct" MoneyAccountValue="1000" />
<BrokerageAccount Name="Account2" Number="1235" Registration="IRA" MoneyAccountValue="1000" />

</Accounts>


I would appreciate if someone can find the reason....

THanks
Kalpana
0
Comment
Question by:kalpana_kk
3 Comments
 
LVL 14

Accepted Solution

by:
avner earned 100 total points
ID: 8215705
Have you tried to ouput the value of the variable $total ?

I tried, and it works fine :

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
     <xsl:output method="html" indent="yes" encoding="iso-8859-1" />
     <xsl:template match="/">
     <xsl:variable name="total" select="sum(Accounts/BrokerageAccount/@MoneyAccountValue)" />
     <xsl:value-of select="$total"/>
     </xsl:template>
</xsl:stylesheet>
0
 
LVL 1

Assisted Solution

by:foxyshadis
foxyshadis earned 100 total points
ID: 8228816
Depending on your XSLT implementation, you may have to use

<xsl:variable name="total" select="sum(Accounts/BrokerageAccount/@MoneyAccountValue[1])" />

As some (like Xalan) seem to require the position on attribute values. *shrug* Just a guess.
0
 
LVL 3

Expert Comment

by:jm60697
ID: 8646418
Atleast Xalan-C does not require [1].
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Problem How to write an Xquery that works like a SQL outer join, providing placeholders for absent data on the outer side?  I give a bit more background at the end. The situation expressed as relational data Let’s work through this.  I’ve …
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Loops Section Overview
Suggested Courses

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question