I have a XML file which was generated from a SQL table. And I need to transform the XML into my desired output XML.
Input XML:
<rowset>
<row>
<aaa>123</aaa>
<bbb>James</bbb>
<ddd>Large</ddd>
<eee>Black</eee>
<ddd>456213</ddd>
</row>
<row>
<aaa>123</aaa>
<bbb>James</bbb>
<ddd>Large</ddd>
<eee>Blue</eee>
<ddd>456213</ddd>
</row>
<row>
<aaa>123</aaa>
<bbb>James</bbb>
<ddd>small</ddd>
<eee>Black</eee>
<ddd>456213</ddd>
</row>
<row>
<aaa>123</aaa>
<bbb>James</bbb>
<ddd>small</ddd>
<eee>blue</eee>
<ddd>456213</ddd>
</row>
<row>
<aaa>321</aaa>
<bbb>William</bbb>
<ddd>Large</ddd>
<eee>White</eee>
<ddd>555555</ddd>
</row>
<row>
<aaa>321</aaa>
<bbb>William</bbb>
<ddd>Large</ddd>
<eee>Yellow</eee>
<ddd>555555</ddd>
</row>
<row>
<aaa>321</aaa>
<bbb>William</bbb>
<ddd>small</ddd>
<eee>White</eee>
<ddd>555555</ddd>
</row>
<row>
<aaa>321</aaa>
<bbb>William</bbb>
<ddd>small</ddd>
<eee>Yellow</eee>
<ddd>555555</ddd>
</row>
</rowset>
Output XML:
<?xml version="1.0" encoding="utf-8"?>
<tXML xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:user="urn:my-scripts">
<product product-id = "123">
<Name>James</Name>
<Image>
<Image image-view-type = "Large" image-color = "Black">
<Image image-view-type = "Large" image-color = "Blue">
<Image image-view-type = "small" image-color = "Black">
<Image image-view-type = "small" image-color = "Blue">
</Image>
<DeptCode>456213</DeptCode>
</product>
<product product-id = "321">
<Name>William</Name>
<Image>
<Image image-view-type = "Large" image-color = "White">
<Image image-view-type = "Large" image-color = "Yellow">
<Image image-view-type = "small" image-color = "White">
<Image image-view-type = "small" image-color = "Yellow">
</Image>
<DeptCode>555555</DeptCode>
</product>
</tXML>
How to write XSLT for this. Please note Products are many. so there will be thousands of products.
No comments:
Post a Comment