XSLT Output Types


 

XSLT Output Types

The xsl:output element lets you specify how to generate result output. Although it is not required to specify the type of output but an XSLT processor outputs the result as specified the type in the method attribute of the output element. 

The xsl:output element lets you specify how to generate result output. Although it is not required to specify the type of output but an XSLT processor outputs the result as specified the type in the method attribute of the output element. 

Output Types

The xsl:output element lets you specify how to generate result output. Although it is not required to specify the type of output but an XSLT processor outputs the result as specified the type in the method attribute of the output element. 

The xsl:output element is a top-level element and it must be a child node of <xsl:stylesheet> or <xsl:transform>

The method attribute of xsl:output declares the type of output XSLT processor should generate as output of the result tree.

Attribute Value
method xml
html
text

Features:

1. This attribute is optional.

2. It defines the output format.

3. If you don't specify xsl:output element then the default is XML. But if <html> is the first child of the root node with no preceding text nodes then HTML is the default value.

Text

<xsl:output method="text"/>

XSLT can be used to output plain text using the above line in xslt document.

XML

<xsl:output method="xml"/>

XSLT can be used to output XML using the above line in xslt document. This is the default method.

HTML

<xsl:output method="html"/>

XSLT can be used to output HTML using the above line in xslt document. It is the commonly used type of the result output. If there is html element as document element then the default method is changed from xml to html.

Ads