InformIT

Exploring the XML Infoset

Date: Jun 6, 2003

Sample Chapter is provided courtesy of Addison-Wesley Professional.

Return to the article

Ken Sall explains the XML Information Set, which is used for describing the common set of items that are relevant across many XML specifications.

XML Information Set, often called simply Infoset, is an attempt to define a set of terms that other W3C specifications (and presumably specs from other organizations) can use to refer to the information chunks in a well-formed (but not necessarily valid) XML document. The Infoset is partly defined by what it isn't as well; it does not attempt to define a complete set of information, nor does it represent the minimal information that an XML processor should return to an application. The initial working draft was published in May 1999; XML Information Set became a W3C Recommendation in October 2001, located at http://www.w3.org/TR/xml-infoset/.

An information set is the collection of information items of a particular XML document. An information item is an abstract model of a portion of an XML document that is characterized by certain properties, denoted in bold, square brackets in the spec (e.g., [children]). Some properties are characteristic of more than one kind of information item (e.g., [local name] applies to element and attribute information items), while others are unique to a specific information item type (e.g., [document element] applies only to the document information item). There are eleven kinds of information items, described in the next subsection "What's In the Infoset?"

While valid documents also may have an information set, any document that is well-formed and meets XML namespace constraints described in the Infoset specification has an information set. Documents that do not conform to the Namespaces in XML Recommendation cannot have meaningful information sets, even though they may be well-formed. In cases where an XML processor, especially a validating parser, expands entity references, there are information items that contain the replacement text. Since a nonvalidating parser is not required1 to do this expansion, there is a special information item called an unexpanded entity reference information item.

Conformance with the XML Information Set specification is really a matter of concern for the other specifications that use Infoset definitions. Specifications that reference the Infoset must:

What's in the Infoset?

The eleven information items described by the Infoset are shown in Table 5-2. For each, a representative sample of properties is listed. Refer to the specification for details and a complete list of properties and more detailed descriptions.

TABLE 5-2 Information Items and Selected Properties

Name

Description and Selected Properties in [ ]

Document Information Item

There is always exactly one document information item, which is the single root from which all other information items are accessible (directly or indirectly) via properties. Note: This is not the item corresponding to the document element, although that element is one of the properties of this item. Properties mainly pertain to the XML prolog, including [children], [document element], [base URI], [character encoding scheme], [version] and [standalone]. The [document element] property identifies the unique document element, which is the root of all elements in the document. The [children] property is an ordered list of information items containing one element (the document element), plus one information item for each processing instruction or comment that appears outside the document element. If there is a document type declaration, then one child is the document type declaration information item described later in this table.

Element Information Items

There is one element information item for each element in the document, including one for the unique document element, through whose [children] property all other elements are reachable. Properties include [namespace name], a URI or possibly no value,a [local name], [prefix], [children], an ordered list in document order of element, processing instruction, unexpanded entity reference, character, and comment information items that are immediate children, [attributes], an unordered possibly empty set, [namespace attributes], [in-scope namespaces], [base URI], and [parent].

Attribute Information Items

There is one attribute information item for each attribute of each element, including any attributes from the DTD with default values that are not explicit in the XML document. Properties include [namespace name], [local name], [prefix], [normalized value], [specified], a flag designating

Attribute Information Items (continued)

whether the attribute was explicit in the owner element's start tag, [attribute type], one of the 10 values such as ID, IDREF, CDATA, NMTOKEN, ENUMERATION, [references], meaningful only for certain attribute types such as IDREF or ENTITY, and [owner element], the element whose start tag contains the attribute.

Processing Instruction Information Items

There is one of these for each PI. The XML declaration is not considered a processing instruction. Properties include [target], the application to receive the data, [content], the PI's data such as name/value pairs, and [parent], the item that contains this item in its [children] property.

Unexpanded Entity Reference Information Items

Items of this type serve as placeholders for XML processors (primarily nonvalidating parsers) to indicate which external parsed entities have not been expanded. Properties include [name], the entity referenced, [system identifier], and [public identifier].

Character Information Items

There is a character information item for each character in the document, although applications are free to combine contiguous characters. This applies to #PCDATA content of elements, CDATA sections, and character entity references. Properties include [character code], [element content whitespace], a flag indicating true if the character is white space within element content, and [parent], which is always an element information item.

Comment Information Items

There is one of these for each comment in the instance document, but not for comments in the DTD. Properties are [content] and [parent].

Document Type Declaration Information Item

