XSLT - Top-level elements

Top-level elements

The elements described in this section can appear only as children of the root xsl:stylesheet element. They specify options that affect the entire translation of the input file to the output.

 

xsl:output: Select output options
xsl:preserve-space: Preserving white space
 xsl:strip-space: Removing non-significant white space
xsl:import: Use templates from another stylesheet
xsl:key: Create an index to optimize input document access
xsl:decimal-format: Define a numeric format

This optional tag defines what tag format to use in the output file. The default is XML format. This tag must be a child of the root xsl:stylesheet element.

Attributes include:

method

    Values include xml for XML output; html for output as HTML; and text if the output is just ordinary text, not tagged.
version

    Identifies the version of the output method.
omit-xml-declaration

    If the output method is XML, a <?xml...?> processing instruction is written to the output file unless you specify omit-xml-declaration="yes". The default is "no". No XML declaration is written for the other output methods.
indent

    Use indent="yes" to request that XML or HTMl output be indented. Some XSLT processors may not support this option.
encoding

    Specifies the character encoding that will appear in the XML processing instruction, if one is generated. Examples: ISO-8859-1, UTF-8.
doctype-system

    Use this attribute to add a <!DOCTYPE> declaration to generated HTML or XML.

    If you want to generate a SYSTEM document type, set this attribute to the URI containing the DTD.
doctype-public

    If you want to generate a <!DOCTYPE> declaration using a public identifier, set this attribute to the public identifier and also set the doctype-system attribute to the URI corresponding to that public identifier.

Here is an example of an xsl:output element for generating strict XHTML 1.0:

<xsl:output method="xml" encoding="ISO-8859-1" indent="yes"
    doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
    doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"/>

The file generated with these output options will start like this:

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE html PUBLIC
    "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

 

source: http://infohost.nmt.edu/~shipman/doc/xslt/web/top-level-elts.html