Updating Stylesheets

You can edit a stylesheet in the XSLT Source tab in Full Source mode or Template mode. To display a particular template in either mode, click the down arrow in the upper right corner of the editing pane. This displays a drop-down list of template match patterns. Click the template you want to view.

The XSLT editor keeps track of your XSLT context. That is, it keeps track of template match patterns, and any xsl:for-each element that affects the context on which the stylesheet is working. The editor uses Stylus Studio's Sense:X technology to help you create XPath expressions whenever they are needed.

After you associate the stylesheet with a scenario, you can display the source tree for the XML source document specified in the scenario. Click Source Tree in the XSLT editor tool bar. This tree provides a description of the structure of the XML source document specified in the scenario. This tree does not include elements and attributes that are not instantiated in the particular source document. However, the tree provides a structure that you can examine to help you understand stylesheet behavior in a given scenario.

Editing tools

The following sections describe the Stylus Studio editing tools:

Dragging and Dropping from Schema Tree into XSLT Editor

From the source tree of the XSLT editor, you can drag an element or attribute into the XSLT Source pane. If you drop the node in the stylesheet so that it is in a template, Stylus Studio displays the following choices:

  • xsl:for-each
  • xsl:value-of
  • xsl:apply-templates
  • node_name

Click the instruction you want to create. The XSLT context into which you drop the node determines the value of the select attribute in the instruction you choose. The select attribute always selects the node you dragged into the stylesheet. If you choose node_name, Stylus Studio simply inserts the name of the element or attribute you dragged in. This is convenient for pasting long element or attribute names.

If you drop the node in the stylesheet so that it is not in a template, Stylus Studio creates a new template. In the new template, the value of the match attribute is the name of the node you dragged into the stylesheet.

Double-clicking

You can also create a new template by double-clicking a node in the source tree. The difference between double-clicking a node and dragging a node is that when you double-click a node to create a template, Stylus Studio always inserts the template at the end of the stylesheet. When you drag a node to create a template, you determine the location of the template.

Using Sense:X Automatic Tag Completion

The Stylus Studio Sense:X automatic tag completion system helps you edit XSLT, HTML, and FO (formatting objects) instructions. Stylus Studio has built-in knowledge of all XSLT, HTML, and FO tags, as well as their attributes.

As you type in the XSLT edit window, Stylus Studio prompts you with a list of tag or attribute names that match the first few letters you typed. To complete the tag name you are typing, scroll the list if necessary, and double-click the tag you want.

You can customize the Sense:X system. Edit languages.xml in the Stylus Studio bin\Plugins\Configuration Files directory to customize the tag list.

To set options that specify Sense:X behavior, see Options - General - Editor General.

Using Sense:X to Ensure Well-Formed XML

Sense:X also helps you write well-formed XML. There is an option in the Editor General page that is set by default. This is Auto-Close Open Tag When Typing '</'. This means that as soon as you type </, Stylus Studio immediately inserts the only tag that can possibly be closed at that point.

If you prefer, you can turn off this option. Then, when you start to type a closing tag, the Sense:X list displays the only valid closing tag. Double-click it to insert it.

Using Standard Editing Tools

Standard editing tools are available to you for updating stylesheets. From the Edit menu or tool bar you can cut, copy, paste, replace, undo, redo, select all, and find. The usual keyboard shortcuts work as well:

  • Ctrl+X cuts highlighted text.
  • Ctrl+C copies highlighted text.
  • Ctrl+V pastes text.
  • Ctrl+Z undoes the most recent action that has not already been undone.
  • Ctrl+Y redoes the most recently undone action that has not already been redone.

For additional shortcuts, see Keyboard Accelerators.

 
Free Stylus Studio XML Training:
W3C Member