XML technologies / XSLT / Introduction to XSLT 2.0 / XSLT and XPath – getting started / The XML document as a tree / The tree as a representation of an infoset or PSVI

(Excerpt from “XSLT 2.0 & XPath 2.0” by Frank Bongers, chapter 1.)

We said, in simplified terms, that an XML document is converted to a tree-like form by the XML parser. This is actually only the second or third stage. Parsing first converts the document into information usable by a subsequent application: the infoset. Its parsed components are represented as information items, an element being an element information item, for example.

Infoset properties

The infoset includes all information in the parsed XML document considered relevant (Note: Opinions already differ here: should comments count as relevant information?). It also includes additional information, called properties, about each information item: base URI, data type, names of elements and attributes, document position through parent and child properties, and other characteristics. The infoset is not yet a tree; the tree and its nodes are constructed from it.

The Post Schema Validation Infoset – PSVI

If the parser has access to an XML Schema document and can process it, the infoset is validated. This checks document validity and associates information with a schema data type (type annotation). This may be a built-in or user-defined schema type. The validation result is a PSVI (Post Schema Validation Infoset).

Constructing tree nodes from the infoset

Nodes and their tree are now constructed from either an infoset without validation or a PSVI validated against a schema. The main difference lies in the nodes’ associated data types.

A node constructed from an ordinary infoset usually has an unspecific type. An element node, for example, has XML Schema type xs:anyType. Attributes are more complex: the unspecific XPath type xdt:untypedAtomic may be assigned, or another type if the attribute was declared in a DTD as ID, IDREF, NMTOKEN or similar.

With a PSVI-based tree, each validated element and attribute node has a property validity that can be valid, invalid or notKnown. Element nodes that are valid receive the schema type specified by the schema; otherwise they receive xs:anyType. Attributes are handled analogously.

Further information on the data model:
The official description of the XPath data model and node construction from infosets and PSVI is in the W3C specification XQuery 1.0 and XPath 2.0 Data Model (XDM).

   

back to top