YouTip LogoYouTip

El Output


XSLT Element Reference Complete XSLT Element Reference


Definition and Usage

The <xsl:output> element defines the format of the output document.

Note: <xsl:output> is a top-level element and must be a child of <xsl:stylesheet> or <xsl:transform>.


Syntax

<xsl:output
  method="xml|html|text|name"
  version="string"
  encoding="string"
  omit-xml-declaration="yes|no"
  standalone="yes|no"
  doctype-public="string"
  doctype-system="string"
  cdata-section-elements="namelist"
  indent="yes|no"
  media-type="string"/>

Attributes

Attribute Value Description
method xml html text name Optional. Defines the output format. Default is XML (but if the first child node of the root node is <html> and there is no text node before it, the default is HTML). Netscape 6 only supports "html" and "xml".
version string Optional. Sets the W3C version number of the output format. (Only used when method="html" or method="xml".)
encoding string Optional. Sets the value of the encoding attribute in the output.
omit-xml-declaration yes no Optional. "yes" specifies that the XML declaration (<?xml...?>) should be omitted in the output. "no" specifies that the XML declaration should be included in the output. Default is "no".
standalone yes no Optional. "yes" specifies that the XSLT processor should output a standalone document declaration. "no" specifies that the XSLT processor should not output a standalone document declaration. Default is "no". Netscape 6 does not support this attribute.
doctype-public string Optional. Specifies the public identifier to be used in the DTD. That is, the value of the PUBLIC attribute in the DOCTYPE declaration in the output.
doctype-system string Optional. Specifies the system identifier to be used in the DTD. That is, the value of the SYSTEM attribute in the DOCTYPE declaration in the output.
cdata-section-elements namelist Optional. A space-separated list of elements whose text content should be output as CDATA sections.
indent yes no Optional. "yes" specifies that the output should be indented according to its hierarchy. "no" specifies that the output should not be indented according to its hierarchy. Netscape 6 does not support this attribute.
media-type string Optional. Defines the MIME type of the output (the media type of the data). Default is "text/xml". Netscape 6 does not support this attribute.

Example 1

In this example, the output is an XML document, version 1.0. The character encoding is set to "ISO-8859-1", and the output is indented to improve readability:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="xml" version="1.0"
    encoding="iso-8859-1" indent="yes"/>
  ...
  ...
</xsl:stylesheet>

Example 2

In this example, the output is an HTML document, version 4.0. The character encoding is set to "ISO-8859-1", and the output is indented to improve readability:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="html" version="4.0"
    encoding="iso-8859-1" indent="yes"/>
  ...
  ...
</xsl:stylesheet>

XSLT Element Reference Complete XSLT Element Reference

← El ParamEl Otherwise β†’