XSLT <xsl:output>Element


XSLT 元素参考手册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 format of the output. The default is XML (but if the first child node of the root node is <html>, and there are no text nodes before it, then 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. The 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. The 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 of 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 of the DOCTYPE declaration in the output.
cdata-section-elements namelist Optional. A space-separated list of elements whose text contents 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 (media type of the data) of the output. The default is "text/xml".

Netscape 6 does not support this attribute.

Example 1

In this example, the output is an XML document with version 1.0. The character encoding is set to "ISO-8859-1", and the output will be 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 with version 4.0. The character encoding is set to "ISO-8859-1", and the output will be 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 元素参考手册Complete XSLT Element Reference Other Extensions