Controlling the Contents of the Result Document

This section highlights some of the XSLT instructions you can specify in a stylesheet to control the contents of the result document. This section discusses the following topics:

Specifying Result Formatting

In a stylesheet, you can specify that the XSLT processor should format the result as XML, HTML, or text. Table 48 describes the XSLT processor output for each alternative:

Result Format
XSLT Processor Output
XML
Well-formed XML.
HTML
Recognized HTML tags and attributes that are formatted according to the HTML 4.0 specification. Most browsers should be able to correctly interpret the result. It is your responsibility to ensure that the result is well-formed HTML. For example, <BR> elements should not have child nodes.
Text
All text nodes in the result in document order.
Table 48. Output Based on Result Format

See xsl:output for information about specifying formatting in a stylesheet.

Creating New Nodes in the Result Document

The simplest way to create new nodes in a result document is to specify them as literal result elements or literal result text in a stylesheet template. For example:

<xsl:template match="/">
               

              
<html><head></head><body><table>
                   
<tr><th>Title</th><th>Author</th><th>Price</th></tr>
                   
...
                   
</table></body></html>
                   

                
</xsl-template>

This template creates many nodes in the result document that were not in the source document.

You can also use XSLT instructions to create new nodes. Typically, you use XSLT instructions when you need to compute the name or value of the node. You can find information about using the following instructions in the XSLT Instructions Quick Reference:

You can use the xsl:value-of instruction to provide the contents for a new node. You can also create a new node by copying the current node from the source document to the result document. The current node is the node for which the XSLT processor instantiates a template. See xsl:copy.

Controlling White Space in the Result

For readability, XML documents (both source documents and stylesheets) often include extra white space. White space in XML documents includes spaces, tabs, and new-line characters. Because this white space is for readability, it receives special treatment.

Text nodes that contain only white space are

  • Preserved as normal text nodes in a source document
  • Ignored in a stylesheet, unless the parent node is xsl:text
Significant white space

Stylus Studio recommends that you specify xsl:text in a stylesheet whenever you want to create significant white space in the result. Significant white space is white space that you want to appear in the result in exactly the way that you specify.

To obtain white space for readability during output formatting, specify the xsl:output instruction with the indent attribute. Default values are yes for HTML, and no for XML. With Stylus Studio, you can select the Indent check box on the Params/Other tab to display indented output instead of one long string. Note that the value of the indent attribute, if specified in the stylesheet, has precedence over the Indent option.

Validating EDIFACT Documents with XML Schemas

Either before or after transforming EDIFACT content, generated XML Schemas will make sure that we have all of the necessary components, our codes are all according to the standard codelists, and every little delimiter is in the right place.

DTD Generator

Stylus Studio's DTD Generator supports the automatic generation and association of both internal and external DTDs based on XML instance documents.

XML Helps Uncork Innovative Winery Web Sites

Learn how Freerun Technologies, Inc., a leading Internet services provider used Stylus Studio and XML technologies to develop a framework for Web-based eCommerce applications for the wine industry, reducing development cycles.

Technology Companies That Use Stylus Studio

Technology companies can't always handle every technology that they come across. That's why when it comes to XML, they look to Stylus Studio to guide them. Check out which top technology companies are looking to the future with Stylus Studio.

Stylus Most Wanted

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.