Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 28th, 2006, 05:35 PM
Registered User
 
Join Date: Nov 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default XML to XML transform

Hi!

I am trying to transform one XML format to another using a stylesheet.

Original XML:

<?xml version="1.0" encoding="UTF-8"?>
<dataset>
  <table name="Table1">
    <column>Column1</column>
    <column>Column2</column>
    <column>Column3</column>
    <row>
      <value>Value1</value>
      <null />
      <value>Value3</value>
    </row>
</table>
</dataset>

Output XML:
<DataSet>
    <ROW NUM="1">
        <Column1>
            <![CDATA[Value1]]>
        </Column1>
        <Column3>
            <![CDATA[Value3]]>
        </Column3>
    </ROW>
</DataSet>

Here is the xsl file I got so far, which is not exactly what I want:


<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:output method="xml" indent="yes" />
    <xsl:template match="/">
        <DataSet>
            <xsl:for-each select="dataset/table/row">
               <ROW NUM="{position()}">
                 <xsl:for-each select="../column">
                   <xsl:element name="{//column}">
                    </xsl:element>
                   </xsl:for-each>
               </ROW>
           </xsl:for-each>
        </DataSet>
    </xsl:template>
</xsl:stylesheet>

Any suggestions would be greatly appreciated.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Transform xml to xml changing one tag. surfer97301 XSLT 2 April 21st, 2010 05:14 PM
XML to XML transform (Simplified) nmahesh567 XSLT 2 March 24th, 2007 07:57 AM
XSLT read through XML to transform another XML dendenx2 XSLT 8 July 7th, 2005 08:18 PM
Transform XML to XML wene XSLT 8 December 17th, 2004 11:28 AM
Transform XML to XML using XSLT Mr.D XSLT 2 September 7th, 2004 02:13 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.