Well I've seen many times question and answers, about converting for instance a ADO persisted recordset that will use a XDR schema with all those attributes, into another XML with elements. But most the answer I've seen, will use a simple approach of converting attributes into elements, using this type of code, that it was one of my first XSLT stylesheets.
<xsl:stylesheet version='1.0'
exclude-result-prefixes=xsl s dt rs z
xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
xmlns:s='uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882'
xmlns:dt='uuid:C2F41010-65B3-11d1-A29F-00AA00C14882'
xmlns:rs='urn:schemas-microsoft-com:rowset'
xmlns:z='#RowsetSchema'>
<xsl:output method=xml indent=yes omit-xml-declaration='no'/>
<xsl:template match=/>
<Orders>
<xsl:apply-templates select=xml/rs:data/z:row/>
</Orders>
</xsl:template>
<xsl:template match = z:row>
<Order>
<xsl:for-each select = '@*'>
<xsl:element name='{name(.)}' >
<xsl:value-of select='.' />
</xsl:element>
</xsl:for-each>
</Order>
</xsl:template>
</xsl:stylesheet>
There are several problem IMHO opinion with this type of approach, first of all the <Orders> and <Order> elements are hardcoded, making this stylesheet only applicable to a particular XML|XDR file. The other is the simplistic approach of one attribute one element. You can say that I could have made the stylesheet in a different format according to the desired output, but the would mean more hardcoded stylesheet that I could not use with other XML|XDR files.
I decide to develop a XSLT stylesheet that makes another XSLT stylesheet that you can apply to the XML/XDR file in order to convert it.
The sequence would be something like this:
1) Change the params.xml file to reflect the desired output.
2) Transform the params.xml file using the genXSLT.xsl
3) Apply the output of this to the XML/XDR file.
On the sample I'm publishing here, I'm converting a file that was persisted from the table orders from the northwind database.
Files included in the attachment:
genXSLT.xsl --> the XSLT stylesheet that generates the conXSLT.xsl based on params.xml
params.xml --> the xml used by the genXSLT.xsl to build the conXSLT.xsl
conXSLT.xsl --> the result of the previous transformation and to be applied to the Orders.xml
orders.xml --> sample xml/xdr file.
output.xml --> the result of the whole process.