I am very new to XSLT and am struggling to get the below done. I am trying to reduce the number hierarchies in a XML document by adding the node names as additional nodes. I am unable to write the correct XSLT though. Also, is there any other way of achieving this(without XSLT, any tools?) ?
Appreciate any help in this. Thanks.
Input XML:
<Rates>
<Rate1>
<Current>
<onsite>100</onsite>
<net>100</net>
<gross>100</gross>
</Current>
<Past>
<onsite>100</onsite>
<net>100</net>
<gross>100</gross>
</Past>
</Rate1>
<Rate2>
<Current>
<onsite>2100</onsite>
<net>2100</net>
<gross>2100</gross>
</Current>
<Past>
<onsite>2100</onsite>
<net>2200</net>
<gross>1200</gross>
</Past>
</Rate2>
</Rates>
Expected Output:
<Rates>
<Rate>
<RateType>Rate1</RateType>
<RateHistory>Current</RateHistory>
<onsite>100</onsite>
<net>100</net>
<gross>100</gross>
</Rate>
<Rate>
<RateType>Rate1</RateType>
<RateHistory>Past</RateHistory>
<onsite>100</onsite>
<net>100</net>
<gross>100</gross>
</Rate>
<Rate>
<RateType>Rate2</RateType>
<RateHistory>Current</RateHistory>
<onsite>2100</onsite>
<net>2100</net>
<gross>2100</gross>
</Rate>
<Rate>
<RateType>Rate2</RateType>
<RateHistory>Past</RateHistory>
<onsite>2100</onsite>
<net>2200</net>
<gross>1200</gross>
</Rate>
</Rates>