My guess is you'd need apply-templates to get the elements in the same order. Wasn't going to post this, since it didn't totally apply but anyways:
generic element -> attribute template
-
<?xml version="1.0" encoding="UTF-8"?>
-
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>
-
<xsl:template match="*">
-
<xsl:copy>
-
<xsl:for-each select="*[not(*)]">
-
<xsl:attribute name="{name()}"><xsl:value-of select="."/></xsl:attribute>
-
</xsl:for-each>
-
<xsl:apply-templates select="*[*]"/>
-
</xsl:copy>
-
</xsl:template>
-
</xsl:stylesheet>
-
Specific to your problem:
1. Since you're getting rid of the namespace, replace
<xsl:copy> with <xsl:element name="local-name()">
2. Remove unnecessary nodes: eg CL, etc... seperated by |
<xsl:template match="CL|OtherNode|etc"/>
3. Have custom templates accordingly:
-
xmlns:w3="http://www.w3.org/2001/xmlns"
-
...
-
<xsl:template match="w3:Batch">
-
<INFO>
-
<xsl:apply-templates/>
-
</INFO>
-
</xsl:template>
-
<xsl:template match ="w3:Claimant">
-
<CONTACT type="{type/text()}" name="{name/text()}"/>
-
</xsl:template>
-
<xsl:template match="w3:Insured"><!-- remove this node, but continue on. -->
-
<xsl:apply-templates/>
-
</xsl:template>
-
Don't know where you're getting loss details from. Assuming it's somewhere else in unposted source code.