[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: merging multiple xml files

Subject: Re: merging multiple xml files
From: Rick Taylor <taylor@xxxxxxxx>
Date: Wed, 04 Jun 2003 14:47:06 -0600
merge multiple xml
You can use a combination of the document() function and sort.

try running this agaist the masterfile:

 <xsl:template match="masterfile">
   <merged>
    <xsl:apply-templates select="document(doc/@filename)/client">
     <xsl:sort select="name"/>
     <xsl:sort select="subclient/name"/>
    </xsl:apply-templates>
  </merged>
 </xsl:template>

 <xsl:template match="@*|node()">
   <xsl:copy>
    <xsl:apply-templates select="@*|node()"/>
   </xsl:copy>
 </xsl:template>


-rick



At 02:36 PM 6/4/03 -0500, you wrote:





I have multiple xml files that I wish to merge. An example of the files is
below.  Note that a file
may contain thousands of <detail> nodes.  I want to merge them so that the
clients are grouped together
I have been using a master xml file to try and merge but with no success in
keeping the clients together.
Also, due to the size of the files, is using xsl:copy and xsl:copy-of the
best way to approach this.

Thanks
.

<masterfile>
      <doc filename="file1.xml"/>
      <doc filename="file2.xml"/>
      <doc filename="file3.xml"/>
</masterfile>

<client>
      <name>A</name>
      <subclient>
            <name>a</name>
            <detail>....</<detail>
            <detail>....</<detail>
      </subclient>
</client>

<client>
      <name>A</name>
      <subclient>
            <name>b</name>
            <detail>....</<detail>
            <detail>....</<detail>
      </subclient>
</client>

<client>
      <name>B</name>
      <subclient>
            <name>c</name>
            <detail>....</<detail>
            <detail>....</<detail>
      </subclient>
</client>

<merged>
      <client>
            <name>A</name>
            <subclient>
                  <name>a</name>
                  <detail>....</<detail>
                  <detail>....</<detail>
            </subclient>
            <subclient>
                  <name>b</name>
                  <detail>....</<detail>
                  <detail>....</<detail>
            </subclient>
      </client>
      <client>
            <name>B</name>
            <subclient>
                  <name>c</name>
                  <detail>....</<detail>
                  <detail>....</<detail>
            </subclient>
      </client>
</merged>


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list

Rick Taylor XML Developer PPDM Association


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.