File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

subtotal in xslt?

 
arulraj michealraj
Greenhorn
Posts: 28
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

summaryreport.xsl


//template for row1




The requirement is that subtotals need to be added for each group(group's atrriute is partnerid in summaryReport) in my summary report.
The object(summaryReport) are splitted into row1 and row2 respectively to fullfill our requirements.

Ex: summary report -record 1
partnerid=1;
totalpayment=10.00;
badpayment=20.00;
goodpayment=10.00;
avgpayment=10.00;
minpayment=20.00;
maxpayment=10.00;

summary report -record 2
partnerid=1;
totalpayment=10.00;
badpayment=30.00;
goodpayment=10.00;
avgpayment=40.00;
minpayment=20.00;
maxpayment=10.00;

summary report -record 3
partnerid=3;
totalpayment=10.00;
badpayment=20.00;
goodpayment=10.00;
avgpayment=10.00;
minpayment=20.00;
maxpayment=10.00;

Let's assume I have three records in summaryreport list.when the list is iterating in for-each loop, i have to check the current record's partnerid with next's
partnerid and do the summation(ie:subtotal) for each attribute in summary report till partner id is 1 and displays subtotal at end of each group.similarly i have to do for other group as well.
As i am new to this xsl, i am bit struggling to implement the above scenario.


1) How to compare the first and record object in for-each based on group(partner-id)?
2) how to do the summation for each group(partnerid)attributes?

 
Paul Clapham
Sheriff
Pie
Posts: 20191
26
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I edited your post to use the "code" tags to delimit code instead of the "bold" tags. Notice how it makes the code more readable and prevents your XSLT elements from being converted to smilies? Much easier to read.

As for your question, if you google "xslt grouping" the first link you get is this one: http://www.jenitennison.com/xslt/grouping/.

Your alternative is to use XSLT 2.0, which has new elements for grouping built into the language, but you would have to use a transformer which supported XSLT 2.0 if you chose that option.
 
arulraj michealraj
Greenhorn
Posts: 28
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul.. Thanks for your help..... I am using XSL1.0. Acutually i cannot change the version to 2.0,as there are so- many xsl files depdend on 1.0.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic