XSLT <xsl: output> element
Definition and Usage
<Xsl: output> element defines the format of the output document.
NOTE: <xsl: output> element is the top (top-level element), must be <xsl: stylesheet> or <xsl: transform> child node.
grammar
<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"/>
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
属性 | 值 | 描述 |
---|---|---|
method | xml html text name |
可选。定义输出的格式。默认是 XML(但是如果根节点的第一个子节点是 <html>,且在这之前没有文本节点,则默认是 HTML)。 Netscape 6 仅支持 "html" 和 "xml"。 |
version | string | 可选。设置输出格式的 W3C 版本号。(仅在 method="html" or method="xml" 时使用)。 |
encoding | string | 可选。设置输出中编码属性的值。 |
omit-xml-declaration | yes no |
可选。"yes" 规定在输出中省略 XML 声明(<?xml...?>)。"no" 规定应在输出中包含的 XML 声明。默认是 "no"。 |
standalone | yes no |
可选。"yes" 规定 XSLT 处理器应输出独立文档声明。"no" 规定 XSLT 处理器不应输出独立文档声明。默认是 "no"。
Netscape 6 不支持该属性。 |
doctype-public | string | 可选。规定 DTD 中要使用的公共标识符。即输出中 DOCTYPE 声明的 PUBLIC 属性的值。 |
doctype-system | string | 可选。规定 DTD 中要使用的系统标识符。即输出中 DOCTYPE 声明的 SYSTEM 属性的值。 |
cdata-section-elements | namelist | 可选。一个空格分隔的元素列表,这些元素的文本内容应作为 CDATA 部分来输出。 |
indent | yes no |
可选。"yes" 规定输出应根据其层次结构进行缩排。"no" 规定输出不应根据其层次结构进行缩排。 Netscape 6 不支持该属性。 |
media-type | string | 可选。定义输出的 MIME 类型(数据的媒体类型)。默认是 "text/xml"。
Netscape 6 不支持该属性。 |
Example 1
In this case, the output is an XML document, version 1.0. Character encoding is set to "ISO-8859-1", 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>
<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 case, the output is an HTML document, version 4.0. Character encoding is set to "ISO-8859-1", 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>
<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>
Complete XSLT Element Reference Manual