XML Development

Moderators: None (Apply to moderate this forum)
Number of threads: 257
Number of posts: 456

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
transform 3 different nodes into a collection Posted by rhonings on 24 Feb 2005 at 12:34 AM
I want to transform XML-1 to XML-2. The problem is : how do you transform 3 different nodes from XML-1 into an collection of nodes in XML-2.
XML-1 looks like :
<source>
<greentea>yes</greentea>
<earlgreytea>no</earlgreytea>
<normaltea>yes</normaltea>
</source>

The above XML should be transormed into XML-2. XML-2 looks like this :
<target>
<tea>
<flavor>greentea</flavor>
</tea>
<tea>
<flavor>earlgraytea</flavor>
</tea>
<tea>
<flavor>normaltea</flavor>
</tea>
<target>

Anyone, please .... ?
Report
Re: transform 3 different nodes into a collection Posted by infidel on 24 Feb 2005 at 7:45 AM
: I want to transform XML-1 to XML-2. The problem is : how do you transform 3 different nodes from XML-1 into an collection of nodes in XML-2.
: XML-1 looks like :
: <source>
: <greentea>yes</greentea>
: <earlgreytea>no</earlgreytea>
: <normaltea>yes</normaltea>
: </source>
:
: The above XML should be transormed into XML-2. XML-2 looks like this :
: <target>
: <tea>
: <flavor>greentea</flavor>
: </tea>
: <tea>
: <flavor>earlgraytea</flavor>
: </tea>
: <tea>
: <flavor>normaltea</flavor>
: </tea>
: <target>

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <xsl:template match="source">
        <target>
            <xsl:for-each select="*">
                <tea>
                    <flavor><xsl:value-of select="name()"/></flavor>
                </tea>
            </xsl:for-each>
        </target>
    </xsl:template>

</xsl:stylesheet>



infidel

$ select * from users where clue > 0
no rows returned





 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.