This Example Demonstrates how to convert XML attributes into XML elements
 

Here is an XML example, all the data we need is stored as XML attribute so we need to convert into simpler XML format

 <Table>
<Record>
<CompanyData ID="1" Company="James Bond Production" Amount="13"></CompanyData>
</Record>
<Record>
<CompanyData ID="2" Company="Green Cloud" Amount="146"></CompanyData>
</Record>
</Table>

Here is XSLT transformation:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" version="1.0"/>
<xsl:template match="Table">
<Table>
<xsl:for-each select="Record">
<Record> <ID><xsl:value-of select="CompanyData/@ID"/></ID>
<Company><xsl:value-of select="CompanyData/@Company"/></Company>
<Amount><xsl:value-of select="CompanyData/@Amount"/></Amount>
</Record>
</xsl:for-each>
</Table>
</xsl:template>
</xsl:stylesheet>

 Note: XSLT (Extensible Stylesheet Language Transformations) is a language for transforming XML documents into other XML documents or formats

Steps to follow
  • Download and install Advanced ETL Processor [Link]
  • Download and Unzip example [Link]
  • Create a new transformation and open the .ats file

Convert XML attributes to XML tags 

  • Double click on the reader and select source XML file

XML Data Reader

  • Repeat the process for the data writer (Point it at the result.csv file)

XML Data writer

  • Run the transformation by pressing the green arrow.

Press magnifying glass button to amend the XSLT transformation 

XSLT Transformation

 

XML Editor

 

XML Result

Please contact us if you need help with transforming the data

Visit ETL Tools Forum