AW: [xsl] 2 XML source

Subject: AW: [xsl] 2 XML source
From: Delaney Robin <Robin.Delaney@xxxxxxx>
Date: Wed, 12 Mar 2003 15:20:35 +0100
Hello David,

I had the same situation. Solution for me was:

1) Create a simple directory listing of the XML's you want to concatonate
(this is platform dependant)
2) Create an XML compatible directory listing from the list created in step
1
3) Concatonate all the files in the listing from step 2 into a single XML
(using document())
4) Transform usign your XSL

I also use xalan.

Here is some code for Steps 2 and 3. You'll probably need to customize
it..........

Step 1)  (WIN solution)

dir *.xml /b >xmlDir.lst

Step 2)
using this XML
	<?xml version="1.0" encoding="ISO-8859-1"?>
	<!DOCTYPE xmlDir [
	<!ENTITY xmlDirList SYSTEM "xmlDir.lst">]>
	<xmlDir>
	&xmlDirList;
	</xmlDir>
and this XSL

	<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
	<xsl:template match="/xmlDir">
	<!-- create our root output element -->
  		<xmlDir>
    			<xsl:call-template name="file">
      			<!-- normalise CRs and line-breaks into single
spaces, plus one on
			the end -->
      				<xsl:with-param name="flist"
				select="concat(normalize-space(string()),'
')" />
    			</xsl:call-template>
  		</xmlDir>
	</xsl:template>
	
	<!-- process the idividual files in the space-separated file list
-->
	<xsl:template name="file">
  	<xsl:param name="flist" />
		<xsl:if test="$flist != ''">
    			<xmlFile><xsl:value-of
select="substring-before($flist, ' ')"
			/></xmlFile>

    			<xsl:call-template name="file">
      			<xsl:with-param name="flist"
select="substring-after($flist, ' ')"
			/>
    			</xsl:call-template>
  		</xsl:if>
	</xsl:template>

</xsl:stylesheet>

you can transform the file list to a "usable" XML using 

java org.apache.xalan.xslt.Process -in xmlDir.xml -xsl xmlDir.xsl -out
xmlFiles.xml

Step 3)
The file XMLfiles.xml from step 2 can then be transformed using this
XSL(xmlconcat.xsl) to give you a single XML. 

(xmlconcat.xsl)
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
	<xsl:template match="/">
		<Concat>
  			<xsl:copy-of select="document(/xmlDir/xmlFile)"/>
  		</Concat>
	</xsl:template>
</xsl:stylesheet>

Transform with 

java org.apache.xalan.xslt.Process -in xmlFiles.xml -xsl xmlConcat.xsl -out
xml2txt.xml

Steps 1 and 2 can be avoided if you can build an XML with the input file
names using another method, however automation makes it
easier...............

Hope this helps !!

Cheers,

Robin
                                                     
Robin Delaney
FJA Feilmeier & Junker GmbH    
Elsenheimerstraße 65,	80687 München.
*   +49 (0) 89 - 76 901-7058
Fax   +49 (0) 89 - 76 901-9502
web  http://www.fja.com
*    Mailto:Robin.Delaney@xxxxxxx	



> -----Ursprüngliche Nachricht-----
> Von:	David Alcantara [SMTP:wwwdavid@xxxxxx]
> Gesendet am:	Mittwoch, 12. März 2003 14:35
> An:	xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Betreff:	AW: [xsl] 2 XML source
> 
> Thank you,
> 
> but it´s  not so simple. :-(
> 
> every day i get approx. 100 XML files like 030312_01.xml (XML name =
> date+position) and i want to have only one XSL :-)
> Because every day other application creates 100's of xml files from which
> i
> need to filter some data out of these files. As you said in your mail that
> to incorporate the xml file names into the XSL File, i think in my case it
> is difficult to type all the file names into the XSL File. So in this case
> I
> request some other solution which suite my need given above.
> maybe is easily make a C program who integreate the 100 xml files in other
> one.
> Is there a way to make C or C++ program.
> 
> Regards
> david
> 
> 
> 
> -----Ursprüngliche Nachricht-----
> Von: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]Im Auftrag von Jarkko
> Moilanen
> Gesendet: Mittwoch, 12. März 2003 12:40
> An: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Betreff: Re: [xsl] 2 XML source
> 
> 
> On Wed, 12 Mar 2003, David Alcantara wrote:
> 
> > Hi,
> >
> > i need to make a new XML file from 2 diferent XML source.
> > It´s possible?
> >
> > Regards
> > david
> >
> > I´m working with xalan 1.4.0
> 
> 
> Yes it is and simple. =)
> Use document() function.
> 
> For example:
> 
> <xsl:value-of select="document('source.xml')/XPath"/>
> 
> would look inside a file source.xml and traverse the tree
> by the given XPath.
> 
> For more information see:
> http://www.w3.org/TR/xslt#document
> 
> Cheers,
> Jarkko.
> 
> >
> >
> >  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> >
> >
> 
> 
> ****************************************************************
> Jarkko Moilanen          "Erehtyminen on inhimillista,
> Researcher                mutta todella suuret mokat
> jm60697@xxxxxx            vaativat tietokoneen käyttöä."
> www.uta.fi/~jm60697
> GSM: +358 50 3766 927
> ****************************************************************
> * ITCM | Information Technology and Crisis Management
> * http://www.itcm.org
> ****************************************************************
> 
> 
> 
> 
> 
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

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


Current Thread