Creating an XSLT Scenario

An XSLT scenario is a group of settings that Stylus Studio uses to process the XSLT when you click the Preview Result button ( ). Examples of scenario settings include the XML document to which the XSLT will be applied, whether you want to perform any post-processing, and the values of any parameters you might have defined. You can create multiple scenarios that use the same XSLT, and choose different settings for each. This flexibility can aid the XSLT development process as it enables you to easily test different applications of the XSLT before you put it online.

Even if you do not explicitly create a scenario, Stylus Studio uses default scenario settings in order to preview the XSLT. For example, Stylus Studio uses the first source document you specify as the document to which the XSLT is applied. (If the first source document is an XSD or DTD, Stylus Studio prompts you to provide an XML document for the scenario when you preview the XSLT.)

This section covers the following topics:

Overview of Scenario Features

This section describes the main features of XSLT scenarios. It covers the following topics:

Specifying XML Source Documents

The main benefit of the XSLT scenario feature is that it lets you specify the XML document against which you want to run your XSLT. By default, Stylus Studio uses the first source document you add using the XSLT mapper as the XML source document for the scenario. You can specify the XML source document setting on the General tab of the Scenario Properties dialog box.

Figure 237. General Tab of XSLT Scenario Properties Dialog Box

For more information

See Source Documents to learn more about the process of selecting and working with source documents in XSLT mapper.

Setting Values for Global Parameters

The Parameter Values tab of the Scenario Properties dialog box displays any global parameters you have defined in the XSLT source and allows you to

  • Specify an alternate value to use when running the scenario
  • Indicate whether the value is an XPath expression or a string

For example, imagine the following parameter defined in the XSLT source:

<xsl:param name="my_title" select="'Confederacy of Dunces'"/>
               

            

This parameter is displayed on the Parameter Values tab as follows:

Figure 238. Specifying Alternate Values for XSLT Parameters

If you want to specify an alternate parameter value for this scenario, click the Parameter value to be used when processing entry field. If the alternate value you enter is an XPath expression, click the associated check box.

Tip

 

All global parameters you define for a stylesheet are displayed on the Params/Other tab of the XSLT editor. Parameters displayed on this tab are read-only.

Choosing an XSLT Processor

By default, Stylus Studio uses a built-in processor to process the XSLT you compose. You can select other supported processors on the Processor tab, or use this tab to specify an external or custom processor.

Performance Metrics Reporting

 

Performance metrics reporting is available only in Stylus Studio XML Professional Edition.

Stylus Studio can generate an HTML report that contains information about how your XSLT is being processed. This option is off by default, but you can enable it, and choose options for the report, on the Profiling Options tab.

See Profiling XSLT Stylesheets to learn more about the different ways in which Stylus Studio can provide you with XSLT performance metrics.

Performing Post-Processing

You can use the Post-process tab to specify any optional processing you want performed on the XML after it has been processed by the XSLT.

How to Create a Scenario

To create a scenario:
1. In the XSLT editor toolbar, click .

Alternative: Select Create Scenario from the scenario drop-down list at the top of the editor window.

Stylus Studio displays the Scenario Properties dialog box.

2. In the Scenario name: field, type the name of the new scenario.
3. In the Source XML URL (optional): field, type the name of the XML file to which you want to apply the XSLT, or click Browse to navigate to an XML file and select it.

Note

 

If the first document you added to the XSLT mapper is an XML document, Stylus Studio uses that document as the XML source for the scenario and displays it in this field.

4. In the Output URL field, optionally type or select the name of the result document you want the XSLT document to generate. If you specify the name of a file that does not exist, Stylus Studio creates it when you preview the XSLT.
5. If you want Stylus Studio to Store paths relative to XSLT document path, ensure that this option is checked.
6. If you check Preview result in an external application, Stylus Studio displays the result Internet Explorer. In addition, Stylus Studio always displays XSLT results in the Preview window
7. Optionally, configure settings for global parameters, the XSLT processor you want to use, whether or not you want to run a profiling report, and whether or not you want to perform any post-processing on the XSLT result. See Overview of Scenario Features for more information.
8. To define another scenario, click Add and enter the information for that scenario. You can also copy scenarios. See How to Clone a Scenario.
9. Click OK.

If you start to create a scenario and then change your mind, click Delete and then OK.

How to Run a Scenario

To run a scenario:
1. Select a scenario from the scenario drop-down list at the top of the editor window.

Alternative:

a. In the XSLT editor toolbar, click .

Stylus Studio displays the Scenario Properties dialog box.

b. On the General tab, select the scenario you want to run from the Existing Scenarios list.
c. Click OK.
2. Click the Preview Result button ( ).

How to Clone a Scenario

When you clone a scenario, Stylus Studio creates a copy of the scenario except for the scenario name. This allows you to make changes to one scenario and then run both to compare the results.

To clone a scenario:
1. Display the XSLT in the scenario you want to clone.
2. In the XSLT editor toolbar, click to display the Scenario Properties dialog box.
3. In the Scenario Properties dialog box, in the Existing preview scenarios field, click the name of the scenario you want to clone.
4. Click Clone.
5. In the Scenario name field, type the name of the new scenario.
6. Change any other scenario properties you want to change. See How to Create a Scenario.
7. Click OK.

If you change your mind and do not want to create the clone, click Delete and then OK.

 
Free Stylus Studio XML Training: