Subject: Re: [xsl] FW: I need help with converting XML document different formed XML document. From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Tue, 30 Jun 2009 12:54:13 -0400 |
I need help with converting XML document to a different formed XML document.
I have looked for examples on how to do this and I'm just not finding what I need.
I'm very new to this
and will continue to look for a solution.
If possible can you explain the code.
T:\ftemp>type mike.xml <?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>
</table> </report> </fxf> T:\ftemp>type mike.xsl <?xml version="1.0" encoding="US-ASCII"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<!--this element is different in the result, so catch and process it--> <xsl:template match="tr"> <item> <!--the given attributes are preserved--> <xsl:copy-of select="@*"/> <!--additional attributes are added for each table data element--> <xsl:for-each select="td"> <!--create an attribute out of thin air--> <xsl:attribute name="{@colnum}"> <xsl:value-of select="."/> </xsl:attribute> </xsl:for-each> </item> </xsl:template>
<xsl:template match="@*|node()"><!--identity for all other nodes--> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template>
-- Possible July/August XSLT/XQuery/XSL-FO training in Oakland/CA/USA Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video Video lesson: http://www.youtube.com/watch?v=PrNjJCh7Ppg&fmt=18 Video overview: http://www.youtube.com/watch?v=VTiodiij6gE&fmt=18 G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Male Cancer Awareness Nov'07 http://www.CraneSoftwrights.com/s/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] FW: I need help with converti, Johnson, Mike | Thread | Re: [xsl] FW: I need help with conv, Martin Honnen |
[xsl] FW: I need help with converti, Johnson, Mike | Date | Re: [xsl] FW: I need help with conv, Martin Honnen |
Month |