This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes  XSLT  Calculations Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark " XSLT  Calculations" Watch " XSLT  Calculations" New topic
Author

XSLT Calculations

Siva Arun
Greenhorn

Joined: Feb 23, 2010
Posts: 28
Input XML



XSL


I just want to calculate the average marks of all the students and display it on the same output HTML. Could you please guide me?
Thanks in advance.

"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan.
Paul Clapham
Sheriff

Joined: Oct 14, 2005
Posts: 19747
    
  10

There's a "sum(nodeset)" function in XSLT. And I expect if you looked in some documentation you would find another function called something like "count". Those should take care of the problem.
Siva Arun
Greenhorn

Joined: Feb 23, 2010
Posts: 28
The below code works fine.




avg function seems to be not available in XLST 1.0 version. Though I used XSLT 2.0, It is giving me the error.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: XSLT Calculations
 
It's not a secret anymore!