XSLT <xsl:output>
❮ Complete XSLT Element Reference
定义和用法
The <xsl:output> element defines the format of the output document. (<xsl:output> 元素定义输出文档的格式。)
Note: <xsl:output> is a top-level element, and must appear as a child node of <xsl:stylesheet> or <xsl:transform>. (注意: <xsl:output> 是一个顶层元素,必须作为 <xsl:stylesheet> 或 <xsl:transform> 的子节点出现。)
语法
<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"/>
属性
Attribute | 值 | 描述 |
---|---|---|
method | xml html text name |
Optional. Defines the output format. The default is XML (but if the first child of the root node is <html> and there are no preceding text nodes, then the default is HTML) (可选。定义输出格式。默认为 XML(但如果根节点的第一个子节点是 <html> 且前面没有文本节点,则默认为 HTML)) Netscape 6 only supports "html" and "xml" (Netscape 6 只支持“html”和“xml”) |
version | string | Optional. Sets the W3C version number for the output format (only used with method="html" or method="xml") (可选。为输出格式设置 W3C 版本号(仅在 method="html" 或 method="xml" 时使用)) |
encoding | string | Optional. Sets the value of the encoding attribute in the output (可选。设置输出中 encoding 属性的值) |
omit-xml-declaration | 是 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" (可选。“yes”指定在输出中省略 XML 声明 (<?xml...?>)。“no”指定在输出中包含 XML 声明。默认为“no”) |
standalone | 是 no |
Optional. "yes" specifies that a standalone declaration should occur in the output. "no" specifies that a standalone declaration should not occur in the output. The default is "no" (可选。“yes”指定在输出中应出现 standalone 声明。“no”指定在输出中不应出现 standalone 声明。默认为“no”) This attribute is not supported by Netscape 6 (Netscape 6 不支持此属性) |
doctype-public | string | Optional. Sets the value of the PUBLIC attribute of the DOCTYPE declaration in the output (可选。设置输出中 DOCTYPE 声明的 PUBLIC 属性的值) |
doctype-system | string | Optional. Sets the value of the SYSTEM attribute of the DOCTYPE declaration in the output (可选。设置输出中 DOCTYPE 声明的 SYSTEM 属性的值) |
cdata-section-elements | namelist | Optional. A white-space separated list of elements whose text contents should be written as CDATA sections (可选。一个以空格分隔的元素列表,其文本内容应写为 CDATA 部分) |
indent | 是 no |
Optional. "yes" indicates that the output should be indented according to its hierarchic structure. "no" indicates that the output should not be indented according to its hierarchic structure. (可选。“yes”表示输出应根据其层次结构进行缩进。“no”表示输出不应根据其层次结构进行缩进。) This attribute is not supported by Netscape 6 (Netscape 6 不支持此属性) |
media-type | string | Optional. Defines the MIME type of the output. The default is "text/xml" (可选。定义输出的 MIME 类型。默认为“text/xml”) This attribute is not supported by Netscape 6 (Netscape 6 不支持此属性) |
示例 1
The output in this example will be an XML document, version 1.0. The character encoding is set to "UTF-8" and the output will be indented for readability (此示例中的输出将是一个 XML 文档,版本为 1.0。字符编码设置为“UTF-8”,输出将缩进以便于阅读。)
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0"
encoding="UTF-8" indent="yes"/>
...
...
</xsl:stylesheet>
示例 2
The output in this example will be an HTML document, version 4.0. The character encoding is set to "UTF-8" and the output will be indented for readability (此示例中的输出将是一个 HTML 文档,版本为 4.0。字符编码设置为“UTF-8”,输出将缩进以便于阅读。)
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" version="4.0"
encoding="UTF-8" indent="yes"/>
...
...
</xsl:stylesheet>
❮ Complete XSLT Element Reference