Creating a Template That Matches the book Element

This topic is part of a sequence that starts with Creating a New Sample Stylesheet.

The template that matches the root node includes an xsl:apply-templates instruction that selects book nodes for processing.

To define the template that matches the book element:
1. In the XSLT editor source document tree pane, expand the bookstore element.
2. Double-click the book element.

Stylus Studio creates a template that matches the book element. The new template is near the end of the stylesheet and has the form <xsl:template match="book">. In the tree pane, the yellow check next to the book element indicates that there is a template that matches this element.

3. In the XSLT editor pane, add the following instructions to the new template's body:
<tr>
               
<td><xsl:apply-templates select="title"/></td>
               
<td><xsl:apply-templates select="author"/></td>
               
<td align="right"> 
               

            
<xsl:apply-templates select="price"/>
               

              
</td>
                   
</tr>
                   

                

Press F5 to see the results. The result document looks like that shown in Figure 213:

Figure 213. Result of Applying XSLT

In the book template, the xsl:apply-templates instructions cause the XSLT processor to instantiate the default templates. For the title and price elements, this works correctly because those elements include only a text node. But for the author element, the use of the default templates copies too much information to the result table. You need to explicitly define a template for the author element.

EDI to XML Mapping in Stylus Studio

Learn how to use Stylus Studio's EDI to XML mapping tools in Convert-to-XML, including loading an EDI file, inspecting application control codes, customizing XML output and other advanced EDI to XML mapping features.

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.

Whitepaper: FIXML - Working with Complex Message Sets Defined Using XML Schema

The advanced XML Schema handling and presentation capabilities of Stylus Studio have valuable implications for users of industry-specific XML message sets.

Using DataDirect XML Converters

Learn how to use DataDirect XML Converters and the Stylus Studio Java Code Generator to deploy the XQuery applications you build in Stylus Studio to a live server environment.

Stylus Most Wanted

 
Free Stylus Studio XML Training:
W3C Member