n2n linking. Call 4 better solution

Subject: n2n linking. Call 4 better solution
From: "Rudolf P. Weinmann" <rudolf.weinmann@xxxxxx>
Date: Thu, 3 Aug 2000 16:41:34 +0200
Hi
I have three xml files. Their elements have relationships with each other.
For example: element <c id="L1"/> of three.xml belongs to the elements with
the ids M1,M2,M3 of two.xml and so on.
In terms of a DTD the attribute LinkedTo is of type IDREFS.
I have written a stylesheet to produce the file output.xml (see below).
Are there more efficient solutions than mine (not using extensions).

Rudolf

input one.xml (primary input for my stylesheet)
<root>
    <a id="N1"/>
    <a id="N2"/>
    <a id="N3"/>
</root>

input two.xml
<root>
    <b id="M1" LinkedTo="N1 N2"/>
    <b id="M2" LinkedTo="N2 N3"/>
    <b id="M3" LinkedTo="N1"/>
</root>

input three.xml
<root>
    <c id="L1" LinkedTo="M1 M2 M3"/>
    <c id="L2" LinkedTo="M2 M3"/>
    <c id="L3" LinkedTo="M1 M3"/>
</root>

output.xml
<root>
    <a id="N1">
        <b id="M1" LinkedTo="N1 N2">
            <c id="L1" LinkedTo="M1 M2 M3"/>
            <c id="L3" LinkedTo="M1 M3"/>
        </b>
        <b id="M3" LinkedTo="N1">
            <c id="L1" LinkedTo="M1 M2 M3"/>
            <c id="L2" LinkedTo="M2 M3"/>
            <c id="L3" LinkedTo="M1 M3"/>
        </b>
    </a>
    <a id="N2" ....... you got the idea

output.xml generated using the following stylesheet

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>

<xsl:import href="CopyUnchanged.xsl"/>
<xsl:output method="xml"/>

<xsl:variable name="Files" select="document('two.xml') |
document('three.xml')"/>

<xsl:template match="a | b">
    <xsl:copy>
        <xsl:apply-templates select="@*"/>
        <xsl:apply-templates/>
        <xsl:apply-templates select="$Files//*[contains(concat('
',@LinkedTo,' '),concat(' ',current()/@id,' '))]"/>
    </xsl:copy>
</xsl:template>

</xsl:stylesheet>

I'm concernded about the performance. Are there better solutions?
_________________________________
Rudolf P. Weinmann
Innovation Process Technology Inc.
Switzerland



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


Current Thread