Read XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition Online
Authors: Michael Kay
Validating an element using the
type
attribute places no constraints on the name of the element. It does not need to be an element name that is defined in any schema. The validation is concerned with the content of the element (including, of course, the names of its attributes and children) and not with its name.
In contrast, validation using the
validation
attribute is driven by the element's name.
There are two options for the
validation
attribute that cause schema validation to happen and two options that cause it not to happen. Let's take the last two first:
The difference between
xs:anyType
and
xs:untyped
is rather subtle, and most applications won't notice the difference. However, the XSLT processor knows when it sees an
xs:untyped
element that all its descendants will also be
xs:untyped
, and this makes certain optimizations possible.
The other two options are
strict
and
lax
:
If the element declaration in the schema refers to a named type definition, then on successful validation, the element is annotated with this type name. If the element declaration contains an inline (and therefore unnamed) type definition, the XSLT processor invents a name for this implicit type, and uses this invented name as the type annotation, just as in the case described earlier for the
type
attribute.
If the element declaration requires it, then strict validation of an element proceeds recursively through the content of the element. It is possible, however, that the element declaration is liberal. It may, for example, define the permitted contents of the element using
processContents
set to
lax
or
skip
. In this case, validation follows the schema rules. If
skip
is specified, for example, the relevant subtree is not validated. All nodes in such a subtree will be annotated as if
validation=“strip”
were specified.
If an
xsi:type
attribute appears in the data being validated, then the system takes account of it according to the rules in the XML Schema specification. Elements validated against such an attribute will end up with this type as their type annotation.