Dear Friends,
Can someone help me translating one xml to another xml using xslt.
Please see below input xml which has name and valueAsString elements where it determine to go what level of element.
Input xml:
<?xml version="1.0" encoding="UTF-8"?>
<outputMessage>
<offers>
<attributes>
<name>type</name>
<valueAsString>pkg</valueAsString>
</attributes>
<attributes>
<name>name</name>
<valueAsString>First package</valueAsString>
</attributes>
<attributes>
<name>id</name>
<valueAsString>P1</valueAsString>
</attributes>
</offers>
<offers>
<attributes>
<name>type</name>
<valueAsString>grp</valueAsString>
</attributes>
<attributes>
<name>parent_id</name>
<valueAsString>P1</valueAsString>
</attributes>
<attributes>
<name>id</name>
<valueAsString>G1</valueAsString>
</attributes>
</offers>
<offers>
<attributes>
<name>type</name>
<valueAsString>ofr</valueAsString>
<valueDataType>string</valueDataType>
</attributes>
<attributes>
<name>parent_id</name>
<valueAsString>P1</valueAsString>
</attributes>
<attributes>
<name>id</name>
<valueAsString>OFR1</valueAsString>
</attributes>
</offers>
<offers>
<attributes>
<name>type</name>
<valueAsString>ofr</valueAsString>
</attributes>
<attributes>
<name>parent_id</name>
<valueAsString>G1</valueAsString>
</attributes>
<attributes>
<name>id</name>
<valueAsString>OFR2</valueAsString>
</attributes>
</offers>
<offers>
<attributes>
<name>type</name>
<valueAsString>ofr</valueAsString>
</attributes>
<attributes>
<name>parent_id</name>
<valueAsString>null</valueAsString>
</attributes>
<attributes>
<name>id</name>
<valueAsString>OFR3</valueAsString>
</attributes>
</offers>
</outputMessage>
Output xml:
<?xml version="1.0" encoding="UTF-8"?>
<offers>
<offer>
<id>OFR3</id>
</offer>
<package ID="P1">
<groups>
<group ID="G1">
<offer>
<ID>OFR2</ID>
</offer>
</group>
</groups>
<offer>OFR1</offer>
</package>
</offers>
Thanks in Advance,
Raju
This is a companion discussion topic for the original entry at https://our.umbraco.com/forum/65025-xml-to-xml-using-xslt