There is at most one document type declaration information item, if and only if the document has a document type declaration. Properties are [system identifier] of the external subset (if any), [public identifier] of the external subset (if any), [children], which in this context is the ordered list of processing instructions from the DTD, and [parent], the document information item that contains this item.

Unparsed Entity Information Items

This information item pertains to unparsed general entities declared in the DTD, which relate to notations. Properties include [name], [system identifier], [public identifier], [notation name], and [notation].

Notation Information Items

This information item applies to notations declared in the DTD, used to represent binary data (e.g., images) or other non-XML data. Properties include [name], [system identifier], and [public identifier].

Namespace Information Items

Each element has a namespace information item for every in-scope namespace, identified by the [in-scope namespaces] property of the element information item. Properties are [prefix], the portion that follows xmlns: prefix (or no value if the attribute name is xmlns denoting the default namespace) and [namespace name], the URI to which the prefix is bound. Namespace information items are what we have called xmlns attributes earlier in this chapter.


What's Not in the Infoset?

Appendix D of the XML Information Set Recommendation presents a nonexhaustive list of about twenty items not within scope (http://www.w3.org/TR/xml-infoset/#omitted). A sampling of the list is illustrative of what the Infoset does not attempt to define.

Keep this list in mind as we discuss Canonical XML shortly. Although the XML Information Set specification does not refer to Canonical XML, there is mention of Infoset in the Canonical XML specification.

Summary

In this chapter, we learned about Namespaces in XML, XML Information Set, and Canonical XML, three specifications that at least at one time were the the work of the W3C XML Core Working Group. All three of these specifications followed the XML 1.0 Recommendation, attempting to address particular areas that are fundamental. The main points covered are:

For Further Exploration

Articles

XML.com: Namespace Nuances (July 2001)

http://www.xml.com/pub/a/2001/07/05/
namespaces.html

19 Short Questions about Namespaces (with Answers), David Megginson







http://xml.coverpages.org/megginsonNSFAQ.html

RDDL Me This: What Does a Namespace Locate?

http://xml.oreilly.com/news/xmlnut2_0201.html

Namespace Myths Exploded, Ronald Bourret [highly recommended]

http://www.xml.com/pub/a/2000/03/08/namespaces/index.html

Clean XML Namespacing Pattern

http://www.tbradford.org/clean-namespaces.txt

Namespaces in XML: Best Practices, Risky Business, Simon St. Laurent

http://www.simonstl.com/articles/namespaces/index.html

Resources

Resource Directory Description Language (RDDL)

http://www.rddl.org/

ZVON: Namespaces Tutorial

http://www.zvon.org/xxl/NamespaceTutorial/Output/index.html

XML Namespace FAQ, Ronald Bourret [highly recommended especially for fine points]

http://www.rpbourret.com/xml/NamespacesFAQ.htm

Robin Cover: Namespaces in XML

http://xml.coverpages.org/namespaces.html

ZVON: List of Namespaces

http://zvon.org/index.php?nav_id=172

xmlhack: Namespace Category of Articles

http://xmlhack.com/list.php?cat=7

xmlhack: XML Information Set: Search of Articles

http://xmlhack.com/search.php?q=infoset&s=Search+site

xmlhack: Canonical XML: Category of Articles

http://xmlhack.com/search.php?q=canonical&s=Search+site

ElCel Technology: xmlvalid and xmlcanon [very useful standalone validator and canonical XML processors with namespace support]

http://www.elcel.com/products/

W3C Specifications and Information

XML Core Working Group

http://www.w3.org/XML/Activity.html#core-wg

Namespaces in XML [Recommendation, January 1999]

http://www.w3.org/TR/REC-xml-names/

XML Information Set (Infoset) [Recommendation, October 2001]

http://www.w3.org/TR/xml-infoset/

Canonical XML [Recommendation, March 2001]

http://www.w3.org/TR/xml-c14n

XML Signature Working Group

http://www.w3.org/Signature/

XML-Signature Syntax and Processing [Proposed Recommendation, August 2001]

http://www.w3.org/TR/xmldsig-core/

XML Fragment Interchange [Candidate Recommendation, February 2001]

http://www.w3.org/TR/xml-fragment

XML Base [Recommendation, June 2001]

http://www.w3.org/TR/xmlbase/

XML Inclusions (XInclude) Version 1.0 [Working Draft, May 2001]

http://www.w3.org/TR/xinclude/

800 East 96th Street, Indianapolis, Indiana 46240