Home >Online Product Documentation >Table of Contents >Applying a Stylesheet to Multiple Documents
You can apply the same stylesheet to multiple documents
Scenarios make it easy to view results and apply the same stylesheet to multiple XML documents. A stylesheet can have any number of scenarios. Each scenario is associated with only one stylesheet. In addition to the stylesheet, a scenario is associated with a source XML file. The same XML file can be associated with any number of scenarios.
You create an initial scenario when you create a stylesheet. You can create additional scenarios at any time. See Creating a Scenario.
Each time you generate a different scenario, Stylus Studio displays a tab at the bottom of the Preview window for that scenario. Click the tab for the scenario you want to view. This allows you to compare results.
To apply a stylesheet to multiple documents in one operation, call the document() function in the XPath expression of a template. This function allows you to access another XML document and select nodes from that document for processing as source nodes. See Accessing Other Documents During Query Execution.
document()
For example, you can specify the following:
<xsl:apply-templates select="document('bookstore.xml')/bookstore"
This selects the bookstore root element of the bookstore.xml document.
bookstore
bookstore.xml
Stylus Studio looks for the document in the directory that contains the stylesheet.
The document() function has a lot of overhead. You should call it once and assign the result to a variable with the xsl:variable instruction.
xsl:variable