Re: union elements in multiple xml documents

Subject: Re: union elements in multiple xml documents
From: Oliver Becker <obecker@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 13 Sep 2000 10:00:50 +0200 (MET DST)
Hi,

> I'm looking into ways to combine more than one xml documents together. 
> For example: I have one xml document:
> <stock ticker="csco">
>    <last />
>    <date />
>    <change />
>    <open />
>    <high />
>    <volume />
> <stock>
> 
> Another xml document:
> <stock ticker="csco">
>    <highest />
>    <lowest />   
>    <average-volume />
> <stock>
> 
> I want to result document has elements from both. Any suggestions anyone?

The fundamental function you're needing here is document().
So, for example, if your file are named stock1.xml and stock2.xml,
you can access the nodes from these XML sources with
document('stock1.xml') resp. document('stock2.xml')

For example you could define a variable
<xsl:variable name="stock1" select="document('stock1.xml')" />

stock1 now contains the root node of the document in stock1.xml
It may be processed in any way you want, e.g.:
<xsl:apply-templates select="$stock1/stock/volume" />

If you just want a union (resp. a conglomerate) of both XML sources,
have a look at my merging tool at
http://www.informatik.hu-berlin.de/~obecker/XSLT/#merge

Cheers,
Oliver


/-------------------------------------------------------------------\
|  ob|do        Dipl.Inf. Oliver Becker                             |
|  --+--        E-Mail: obecker@xxxxxxxxxxxxxxxxxxxxxxx             |
|  op|qo        WWW:    http://www.informatik.hu-berlin.de/~obecker |
\-------------------------------------------------------------------/


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


Current Thread