This section summarizes data model construction from a PSVI for each kind of information item. General notes occur elsewhere.
Construction from a PSVI is identical to construction from the Infoset.
The following Element Node properties are affected by PSVI properties.
The schema-type is determined as described in 3.3.1.1 Element and Attribute Node Types.
The sequence of nodes constructed from the information items found in the [children] property.
For each element, processing instruction, comment, and maximal sequence of adjacent character information items found in the [children] property, a corresponding Element, Processing Instruction, Comment, or Text Node is constructed and that sequence of nodes is used as the value of the children property.
For elements with schema simple types, or complex types with simple content, if the [schema normalized value] PSVI property exists, the processor may use a sequence of nodes containing the Processing Instruction and Comment Nodes corresponding to the processing instruction and comment information items found in the [children] property, plus an optional single Text Node whose string value is the [schema normalized value] for the children property. If the [schema normalized value] is the empty string, the Text Node must not be present, otherwise it must be present.
The relative order of Processing Instruction and Comment Nodes must be preserved, but the position of the Text Node, if it is present, among them is implementation defined.
The effect of the above rules is that where a fixed or default value for an element is defined in the schema, and the element takes this default value, a text node will be created to contain the value, even though there are no character information items representing the value in the PSVI. The position of this text node relative to any comment or processing instruction children is implementation-dependent.
[Schema Part 1] also permits an element with mixed content to take a default or fixed value (which will always be a simple value), but it is unclear how such a defaulted value is represented in the PSVI. Implementations therefore may represent such a default value by creating a text node, but are not required to do so.
Note:
Section 3.3.1 in [Schema 1.1 Part 1] clarifies the PSVI contributions of element default or fixed values in mixed content: additional character information items are not added to the PSVI.
Because the data model requires that all general entities be expanded, there will never be unexpanded entity reference information item children.
A set of Attribute Nodes constructed from the
attribute information items
appearing in the [attributes]
property. This includes all of the "special" attributes
(xml:lang
, xml:space
, xsi:type
, etc.)
but does not include namespace declarations (because they are not attributes).
Default and fixed attributes provided by XML Schema processing are added to the [attributes] and are therefore included in the data model attributes of an element.
A set of Namespace Nodes constructed from the namespace information items appearing in the [in-scope namespaces] property. Implementations that do not support Namespace Nodes may simply preserve the relevant bindings in this property.
Implementations may ignore namespace information items for namespaces which are not known to be used. A namespace is known to be used if:
It appears in the expanded QName of the node-name of the element.
It appears in the expanded QName of the node-name of any of the element's attributes.
It appears in the expanded QName
of any values of type xs:QName
that appear among the
element's children or the typed values of its attributes.
Note: applications may rely on namespaces that are not known to be used,
for example when QNames are used in content and that content does not
have a type of xs:QName
Such applications may have difficulty
processing data models where some namespaces have been ignored.
If the [validity] property exists on an information item and is "valid" then if the [nil] property exists and is true, then the nilled property is "true". In all other cases, including all cases where schema validity assessment was not attempted or did not succeed, the nilled property is "false".
The string-value is calculated as follows:
If the element is empty: its string value is the zero length string.
If the element has a type of xs:untyped
, a complex
type with element-only content, or a complex type with mixed content: its
string-value is the concatenation of the string-values of all its
Text Node descendants in document order.
If the element has a simple type or a complex type with simple content: its string-value is the [schema normalized value] of the node.
If an implementation stores only the typed value of an element, it may use any valid lexical representation of the typed value for the string-value property.
The typed-value is calculated as follows:
If the element is of type xs:untyped
, its typed-value
is its dm:string-value as an xs:untypedAtomic
.
If the element has a complex type with empty content, its typed-value is the empty sequence.
If the element has a simple type or a complex type with simple content: its typed value is computed as described in 3.3.1.2 Typed Value Determination. The result is a sequence of zero or more atomic values. The relationship between the type-name, typed-value, and string-value of an element node is consistent with XML Schema validation.
Note that in the case of dates and times, the timezone is preserved
as described in 3.3.2 Dates and Times, and
in the case of xs:QName
s and xs:NOTATION
s,
the prefix is preserved as described in
3.3.3 QNames and NOTATIONS.
If the element has a complex type with mixed content
(including xs:anyType
), its typed-value
is its dm:string-value as an xs:untypedAtomic
.
Otherwise, the element must be a complex type with element-only content. The typed-value of such an element is absent. Attempting to access this property with the dm:typed-value accessor always raises an error.
If the element has a complex type with element-only content,
the is-id
property is false
.
Otherwise, if the typed-value of the element consists of exactly
one atomic value and that value is of type xs:ID
,
or a type derived from xs:ID
,
the is-id
property is true
, otherwise it is false
.
Note:
This means that in the case of a type constructed by list
from xs:ID
, the ID is recognized provided that the list
is of length one. A type constructed as a union
involving xs:ID
is recognized provided the actual value
is of type xs:ID
.
Note:
The element that is marked with the
is-id property, and which will
therefore be retrieved by the fn:id function, is the node whose typed
value contains the xs:ID
value.
This node is a child of the element node that, according to XML Schema,
is uniquely identified by this ID.
If the element has a complex type with element-only content, the
is-idrefs
property is false
.
Otherwise, if any of the atomic values in the typed-value of the
element is of type xs:IDREF
or xs:IDREFS
, or
a type derived from one of those types, the
is-idrefs
property is true
, otherwise it is false
.
All other properties have values that are consistent with construction from an infoset.
The following Attribute Node properties are affected by PSVI properties.
The [schema normalized value] PSVI property if that exists.
Otherwise, the [normalized value] property.
If an implementation stores only the typed value of an attribute, it may use any valid lexical representation of the typed value for the string-value property.
The schema-type is determined as described in 3.3.1.1 Element and Attribute Node Types.
The typed-value is calculated as follows:
If the attribute is of type xs:untypedAtomic
: its typed-value
is its dm:string-value as an xs:untypedAtomic
.
Otherwise, a sequence of zero or more atomic values as described in 3.3.1.2 Typed Value Determination. The relationship between the type-name, typed-value, and string-value of an attribute node is consistent with XML Schema validation.
If the attribute is named xml:id
and
its [attribute type] property
does not have the value xs:ID
or a type derived from xs:ID
,
then [xml:id] processing is performed.
This will assure that the value does have the type xs:ID
and that it is properly normalized.
If an error is encountered during xml:id processing,
an implementation may raise a dynamic error.
The is-id
property is always true for attributes named xml:id
.
Otherwise, if the typed-value of the attribute consists of
exactly one atomic value and that value is of type xs:ID
,
or a type derived from xs:ID
,
the is-id
property is true
, otherwise it is false
.
Note:
This means that in the case of a type constructed by list
from xs:ID
, the ID is recognized provided that the list
is of length one. A type constructed as a union
involving xs:ID
is recognized provided the actual value
is of type xs:ID
.
If any of the atomic values in the typed-value of the
attribute is of type xs:IDREF
or xs:IDREFS
, or
a type derived from one of those types, the
is-idrefs
property is true
, otherwise it is false
.
Note:
This rule means that a
node whose type is
constructed by list with an item type of xs:IDREF
(or a type derived from xs:IDREF
)
may have the
is-idrefs property,
whether or not the list type is named xs:IDREFS
or is derived from
xs:IDREFS
. Because union types are allowed, it also means that an
element or attribute with the
is-idrefs property can contain atomic
values of type xs:IDREF
alongside values of other types.
A node
has the
is-idrefs property only if the typed value contains at least
one atomic value that is an instance of xs:IDREF
;
it is not sufficient that the type annotation permits such values.
All other properties have values that are consistent with construction from an infoset.
Note: attributes from the XML Schema instance namespace,
"http://www.w3.org/2001/XMLSchema-instance
",
(xsi:schemaLocation
,
xsi:type
, etc.) appear as ordinary attributes in the data model.
Construction from a PSVI is identical to construction from the Infoset.
Construction from a PSVI is identical to construction from the Infoset.
Construction from a PSVI is identical to construction from the Infoset.
For Text Nodes constructed from the [schema normalized value] of elements, content contains the value of the [schema normalized value].
Otherwise, construction from a PSVI is the same as construction
from the Infoset except for the content property. When
constructing the content property,
[element content whitespace]
is not used to test if whitespace is collapsed. Instead,
if the resulting Text Node consists entirely of whitespace and the
character information items used to
construct this node have a parent and that parent is an element and its
{content type} is not “mixed
”, then
the content of the Text Node
is the zero-length string.
Text Nodes are only allowed to be empty if they have no parents; an empty Text Node will be discarded when its parent is constructed, if it has a parent.