How XML Infoset Defines XML Document Properties
The XML Information Set (Infoset) is a W3C specification that defines an abstract data model for representing the logical structure of a well-formed XML document. Rather than viewing an XML file as a sequence of raw characters, tags, and delimiters, the Infoset describes the document as a structured collection of distinct “information items,” each with an associated set of named properties. This article explains the fundamental concepts of the XML Infoset, breaks down its core information items, details how properties are defined, and highlights why this abstraction is essential for modern XML technologies.
The Purpose of the XML Infoset
Before the Infoset specification, XML standards lacked a uniform definition of what constituted an XML document’s data model. The physical representation of XML involves specific serialization details such as single versus double quotes around attributes, character references, and character encodings. The XML Infoset standardizes the logical data conveyed by an XML document, removing these physical syntax variations to create a clean, tree-structured abstract model that downstream specifications like XPath, XQuery, DOM, and XML Schema can consistently reference.
Information Items and Their Properties
An XML document’s Infoset consists of a tree of information items. Each item represents a distinct logical component of the XML document, and each component possesses a set of abstract properties. There are eleven standard types of information items defined by the specification:
- Document Information Item: Represents the entire
XML document and acts as the root of the Infoset tree. Its properties
include
[children](an ordered list containing processing instructions, comments, and exactly one element item),[document element](the root element),[character encoding scheme], and[standalone]status. - Element Information Items: Represent the
tags/elements within the document. Key properties include:
[local name]: The local part of the element name.[namespace URI]: The namespace URI, if defined.[prefix]: The prefix associated with the namespace.[children]: An ordered list of child element, character, comment, and processing instruction items.[attributes]: An unordered set of attribute information items.[in-scope namespaces]: The set of namespace declarations active on the element.[parent]: The parent element or document item.
- Attribute Information Items: Represent element
attributes. Properties include
[local name],[namespace URI],[prefix],[normalized value],[specified](indicating if it was explicitly written or defaulted via DTD), and[attribute type]. - Character Information Items: Represent individual
characters within element content or CDATA sections. Properties include
[character code](the ISO/IEC 10646 code point) and[element content whitespace](a boolean flag indicating if the whitespace is purely formatting). - Other Information Items: The specification also defines items for Processing Instructions, Comments, Document Type Declarations (DTD), Unparsed Entities, Notations, and Namespace Declarations.
How Properties Are Abstracted
The Infoset defines properties by focusing on logical equivalence rather than literal text:
- Entity Reference Resolution: Entity references
(
&, custom entities) are expanded into their corresponding character or element items; the boundary of the entity itself is not preserved as a separate information item. - Attribute Value Normalization: White-space
characters in attributes are normalized according to XML rules before
being assigned to the
[normalized value]property. - Namespace Resolution: Prefixes are mapped to actual
namespace URIs, enabling consumers of the Infoset to evaluate identity
using
[local name]and[namespace URI]pairs (QNames) rather than relying on arbitrary lexical prefixes. - Exclusion of Syntactic Sugar: Details such as
whether an empty tag is written as
<item/>or<item></item>, the order of attributes, and the specific quotes used ('or") are omitted from the Infoset entirely.
Importance in XML Processing
By defining XML documents in terms of abstract properties, the Infoset ensures that XML processors can work against a predictable, implementation-agnostic data model. Specifications such as XPath 2.0/XQuery 1.0 Data Model (XDM), SOAP message structures, and Canonical XML rely heavily on the Infoset definition to guarantee that documents with identical logical information are treated identically, regardless of how they are serialized on disk or across a network.