merge of 2 xml files

Discussion in 'XML' started by John Huntjens, Sep 14, 2003.

  1. Ive tried so many things that it drives me crazy: a want to merge / join 2
    xml files like this:

    merge.xml:

    <?xml version="1.0"?>
    <merge>
    <appxml>testapp.xml</appxml>
    <userxml>user.xml</userxml>
    </merge>

    testapp.xml:

    <app name="testapp" lifetime="900">
    <mainmenu>
    <menu id="1" caption="test"/>
    <menu id="2" caption="another test"/>
    </mainmenu>
    <forms>
    <testform autosize="1"/>
    <testform2 autosize="0"/>
    </forms>
    </app>

    user.xml:

    <app lifetime="100">
    <mainmenu>
    <menu id="2" caption="my test"/>
    <menu id="3" caption="my menu"/>
    </mainmenu>
    <forms>
    <testform2 autosize="1"/>
    </forms>
    </app>

    the result must be:

    <app name="testapp" lifetime="100">
    <mainmenu>
    <menu id="1" caption="test"/>
    <menu id="2" caption="my test"/>
    <menu id="3" caption="my menu"/>
    </mainmenu>
    <forms>
    <testform autosize="1"/>
    <testform2 autosize="1"/>
    </forms>
    </app>

    What i have so far:

    <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <xsl:eek:utput method="xml" version="1.0" encoding="utf-8" indent="yes"/>

    <xsl:template match="merge" >

    <xsl:variable name="app_xml" select="string(appxml)" />
    <xsl:variable name="user_xml" select="string(userxml)" />

    <xsl:call-template name="domerge">
    <xsl:with-param name="app_nodes" select="document($app_xml)" />
    <xsl:with-param name="user_nodes" select="document($user_xml)" />
    </xsl:call-template>

    </xsl:template>

    <xsl:template name="domerge">
    <!-- what the heck must be here? -->
    </xsl:template>

    </xsl:stylesheet>

    Who can help, give a hint or a pointer?

    Any help appriciated

    John
    John Huntjens, Sep 14, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Luke Airig
    Replies:
    1
    Views:
    915
    Patrick TJ McPhee
    Dec 16, 2003
  2. Luke Airig
    Replies:
    0
    Views:
    631
    Luke Airig
    Dec 21, 2003
  3. Eirik Eldorsen

    [Ant] Merge two xml files

    Eirik Eldorsen, Jan 24, 2004, in forum: XML
    Replies:
    1
    Views:
    6,302
    Brian Agnew
    Apr 12, 2004
  4. Kjetil Finsrud

    Merge two different xml files into one

    Kjetil Finsrud, Nov 23, 2004, in forum: XML
    Replies:
    0
    Views:
    1,181
    Kjetil Finsrud
    Nov 23, 2004
  5. J
    Replies:
    0
    Views:
    338
Loading...

Share This Page