XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition (216 page)

BOOK: XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition
11.07Mb size Format: txt, pdf, ePub
use-character-maps
optional
Whitespace-separated list of lexical QNames
A list of the names of

elements that are to be used for character mapping.
version
optional
NMTOKEN
Defines the version of the output format.

Content

None, the element is always empty.

Effect

A stylesheet can contain several output format definitions. This is useful if the stylesheet produces multiple result documents or if it produces different kinds of output on different occasions. One of the output format definitions can be unnamed, and the others are named using a QName in the same way as other stylesheet objects.

An output definition can be split over several

elements. All the

elements with the same name (as specified in the
name
attribute) constitute one output definition. In this case the attributes defined in these multiple elements are in effect combined into a single conceptual

element as follows:

  • For the
    cdata-section-elements
    attribute, the lists of
    QNames
    supplied on the separate

    elements are merged—if an element name is present in any of the lists, it will be treated as a
    CDATA
    section element.
  • For the
    use-character-maps
    attribute, the lists of QNames on the separate

    elements are concatenated. They are taken in order of the import precedence of the

    declarations on which they appear, or where two declarations have the same import precedence, in declaration order.
  • For all other attributes, an

    element that specifies a value for the attribute takes precedence over one that leaves it defaulted. If several

    elements specify a value for the attribute, the one with highest import precedence is used. It is an error if this leaves more than one value, unless they are all equal.

The concept of import precedence is explained under

on page 359.

The
method
attribute controls the format of the output, and this in turn affects the detailed meaning and the default values of the other attributes.

Four output methods are defined in the specification:
xml
,
html
,
xhtml
, and
text
. Alternatively, the output method may be given as a QName, which must include a non-null prefix that identifies a namespace that is currently in scope. This option is provided for vendor or user extensions, and the meaning is not defined in the standard. A vendor-defined output method can attach its own interpretations to the meanings of the other attributes on the

element, and it can also define additional attributes on the

element, provided they are in a namespace.

If the
method
attribute is omitted, the output will be in XML format, unless the result tree is recognizably HTML or XHTML. The result tree is recognized as HTML if:

  • The root node has at least one element child, and
  • The first element child of the root node is named

    , in any combination of upper and lower case, and has a null namespace URI, and
  • There are no text nodes before the

    element, other than, optionally, a text node containing whitespace only.

The result tree is recognized as XHTML if:

  • The root node has at least one element child, and
  • The first element child of the root node is named

    , in lower case, and has the namespace URI
    http://www.w3.org/1999/xhtml
    , and
  • There are no text nodes before the

    element, other than, optionally, a text node containing whitespace only, and
  • Backward-compatibility mode is
    not
    in effect (specifically, if the
    version
    attribute of the

    element in the principal stylesheet module is
    2.0
    or greater).

Examples

The following example requests XML output using iso-8859-1 encoding. The output will be indented for readability, and the contents of the