This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Getting MEAN with Mongo, Express, Angular, and Node and have Simon Holmes 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


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: 19533
    
  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.

 
Don't get me started about those stupid light bulbs.
 
subject: XSLT Calculations