XSLT Stylesheet Editor Quick Tour

When you use the Stylus Studio XSLT stylesheet editor, you work with XSLT stylesheets, XML source documents, and result documents. This quick tour is organized to introduce you to some of the main features for working with XSLT in Stylus Studio:

Parts of the XSLT Editor

The XSLT Editor consists of four tabs that allow you to work with XSLT in different ways, based on your preferences and the functionality that you desire.

  • XSLT Source. Use the XSLT Source tab when you want to directly edit or view the XSLT source code that comprises your stylesheet. The XSLT Source tab can also be a good way to learn more about XSLT - you can see how changes you make to the XSLT using graphical editors, such as the WYSIWYG tab, affect the source.

Tip

 

XSLT source is also visible from a pane within the Mapper tab.

  • Mapper. The Mapper tab allows you to create XSLT by graphically mapping source document nodes to nodes in a target document. Stylus Studio interprets the mappings to generate XSLT that will yield a document conforming to the document described in the Set Target Document pane.

Note

 

Using the Mapper tab is discussed in detail in Using the XSLT Mapper - Getting Started.

  • Params/Other. You use the Params/Other tab to specify the encoding Stylus Studio uses to store the stylesheet, the stylesheet's output method, and the encoding Stylus Studio uses for the document that results from applying this stylesheet. You can also use this tab to view default values for parameters used by your stylesheet.
  • WYSIWYG. The WYSIWYG tab allows you to compose HTML by dragging and dropping XML document elements and attributes. The WYSIWYG tab tool bar lets you easily format text, create tables, build lists, and Stylus Studio automatically generates the XSLT instructions that output the content you define on the tab.

Exploring the XSLT Source Tab

This topic is part of a sequence. If your-quotes.xsl is not open, see Opening a Sample Stylesheet.

To work with the XSLT Source tab:
1. In the stylesheet text, click anywhere below the third xsl:template instruction (line 11).

In the status bar just below the XSLT Editor tool bar, Stylus Studio displays match: /. This indicates that the location you clicked is inside a template that matches the root node.

Figure 21. Current Template Identity Is Displayed at the Top of the Editor

2. Click in the xsl:stylesheet instruction (line 5).

Now the status bar is blank. This instruction is not part of a template.

3. In the XSLT Editor tool bar, click Add a new template .

Stylus Studio inserts the following after the last template already specified in the stylesheet.

<xsl:template match="NewTemplate">
</xsl:template>

To define a new template, replace NewTemplate with the match pattern you want, and add contents to the new template as needed.

Tip

 

You can also create a new template by double-clicking a node on the schema tree. Templates that match nodes in the XSLT document are displayed with a check in the schema tree, as shown here.

Yellow indicates that the text cursor in the XSLT source is within that template.

4. In the XSLT Editor tool bar, click Template Mode , which is the right most button.

Stylus Studio displays only the new template.

Figure 22. Use Template Mode to Focus on a Single Template

You can edit the stylesheet in either template mode or in full source mode. In template mode, Stylus Studio displays one template at a time. In full source mode, Stylus Studio displays the whole stylesheet.

Tip

 

In large or complex stylesheets, use the XSLT Editor's status bar to identify the current template.

5. In the upper right corner of the editing pane, click the down arrow.

Stylus Studio displays a list of the templates in the stylesheet with their match patterns.

Figure 23. You Can Show Individual Templates in a Stylesheet

6. Click match: *|/. This displays the template that matches every element and the root node.

Every stylesheet that Stylus Studio creates includes two built-in templates. One built-in template matches every element and the root node. The other built-in template matches all text and attribute nodes. See Using Stylus Studio Default Templates.

To delete a template, click the match pattern for the template you want to delete and then click Delete template in the XSLT Editor tool bar. You must be in template mode to delete a template.

7. Click Full Source Mode .

Stylus Studio displays the complete stylesheet. The cursor is at the beginning of the template that was being displayed in template mode.

Exploring the Params/Other Tab

Click the Params/Other tab:

Drop-down menus let you specify the encoding format used to store the stylesheet in Stylus Studio, as well as method and encoding output attributes. A simple grid displays the name, source URL, and default value of any global parameters used by the active stylesheet, as well as by any imported ones.

Figure 24. Specify XSLT Parameters Here or in XSLT Source

All information that you can specify in the Params/Other tab can also be specified in the XSLT source. For example, you can specify the XSLT encoding in the processing instruction at the beginning of the stylesheet; you can specify the output method and encoding with the xsl:output instruction. Stylus Studio automatically updates the XSLT source with any changes you make in the Params/Other tab, and vice versa.

Exploring the WYSIWYG Tab

 

The XSLT Editor WYSIWYG tab is available only in Stylus Studio XML Entperprise Suite and Stylus Studio XML Professional Suite.

The WYSIWYG tab is a graphical XSLT editor that lets you compose XSLT by constructing the HTML document you want the XSLT to output.

To work with the WYSIWYG tab:
1. Click the WYSIWYG tab.

Stylus Studio displays a message that indicates that the output of the stylesheet is unspecified and asks you if you want to make it HTML. When the output is HTML (or XML), you can edit the stylesheet in the WYSIWYG HTML editor.

2. Click Yes to make the stylesheet's output HTML.

Stylus Studio displays the WYSIWYG tab.

Figure 25. XSLT Editor WYSIWYG Tab

See Stylesheets That Generate HTML - Getting Started to learn more about using the XSLT WYSIWYG editor.

 
Free Stylus Studio XML Training:
W3C Member