Re: [xsl] From 2 original xmls to 1.

Subject: Re: [xsl] From 2 original xmls to 1.
From: "Raffaele Sena" <raff@xxxxxxxxxxxx>
Date: Thu, 12 Dec 2002 18:10:54 -0800
> Hi again,
> can someone tell me if there is possible to merge 2 xml files?
> I need to insert some tags from "B xml file" and others from "A xml file" in
> a resulting "xml final file"
> It's possible?
> 
    You pass one file (A.xml) as the input XML document
    and read the other (in a variable ?) with a "document('B.xml')".

    Or, if you want to be fancy, you create a third file
    that simple contains the first 2:

    <merge>
        <source href="A.xml"/>
        <source href="B.xml"/>
    </merge>

    Use this third file as your input XML document
    and read both original inputs (that you get by querying
    your "configuration" file with a document() function.
    In this way you can apply the same metodology to both document:

    <xsl:template match="/merge">
        <xsl:variable name="source-A" select="document(source[1]/@href"/>
        <xsl:variable name="source-B" select="document(source[2]/@href"/>

        <output>
            <tag-from-A>
                <xsl:value-of select="$source-A/some-tag-from-A"/>
            </tag-from-A>

            <tag-from-B>
                <xsl:value-of select="$source-B/some-tag-from-B"/>
            </tag-from-B>
        </output>
    </xsl:template>

    (I just typed this in, so it may contain errors and stuff).

Hope this helps,

    Raffaele

----------------------------------------------------------------
raff@xxxxxxxxxxxx       (::)       http://www.aromatic.org/~raff
              http://www.aromatic.org/

When I say artist I mean the man who is building things
 -- creating molding the earth -- whether it be the plains of the west
 -- or the iron ore of Penn. It's all a big game of construction
 -- some with a brush -- some with a shovel -- some choose a pen.

                             Jackson Pollock

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


Current Thread