xsl:output¶
Used to control the format of serial output files resulting from the transformation.
Available in XSLT 1.0 and later versions. Available in all Saxon editions.
- Category: declaration
- Content: none
- Permitted parent elements:
xsl:package
;xsl:stylesheet
;xsl:transform
Attributes¶
name?
- eqname
- Provides a name for this output format, which may be referenced in the
xsl:result-document
element. By default, the unnamed output format is used. method?
"xml" | "html" | "xhtml" | "text" | "json" | "adaptive"
| eqname- Indicates the format or destination of the output. The value xml indicates XML output (though if disable-output-escaping or character maps are used there is no guarantee that it is well-formed). A value of
html
is used for HTML output, andxhtml
for XHTML. The valuetext
indicates plain text output: in this case no markup may be written to the file using constructs such as literal result elements,xsl:element
,xsl:attribute
, orxsl:comment
. Alternatively output can be directed to a user-defined Java program by specifying the name of the class as the value of the method attribute, prefixed by a namespace prefix, for examplexx:com.me.myjava.MyEmitter
. The class must be on the classpath, and must implement either theorg.xml.sax.ContentHandler
interface, or theReceiver
interface. The last of these, though proprietary, is a richer interface that gives access to additional information. The valuejson
is used for JSON output, andadaptive
for Adaptive output (these options are available in XPath 3.1, and implemented since Saxon 9.7). allow-duplicate-names?
- boolean
- Used only for JSON output, available in XPath 3.1, implemented since Saxon 9.7. Defines whether duplicate keys (e.g. the date
2014-10-01
and the string"2014-10-01"
, which have the same string value) are allowed in a JSON map. The value yes indicates that such duplicate keys will result in duplicate object-member names in the JSON output; whereas the value no indicates that such duplicates are an error. build-tree?
- boolean
- Defines whether the raw output is used to build an XML document tree.
byte-order-mark?
- boolean
- Indicates whether UTF-8/UTF-16 output is to start with a byte order mark. The default is no.
cdata-section-elements?
- eqnames
- Used only for XML output. The value is a whitespace-separated list of element names. Character data belonging to these output elements will be written within CDATA sections.
doctype-public?
- string
- Used only for XML output: it is copied into the DOCTYPE declaration as the public identifier. Ignored if there is no system identifier. If the value is an empty string, Saxon interprets this as if the attribute were omitted, which can be useful it you want to override an actual value with "absent".
doctype-system?
- string
- Used only for XML output: it is copied into the DOCTYPE declaration as the system identifier. If the value is an empty string, Saxon interprets this as if the attribute were omitted, which can be useful it you want to override an actual value with "absent".
encoding?
- string
- A character encoding, e.g.
iso-8859-1
orutf-8
. The value must be one recognised both by the Java run-time system and by Saxon itself: the encoding names that Saxon recognises areASCII
,US-ASCII
,iso-8859-1
,utf-8
,utf8
,KOI8R
,cp1251
. It is used for three distinct purposes: to control character conversion by the Java I/O routines; to determine which characters will be represented as character entities; and to document the encoding in the output file itself. The default (and fallback) isutf-8
. escape-uri-attributes?
- boolean
- New in XSLT 2.0. Affects HTML output only. Controls whether non-ASCII characters in HTML URI-valued attributes (for example, href) are escaped using the %HH convention. The default is
yes
. html-version?
- decimal
- New in XSLT 3.0. Implemented since Saxon 9.6. When the output method is HTML or XHTML, then if this attribute takes decimal value 5.0, then the output produced is HTML 5.0 or XHTML 5.0 respectively.
include-content-type?
- boolean
- New in XSLT 2.0. Affects HTML output only. Controls whether a meta tag is inserted into the HTML head element. The default is
yes
. indent?
- boolean
- The indentation algorithm is different for HTML and XML. For HTML it avoids outputting extra space before or after an inline element, but will indent text as well as tags, except in elements such as
PRE
andSCRIPT
. For XML, it avoids outputting extra whitespace except between two tags. The emphasis is on conformance rather than aesthetics! item-separator?
- string
- Not available in XSLT.
json-node-output-method?
"xml" | "html" | "xhtml" | "text"
| eqname- Used only for JSON output, available in XPath 3.1, implemented since Saxon 9.7. Defines the serialization method for nodes encountered while serializing as JSON.
media-type?
- string
- For example,
text/xml
ortext/html
. This is largely documentary. However, the value assigned is passed back to the calling application in theOutputDetails
object, where it can be accessed using thegetMediaType()
method. The supplied servlet applicationSaxonServlet
uses this to set the media type in the HTTP header. normalization-form?
"NFC" | "NFD" | "NFKC" | "NFKD" | "fully-normalized" | "none"
| nmtoken- Indicates that a given Unicode normalization form (or no normalization) is required.
omit-xml-declaration?
- boolean
- For XML output this controls whether an XML declaration should be output; the default is
no
. parameter-document?
- uri
- New in XSLT 3.0. Not implemented in Saxon 9.7. Allows serialization to be configured in an external document.
standalone?
- boolean |
"omit"
- Used only for XML output: if it is present, a standalone attribute is included in the XML declaration, with the value
yes
orno
. suppress-indentation?
- eqnames
- New in XSLT 3.0 (it was previously available in Saxon as an extension). The value is a whitespace-separated list of element names, and it typically identifies "inline" elements that should not cause indentation; in XHTML, for example, these would be
b
,i
,span
, and the like. undeclare-prefixes?
- boolean
- Indicates XML 1.1 namespace undeclarations are to be output when required.
use-character-maps?
- eqnames
- A space-separated list of the names of character maps (see
xsl:character-map
) which will be applied to transform individual characters during serialization. version?
- nmtoken
- Determines the version of XML or HTML to be output. This is largely documentary. However, for XML the distinction between 1.0 and 1.1 determines whether or not namespace undeclarations will be output; and for HTML, the value 5 can be used to force the HTML5 style of DOCTYPE declaration.
Notes on the Saxon implementation¶
The new XSLT 3.0 attribute parameter-document
is first implemented in Saxon 9.8.
Details¶
The xsl:output
declaration is always a top-level element immediately below the xsl:stylesheet
element. There may be multiple xsl:output
elements; their values are accumulated as described in the XSLT specification.