Original Input XML:
<?xml version="1.0" encoding="UTF-8"?>
<bb3:Reservations xmlns:bb3="http://www.ourbedandbreakfast.com/sample1">
<bb3:Reservation RoomNum="106" InvoiceNum="BB3002">
<bb3:Customer FirstName="Tom" LastName="Cruise" />
<bb3:Customer FirstName="Nicole" LastName="Kidman" />
</bb3:Reservation>
<bb3:Reservation RoomNum="206" InvoiceNum="BB5010">
<bb3:Customer FirstName="Tom" LastName="Cruise" />
</bb3:Reservation>
<bb3:Reservation RoomNum="506" InvoiceNum="BB6020">
<bb3:Customer LastName="Madonna" />
</bb3:Reservation>
</bb3:Reservations>
I want to get a list of all invoice numbers per customer, like below.
Example of Output XML:
<bb3:CustomerVisits>
<bb3:Booking>
<bb3:Customer FirstName="Tom" LastName="Cruise" />
<InvoiceNum>BB3002</InvoiceNum>
<InvoiceNum>BB5010</InvoiceNum>
</bb3:Booking>
<bb3:Booking>
<bb3:Customer FirstName="Nicole" LastName="Kidman" />
<InvoiceNum>BB3002</InvoiceNum>
</bb3:Booking>
<bb3:Booking>
<bb3:Customer LastName="Madonna" />
<InvoiceNum>BB6020</InvoiceNum>
</bb3:Booking>
</bb3:CustomerVisits>
Not sure where to start. I read something about Grouping by 2 levels, but was confused since I am new to XSLT.
Grouping by 2 levels:
http://www.dpawson.co.uk/xsl/sect2/N4486.html#d5891e235