This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: union elements in multiple xml documents


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@informatik.hu-berlin.de             |
|  op|qo        WWW:    http://www.informatik.hu-berlin.de/~obecker |
\-------------------------------------------------------------------/


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]