xsl-list
[Top] [All Lists]

Re: xsl:for-each and document()

2003-07-21 07:43:53
One solution is to add a namespace for the external document. See below.

On Sunday, July 20, 2003, at 01:02 AM, Casale, Jourdain-Alexander wrote:

Hello,

I'm trying to figure out how to access data in the source XML document
while within a for-each loop of another XML document. Does anybody know
how to accomplish this without doing another document() call to the
source XML document?

source.xml
----------------------------------------------
        <element>
                <child>source doc</child>
        </element>

external.xml
----------------------------------------------
<element>
        <child>external doc</child>
<element>

stylesheet.xslt
----------------------------------------------
...
I can display <xsl:value-of select="/element/child"> here
<xsl:for-each select="document('external.xml')/element/*">

< xsl:for-each select="document('external.xml')/element/*" xmlns:ext="http://some/arbitrary/url";>
        <xsl:value-of select="."/>
        <xsl:value-of select="/element/child"/>

        I can display <xsl:value-of select="."/> here
        Problem: I can't display /element/child on my source.xml unless
I do another document() call
</xsl:for-each>


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



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