XML Infoset Schema Defaulted Attributes
This article explains how the XML Information Set (Infoset) handles
attribute information items that originate from default values defined
in a DTD or XML Schema. In the XML Infoset, defaulted attributes are
represented as standard attribute information items attached to an
element, but they are specifically marked with a
[specified] property set to false to indicate
that their values were inferred rather than explicitly written in the
source document.
Representation in the Information Set
When an XML processor performs schema or DTD validation, it supplements the document’s Infoset with any missing attributes that have default values declared in the schema. In the resulting Infoset:
- Inclusion in
[attributes]: The defaulted attribute is added to the[attributes]property of the parent element information item. To a consumer reading the set of attributes, it appears in the same collection as explicitly authored attributes. - The
[specified]Flag: The primary mechanism for distinguishing defaulted attributes from explicit attributes is the boolean[specified]property. For an attribute supplied via a schema default,[specified]is set tofalse. For attributes explicitly declared in the XML document instance,[specified]is set totrue. - Value and Name Properties: The item’s
[local name],[namespace name], and[prefix]are populated according to the schema definition. The[normalized value]property contains the default value string after schema-defined whitespace normalization. - Owner Element: The
[owner element]property points directly to the element information item that contains the defaulted attribute, maintaining the structural hierarchy of the tree.
Role of the Post-Schema-Validation Infoset (PSVI)
In XML Schema processing, the creation of defaulted attribute items is formalized during the creation of the Post-Schema-Validation Infoset (PSVI). The PSVI augments the basic Infoset by:
- Inserting the missing attribute information items with their default values.
- Setting the
[validation attempted]and[validity]properties to record that the defaulted attribute conforms to the schema. - Attaching type definition properties (such as
[type definition]) to supply the data type associated with the default value.
Implications for Applications
Because defaulted attributes are integrated directly into the
[attributes] set of an element, standard XML processing
technologies—such as XPath, XSLT, and DOM Level 3 Core—can query and
access defaulted attributes transparently. Applications requiring
knowledge of the original source text can inspect the
[specified] property to determine whether the value was
provided by the author or generated by the schema processor.