Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

XSLT <xsl:output> elements


May 28, 2021 XSL T


Table of contents


XSLT and lt;xsl:output.gt; elements

Refer to the example in this section for the XSLT and xsl:output elements that define the output format of the document.


XSLT <xsl:output> elements Complete XSLT element reference manual

Definitions and usages

The element defines the format of the output document.

Note: The top-level element (top-level element) must be a child node of the top element, or the sl;xsl:transform.


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"/>

Property

属性 描述
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 不支持该属性。

Instance 1

In this case, the output is an XML document with version 1.0. 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>

Instance 2

In this case, the output is an HTML document and the version is 4.0. 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 <xsl:output> elements Complete XSLT element reference manual