|
Subject: Re: [xsl] FW: I need help with converting XML document different formed XML document. From: Martin Honnen <Martin.Honnen@xxxxxx> Date: Tue, 30 Jun 2009 18:57:59 +0200 |
Example XML Document: <?xml version="1.0" encoding="utf-8"?>
<fxf version="1.0" data="hold"> <report records="1583" lines="1583" > <column_desc> <col colnum="c0" fieldname="test"></col> </column_desc> <table> <tr linetype="data" linenum="1"> <td colnum="c0">01</td> <td colnum="c1">E1c06</td> <td colnum="c2">40797115201</td> </tr> <tr linetype="data" linenum="2"> <td colnum="c0">02</td> <td colnum="c1">E2c06</td> <td colnum="c2">50797115201</td> </tr>
</table> </report> </fxf>
Needed Format: <?xml version="1.0" encoding="utf-8"?>
<fxf version="1.0" data="hold"> <report records="1583" lines="1583" > <column_desc> <col colnum="c0" fieldname="test"></col> </column_desc> <table> <item linetype="data" linenum="1" c0="01" c1=" E1c06" c2="40797115201" ></item> <item linetype="data" linenum="2" c0="02" c1=" E2c06" c2="50797115201" ></item> </table> </report> </fxf>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template> <xsl:template match="tr">
<item>
<xsl:apply-templates select="@* | td"/>
</item>
</xsl:template> <xsl:template match="td">
<xsl:attribute name="{@colnum}">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:template>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template> <xsl:template match="tr">
<item>
<xsl:apply-templates select="@* | td"/>
</item>
</xsl:template> <xsl:template match="td">
<xsl:attribute name="{@colnum}">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:template> <xsl:template match="td[@colnum = 'c1']">
<xsl:attribute name="{@colnum}">
<xsl:value-of select="concat(' ', .)"/>
</xsl:attribute>
</xsl:template>Martin Honnen http://msmvps.com/blogs/martin_honnen/
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] FW: I need help with conv, G. Ken Holman | Thread | [xsl] Search and Replace to add HTM, Sharon_Harris |
| Re: [xsl] FW: I need help with conv, G. Ken Holman | Date | [xsl] Search and Replace to add HTM, Sharon_Harris |
| Month |