Data model generation
Before an XPath expression can be processed, the input documents must be represented in the XML data model.
- During XML parsing, the string representation of an XML
document is transformed into an instance of the XPath model. Optionally,
the XML document can be validated against a specific schema. The parsed
data is represented as a hierarchy of nodes and atomic values. Each
atomic value, element node, and attribute node in the XPath data model
is annotated with a dynamic type. The dynamic type specifies a range
of values. For example, an attribute named version might
have the dynamic type xs:decimal to indicate that
the attribute contains a decimal value.
Restriction: If the XML document is validated against a schema, DB2® does not keep the type annotation for each node. The data is stored as untyped.
The value of an attribute is represented directly within the attribute node. An attribute node of unknown type is annotated with the dynamic type xs:untypedAtomic.
The value of an element is represented by the children of the element node, which might include text nodes and other element nodes. The dynamic type of an element node indicates how the values in the child text nodes are to be interpreted. All element nodes have the type xs:untyped.
An atomic value of unknown type is annotated with the type xs:untypedAtomic.
If an input document has no schema, the document is not validated. DB2 assigns nodes and atomic values as untyped (xs:untyped or xs:untypedAtomic).
- During serialization, the sequence of nodes and atomic values (the instance of the XPath data model) is converted into its string representation. The result of serialization does not always represent a well-formed document. In fact, serialization can result in a single atomic value (for example, 17) or a sequence of elements that do not have a common parent.