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

merging and regrouping multiple xml files

Subject: merging and regrouping multiple xml files
From: "John Reid" <John.Reid@xxxxxxxxxxxxxxx>
Date: Sat, 6 Sep 2003 18:42:09 +1000
asx xml
I think this is a problem of grouping. I want to tranform a number of
xml files into one. At the same time regrouping them. The masterfile
contains the list of files to be merged and file 08 and file09 give
representative input data. The last list is the desired outcome. I have
looked up this type of problem but..

Salud

John

<masterfile>
       <doc filename="file08.xml"/>
       <doc filename="file09.xml"/>
       <doc filename="file10.xml"/>
       <doc filename="file11.xml"/>
       <doc filename="file12.xml"/>
       <doc filename="file13.xml"/>
       <doc filename="file14.xml"/>
       <doc filename="file15.xml"/>
       <doc filename="file16.xml"/>
       <doc filename="file17.xml"/>
       <doc filename="file18.xml"/>
       <doc filename="file19.xml"/>
       <doc filename="file20.xml"/>
</masterfile>

file08

<xchange>
  <asx>
    <code>AAB</code>
    <date>030905</date>
    <op>88</op>
    <hi>88</hi>
    <lo>88</lo>
    <cl>88</cl>
    <vol>10</vol>
  </asx>
  <asx>
    <code>AAC</code>
    <date>030905</date>
    <op>129</op>
    <hi>129</hi>
    <lo>127</lo>
    <cl>128</cl>
    <vol>99757</vol>
  </asx>
</xchange>

file09
<xchange>
  <asx>
    <code>AAB</code>
    <date>030906</date>
    <op>88</op>
    <hi>88</hi>
    <lo>86</lo>
    <cl>88</cl>
    <vol>20</vol>
  </asx>
  <asx>
    <code>AAC</code>
    <date>030906</date>
    <op>129</op>
    <hi>129</hi>
    <lo>127</lo>
    <cl>128</cl>
    <vol>99888</vol>
  </asx>
</xchange>

Merged OutPut

<merged>
	<asx id="AAB">
		<day id="030905">
    			<op>88</op>
    			<hi>88</hi>
    			<lo>88</lo>
    			<cl>88</cl>
    			<vol>10</vol>
		</day>
		<day id="030906">
    			<op>88</op>
    			<hi>88</hi>
    			<lo>86</lo>
    			<cl>88</cl>
    			<vol>20</vol>
		</day>
	</asx>
	<asx id="AAC">
		<day id="030905">
     			<op>129</op>
    			<hi>129</hi>
    			<lo>127</lo>
    			<cl>128</cl>
    			<vol>99757</vol>
		</day>
		<day id="030906">
     			<op>129</op>
    			<hi>129</hi>
    			<lo>127</lo>
    			<cl>128</cl>
    			<vol>99888</vol>
		</day>
	</asx>
Ken Holman gave the below code for something similar and while I feel
that I should be able to adapt it, I could not.

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

<xsl:output indent="yes"/>

<xsl:template match="masterfile">
   <merged>
     <xsl:variable name="clients"
select="document(doc/@filename)/client"/>

     <xsl:for-each select="$clients">
       <xsl:if test="generate-id(.)=
                     generate-id($clients[name=current()/name])">
         <client>
           <xsl:copy-of select="name"/>
           <xsl:copy-of
select="$clients[name=current()/name]/subclient"/>
         </client>
       </xsl:if>
     </xsl:for-each>
   </merged>
</xsl:template>

</xsl:stylesheet>
</merged>


 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.