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

BOOK: XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition
2.61Mb size Format: txt, pdf, ePub

Usage

To allow interoperability, the attribute can be specified as a list of collation URIs, separated by whitespace. The processor will use as the default collation the first URI that it recognizes. This means that if you want to write a stylesheet that works under processors produced by Microsoft, IBM, and Oracle, and if each of these vendors supports different flavors of collation URI, then you can list your preferred collation for each of these vendors, and the product will pick the one that it understands. If the processor doesn't recognize any of the URIs, then it reports an error. You can avoid this error by including the Unicode codepoint collation,
http://www.w3.org/2005/xpath-functions/collation/codepoint
, as the last URI in the list.

It's permitted to use a relative URI, in which case it is resolved against the base URI of the element where it appears. This option is only likely to be useful in the case of a vendor who implements collation URIs as references to real documents, perhaps an XML document that contains a machine-readable specification of the collation rules.

The default-validation Attribute

Like most of the attributes on the

element, the
default-validation
attribute applies to everything that is textually within the stylesheet module. Unlike others, it can't be overridden with a different declaration on an inner element in the stylesheet. (I don't think there's any good reason for this restriction; it was put there simply to avoid adding unnecessary complexity).

Effect

This attribute applies to every instruction in the stylesheet that is allowed to take a
validation
or
type
attribute, provided neither of these attributes is actually present. It also affects literal result elements, which are allowed to take an
xsl:type
or
xsl:validation
attribute, in the same way. The effect is to supply a default value for the
[xsl:]validation
attribute on these instructions or literal result elements.

The possible values of the attribute are
preserve
and
strip
, the default being
strip
. (At one time the values
strict
and
lax
were also allowed, which explains the name of the attribute, but experience showed that these options were not useful.) The meanings of these values are explained under each instruction that takes a
validation
attribute, and vary slightly from one instruction to another, depending on whether it is dealing with single nodes or multiple nodes, elements or attributes.

Usage

This attribute affects every literal result element, and every

,

,

and

instruction within the stylesheet module, unless it has its own
validation
or
type
attribute.

Since the default is
validation=“strip”
, the only real question to consider is when to use
validation=“preserve”
. Given a schema-aware processor, and a stylesheet whose main job is to copy a selection of the nodes from the source document across to the result document with as few changes as possible, for further transformation by another stylesheet later on in the pipeline, it makes sense to preserve all the existing type annotations. However, check the specification of the individual instructions.

probably doesn't do what you imagine. Since

can completely change the content of an element, the type annotation on the element being copied is no longer reliable, so it isn't retained, even with this option. When a subtree is copied in its entirety, with no changes (typically using

), it makes sense to retain type annotations. As soon as any changes are made, the result can only contain type annotations if you put it through schema validation.

Other books

Enchanted Revenge by Theresa M. Jones
One Night of Scandal by Nicola Cornick
Anterograde by Kallysten
Story of My Life by Jay McInerney