[xsl] Re: xsl:for-each and document()

Subject: [xsl] Re: xsl:for-each and document()
From: "Dimitre Novatchev" <dnovatchev@xxxxxxxxx>
Date: Sun, 20 Jul 2003 08:07:37 +0200
> I can display <xsl:value-of select="/element/child"> here
> <xsl:for-each select="document('external.xml')/element/*">
> 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>


Set an xsl:variable to the root of the source xml document, then you can
reference it from the scope of any other document, e.g.:

$srcRoot/element/child


=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL



"Casale, Jourdain-Alexander" <jourdain.casale@xxxxxxxxxxx> wrote in message
news:11E242225E17B84D9379ADC352B869772C74@xxxxxxxxxxxxxxxxxxxx
> 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/*">
> 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>
> ...
>
> Thanks for any help in advance!
> Jourdain
>
> Comspec Communications, Inc.
>
> v: +1 416.785.3553 x206
> f: +1 416.785.3668
> m: +1 647.283.3142
> e: jourdain.casale@xxxxxxxxxxx
> w: http://comspec.com
>
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>
>




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


Current Thread