How to derive Annual Salary
Hi I am relatively new to XSLT (used to procedural programming languages) but finding it difficult to understand how I can accomplish that in XSLT and will appreciate any help:
The xml, I want to transform follows - Is nothing more than a listing of employees with their monthly salary changes. The objective is to determine the annual salary for 2015.
<?xml version='1.0' encoding='UTF-8'?>
<employees>
<employee>
<id>E1</id>
<hiredt>2000-01-01</hiredt>
<salaryhistory>
<change>
<efffrom>2000-01-01</efffrom>
<monthlypay>4000</monthlypay>
</change>
<change>
<efffrom>2014-01-01</efffrom>
<monthlypay>5000</monthlypay>
</change>
<change>
<efffrom>2015-02-01</efffrom>
<monthlypay>6000</monthlypay>
</change>
<change>
<efffrom>2015-07-01</efffrom>
<monthlypay>7000</monthlypay>
</change>
</salaryhistory>
</employee>
<employee>
<id>E2</id>
<hiredt>2015-03-01</hiredt>
<salaryhistory>
<change>
<efffrom>2015-03-01</efffrom>
<monthlypay>5000</monthlypay>
</change>
</salaryhistory>
</employee>
</employees>
To be transformed to
=============
The objective is to compute the annual salary for all employees for 2015
<employees>
<employee>
<id>E1</id>
<annualsal>77000</annualsal>
</employee>
<employee>
<id>E2</id>
<annualsal>50000</annualsal>
</employee>
<employee>
<id>E2</id>
<annualsal></annualsal>
</employee>
</employees>
-- explanation on the computation.
========================
Computation for E1
5000 * 1 month = 5000
6000 * 5 months = 30000
7000 * 6 months = 42000
Total 77000
Computation for E1
5000 * 10 months = 50,000 employee started on March 1,2015 and should only be paid for 10 months.
|