XSL output methods

Options for displaying XML  XSL output methods





  indent="yes" | "no"


  method="html" | "name" | "text" | "xml"

  omit-xml-declaration="yes" | "no"

  standalone="yes" | "no"



The xsl:output element is used to define the format of the output created by the stylesheet. This is accomplished by setting one or more of ten optional attributes. The most important of these ten attributes is the method attribute which dictates if the type of output is HTML, text, or XML. The type of output, in turn, dictates which of the other nine attributes can be applied to the output.
The following table defines which attributes can optionally be set for each of the three types of output. A dash signifies that the attribute cannot effect the output.
Attribute HTML Text XML
cdata-section-elements YES
doctype-public YES YES
doctype-system YES YES
encoding YES YES YES
indent YES YES
media-type YES YES YES
omit-xml-declaration YES
standalone YES
version YES YES
You can have zero or more xsl:output elements:
• If there is more than one xsl:output element, the XSLT processor essentially combines the information.

• If more than one xsl:output element sets the same attribute, the element with the highest import precedence will have its attribute selected.

• If more than one xsl:output element repeats an attribute and has the same highest import precedence, either the last will be chosen or an error will be declared.

• If there is more than one cdata-section-elements attribute, all of the values in the name lists will effectively be merged into one list.

The xsl:output element can only be a child of the xsl:stylesheet or the xsl:transform elements.

This is a self-closing element and it cannot contain any child elements or any content.

The optional cdata-section-elements attribute is set to a white-space delimited list of qnames (element names) whose content is to be output in CDATA sections. CDATA sections permit the use of sequences of characters that contain markup elements without violating the XML requirement to be well-formed (i.e., all tags and elements are closed).
The optional doctype-public attribute specifies the public identifiers that go in the document type declaration (DTD). If the doctype-system attribute is not set, then the doctype-public attribute is ignored.
The optional doctype-system attribute specifies the system identifiers that go in the document type declaration (DTD). The DTD should go immediately after the XML declaration.
The optional encoding attribute specifies the preferred character encoding which is used to encode sequences of characters as sequences of bytes.
indent=”yes” | “no”
The optional indent attribute specifies whether or not to indent. If set to yes, the XML and HTMLoutputs are step-indented to make them more readable.
The optional media-type attribute sets the MIME type. The default is: media-type=”text/xml”
method=”html” | “qname” | “text” | “xml”
The optional method attribute dictates the type of output. The three permitted values are HTML, text and XML. (Some XSLT processors recognize a qname as being an acceptable value for this attribute, but it is not part of the W3C standard.) The default is XML. However, if the first child element of the root node is the HTML <html> tag and there are no preceding text nodes, then the default output type is set to HTML.
omit-xml-declaration=”yes” | “no”
The optional omit-xml-declaration attribute dictates whether the XSLT processor should output an XMLdeclaration. The default is no and an XML declaration is output. If yes, there is no output.
standalone=”yes” | “no”
The optional standalone attribute dictates whether the XSLT processor should output a standalone declaration. Yes signifies that it will. No, the default, signifies that it will not.
The optional version attribute provides the W3C version number for the output format. If the output is XML, the default version is 1.0 (currently, the only X3C version). Or if the output type is HTML, the default version is 4.0.
Scroll to Top