[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Re: document()

Subject: Re: Re: document()
From: "Jonathan Perret" <jonathan@xxxxxxxxxxxx>
Date: Wed, 13 Feb 2002 15:32:36 +0100
Re:  Re: document()
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@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>

> 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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.