Given the following XML document:
<?xml version="1.0" encoding="utf-8"?>
<Store>
<Location>
<State>WA</State>
</Location>
<Transaction>
<Category>Fruit</Category>
</Transaction>
<Customer>
<Category>Rewards</Category>
</Customer>
<Document>
<!-- Huge XML blob here -->
</Document>
</Store>
How would I write an XSLT (version 1 or 2) to transform this to the following XML document:
<?xml version="1.0" encoding="utf-8"?>
<Transaction>
<Account>
<Type>Rewards</Type>
</Account>
<Type>
<Department>Fruit</Department>
</Type>
<Document>
<!-- Huge XML blob here -->
</Document>
</Transaction>
?
Basically, I need to rearrange / rename some elements, drop some elements, and copy some elements just as they appear in the original.
- The Store/Location/State element value is dropped.
- The Store/Transaction/Fruit element is moved/renamed to Transaction/Type/Department.
- The Store/Customer/Category is moved to Transaction/Account/Type.
- The Store/Document element is copied along with all of its sub elements unchanged into the result as the Transaction/Document element.