[xsl] need help on referencing

Subject: [xsl] need help on referencing
From: Lenny Wu <lenny.wu@xxxxxxxxxxx>
Date: Fri, 14 Nov 2003 01:19:22 -0500
Hi,

i found the following example on one of the older post about referencing from another xml file. I have another question. look below





"tutorial.xml
<tutorial>
    <author idref="1"/>
</tutorial>

author.xml
<authors>
    <author id="1">
        <name>foo</name>
    </author>
    <author id="2">
        <name>bar</name>
    </author>
</authors>

XSL
<xsl:template match="tutorial">
    <xsl:copy>
        <xsl:apply-templates select="author"/>
    </xsl:copy>
</xsl:template>
<xsl:template match="author">
    <xsl:copy>
        <xsl:copy-of select="document('author.xml')/authors/author[@id =
current()/@idref]/name"/>
    </xsl:copy>
</xsl:template>

output should be:
<tutorial>
    <author>
        <name>foo</name>
    </author>
</tutorial>
"

Now my question is, if my xml code is like this :

tutorial.xml (which is transformed)
<tutorial>
    <author> 1 </author>
</tutorial>

author.xml
<authors>
    <author>
           <id> 1 </id>
        <name>foo</name>
    </author>
    <author>
           <id> 2 </id>
        <name>bar</name>
    </author>
</authors>

How would I write my xsl code to reference the other xml file to get the desired output?





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


Current Thread