I am quite a newbie in XSLT, and have to perform a transformation from XML to XML. Basically reformatting the file. The XML file bellow is the input, and is normally longer, but as it was irrelevant for the question, I only selected parts of the file. I am also obliged to use XSLT v1.0.
Input file:
<?xml version="1.0" encoding="UTF-8"?>
<transactions>
<transaction>
<transaction_date>01/11/2019</transaction_date>
<customerID>31F9PCQD</customerID>
<giftShop>2</giftShop>
<transactionID>1ygOIpJ6Tf2HB72e</transactionID>
<value currency="gbp">57.43</value>
</transaction>
<transaction>
<transaction_date>01/11/2019</transaction_date>
<customerID>4FI1TAJW</customerID>
<giftShop>1</giftShop>
<transactionID>7Yog0IVnlVbOGIQX</transactionID>
<value currency="gbp">54.12</value>
</transaction>
<transaction>
<transaction_date>01/11/2019</transaction_date>
<customerID>9B237CBO</customerID>
<giftShop>3</giftShop>
<transactionID>DJs5rDV21qeIuKnb</transactionID>
<value currency="gbp">10.09</value>
</transaction>
<transaction>
<transaction_date>01/11/2019</transaction_date>
<customerID>FDCXOH0M</customerID>
<giftShop>2</giftShop>
<transactionID>2lZ75q0FrSpcREjs</transactionID>
<value currency="gbp">49.49</value>
</transaction>
<transaction>
<transaction_date>01/11/2019</transaction_date>
<customerID>9VDK67SH</customerID>
<giftShop>3</giftShop>
<transactionID>CwNGDKipz6ZAE0NZ</transactionID>
<value currency="gbp">36.08</value>
</transaction>
<transaction>
<transaction_date>01/11/2019</transaction_date>
<customerID>BQ0JG15U</customerID>
<giftShop>1</giftShop>
<transactionID>xiFZUFOv8J8zKqyU</transactionID>
<value currency="gbp">19.76</value>
</transaction>
What I'd like to do, is rearrange this file by Shops (so either shop 1 | 2 | 3), and then by dates. The thing is, I really cannot find a way of doing it. I've tried to use the Muenchian grouping method, to avoid replicates of shops and dates, but I cannot manage to select the correct data and put it in the correct shop.
The output xml should have the following structure:
<Transactions>
<Shop id="1">
<Date>
<Transaction>
Transaction and customer details...
</Transaction>
</Date>
<Date>
<Transaction>
Transaction and customer details...
</Transaction>
</Date>
...
</Shop>
<Shop id="2">
<Date>
<Transaction>
Transaction and customer details...
</Transaction>
</Date>
<Date>
<Transaction>
Transaction and customer details...
</Transaction>
</Date>
...
</Shop>
<Shop id="3">
<Date>
<Transaction>
Transaction and customer details...
</Transaction>
</Date>
...
</Shop>
</Transactions>
I'm not sure my question is well formulated or clear, but any guidelines would be much appreciated. Thank you in advance for your time.