File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
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
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

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