This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Re: document()
- From: "Jonathan Perret" <jonathan at holylabs dot com>
- To: <xsl-list at lists dot mulberrytech dot com>
- Date: Wed, 13 Feb 2002 15:32:36 +0100
- Subject: Re: [xsl] Re: document()
- References: <200202130730.CAA20922@biglist.com> <3C6A5DDE.62124197@oucs.ox.ac.uk>
- Reply-to: xsl-list at lists dot mulberrytech dot com
Stuart,
If you need to access the input document when the context is inside
another document, there is a simpler way through the use of a variable :
<xsl:transform [blah blah]>
<xsl:variable name="root" select="/" />
<xsl:template match="foo">
<xsl:for-each select="document('someOtherDoc.xml')>
<!-- We move the context into some other doc -->
<xsl:for-each select="$root">
<!-- And here we are back in the original (whatever it is) -->
</xsl:for-each>
</xsl:for-each>
</xsl:template>
</xsl:transform>
Simpler and almost certainly faster (the input document does not have
to be parsed twice). And you don't need to pass an external parameter.
Cheers,
--Jonathan
----- Original Message -----
From: "Stuart Brown" <stuart.brown@computing-services.oxford.ac.uk>
> It might not be the most sophisticated solution, but I define a global
parameter
> docURI, use references to this, and pass the value to the processor at the
> command line, thus:
>
> <xsl:transform [blah blah]>
> <xsl:param name="docURI">index.xml</xsl:param><!-- My default -->
> <xsl:template match="foo">
> <xsl:for-each select="document('someOtherDoc.xml')>
> <!-- We move the context into some other doc -->
> <xsl:for-each select="document($docURI)">
> <!-- And here we are back in the original (whatever it is) -->
> </xsl:for-each>
> </xsl:for-each>
> </xsl:template>
> </xsl:transform>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list