Read XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition Online
Authors: Michael Kay
The
type
attribute gives the required type of the document element (not the document node). For example, if
type=“mf:invoiceType”
is specified, then the single element child of the document node is validated against the schema type
mf:invoiceType
.
Usage and Examples
The most likely reason for using
It is possible to perform element-level validation of the document element in a tree without using
However, this does not perform document-level validation: it doesn't check the
ID
and
IDREF
constraints defined in the schema, for example. To perform these extra checks, it is necessary to write the
There are certain other situations where
as
attribute of
as=“document(element(*, mf:invoiceType))”
.
See Also
xsl:element
The
Changes in 2.0
Two new attributes
validation
and
type
are available, to control whether and how the copied nodes are validated against a schema.
Format
name = { qname }
namespace? = { uri-reference}
use-attribute-sets? = qnames
inherit-namespaces? = “yes” | “no”
validation? = “strict” | “lax” | “preserve” | “strip”
type? = qname>
Position
Attributes
Name | Value | Meaning |
name mandatory | Attribute value template returning a lexical QName | The name of the element to be generated. |
namespace optional | Attribute value template returning a URI | The namespace URI of the generated element. |
use-attribute-sets optional | Whitespace-separated list of lexical QNames | List of named attribute sets containing attributes to be added to this output element. |
inherit-namespaces optional | yes or no . (Default is yes ). | Indicates whether the namespaces of the constructed element will be inherited by its children. |
validation optional | strict , lax , preserve , or skip | Indicates whether and how the element should be subjected to schema validation, or whether existing type annotations on attributes and child elements should be retained or removed. |