Output Properties

The xsl:output instruction controls the details of serialization. For example, it can specify XML, HTML, or plain text output. It can specify the encoding of the output, what the document type declaration points to, whether the elements should be indented, what the value of the standalone declaration is, where CDATA sections should be used, and more. For example, adding this xsl:output element to a stylesheet would produce plain text output instead of XML:

<xsl:output
  method="text"
  encoding="US-ASCII"
  media-type="text/plain"
/>

This xsl:output element asks for pretty-printed XML:

<xsl:output
  method="xml"
  encoding="UTF-16"
  indent="yes"
  media-type="text/xml"
  standalone="yes"
/>

In all, there are ten attributes of the xsl:output element that control serialization of the result tree:

method="xml | html | text"

The output method. xml is the default. html uses classic HTML syntax such as <hr> instead of <hr />. text outputs plain text but no markup.

version="1.0"

The version number used in the XML declaration. Currently, this should always have the value 1.0.

encoding="UTF-8 | UTF-16 | ISO-8859-1 | …"

The encoding used for the output and in the encoding declaration of the output document.

omit-xml-declaration="yes | no"

yes if the XML declaration should be omitted, no otherwise. (i.e. no if the XML declaration should be included, yes if it shouldn’t be.) The default is no.

standalone="yes | no"

The value of the standalone attribute for the XML declaration; either yes or no

doctype-public="public ID"

The public identifier used in the DOCTYPE declaration

doctype-system="URI"

The URL used as a system identifier in the DOCTYPE declaration

cdata-section-elements="element_name_1 element_name_2 …"

A white space separated list of the qualified names of the elements’ whose content should be output as a CDATA section

indent="yes | no"

yes if extra white space should be added to pretty-print the result, no otherwise. The default is no.

media-type="text/xml | text/html | text/plain | application/xml… "

The MIME media type of the output such as text/html, application/xml, or application/xml+svg


Previous | Next | Top | Cafe con Leche

Copyright 2000-2003 Elliotte Rusty Harold
elharo@metalab.unc.edu
Last Modified January 13, 2003