Creating Templates

To do anything beyond copying the text from your XML document to the result document, you must create templates. You can create new templates several ways:

  • In the source tree of the XSLT editor, double-click the element or attribute for which you want to create a template. Stylus Studio creates an empty template that matches the node you clicked. This template appears at the end of the stylesheet.
  • Click New Template . Stylus Studio creates an empty template whose match pattern is NewTemplate. Replace NewTemplate with a match pattern that has meaning for your stylesheet. The new template appears at the end of the stylesheet.
  • Drag an element or node from the source tree in the XSLT editor to the Full Source pane and drop it in a location that is not in a template. Stylus Studio creates a new template that matches the node you dragged in.
Try creating a new template that matches an XML element in your document:
1. Double-click an element in the tree view of your XML document.
2. Enter the following instruction in the new template:
<b><xsl:value-of select="."/></b>
       

    
3. In another template, ensure that there is an xsl:apply-templates instruction that selects the new template's element for processing.
4. Press F5 to apply the stylesheet and refresh the current scenario in the Preview window.

Notice that the text contents of the element for which you created the template are now displayed in bold - the XSL instruction is formatted with <b> and </b>. Also, the XSLT processor does not process this element's children (if there are any) because the new template you created does not specify <xsl:apply-templates/>.

By creating additional templates to style portions of your XML document, you can completely control how the document appears.

Saving a Template

To save a template, save the stylesheet. Click Save in the Stylus Studio tool bar, or select File > Save from the Stylus Studio menu bar.

Binary XML

How do I get my binary data into XML? How do I get my binary data out of XML? The answers to these questions and more in this amazing Binary XML tutorial.

XML Reports

Build beautiful XML reports from Relational, XML and Legacy Data. You XML report can be rendered in PDF or HTML using XSLT, XQuery or XSL:FO.

Insurance Companies That Use Stylus Studio

Everyone needs insurance, even insurance companies. That's why these top insurance companies are insured when it comes to XML. Come see which insurance providers are insured by the power of Stylus Studio!

XQuery Mapper

Stylus Studio has the industry's only XQuery mapper, enabling you to develop sophisticated XML mappings consisting of queries and data transformation in an intuitive, visual manner.

Stylus Most Wanted

 
Free Stylus Studio XML Training:
W3C Member