xsl-list
[Top] [All Lists]

need help on referencing

2003-11-13 23:19:22
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[(_at_)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



<Prev in Thread] Current Thread [Next in Thread>