Subject:XML-to-XML Transformation Author:Everett T Date:21 Dec 2005 10:44 AM
I am a newbie to XSLT and I'm trying to do something that is somewhat non-standard.
My original XML is formatted in the following manner:
<?xml version= '1.0' ?>
<Bills>
<Bill No="10030" Name="John Doe">
.
. some other XML
.
</Bill>
<Bill No="10009" Name="Jane Jones">
.
. some other XML
.
</Bill>
<Bill No="10100" Name="Bob Smith">
.
. some other XML
.
</Bill>
<Bill No="10030" Name="John Doe">
.
. some other XML
.
</Bill>
</Bills>
I would like to transform it into XML that looks like the following:
<?xml version= '1.0' ?>
<Bills>
<Bill No="10009" Name="Jane Jones" NewBill="1">
.
. some other XML
.
</Bill>
<Bill No="10030" Name="John Doe" NewBill="1">
.
. some other XML
.
</Bill>
<Bill No="10030" Name="John Doe" NewBill="0">
.
. some other XML
.
</Bill>
<Bill No="10100" Name="Bob Smith" NewBill="1">
.
. some other XML
.
</Bill>
</Bills>
Basically, I'm trying to, first, sort all of the Bill tags by the @No attribute. After sorting, I want to go through and add a @NewBill attribute that distinguished whether or not the @No attribute has changed. In the example output above I use a "1" when it is a new bill and a "0" if the @No attribute is the same as the previous bill.