XML Information Set (Second Edition) .xml-def {padding-left: 24pt} .xml-syntax {padding-left: 24pt} .deleted {background-color: #FF9999; text-decoration: line-through} XML Information Set (Second Edition) W3C Recommendation 4 February 2004 This version: http://www.w3.org/TR/2004/REC-xml-infoset-20040204 Latest version: http://www.w3.org/TR/xml-infoset Previous version: http://www.w3.org/TR/2003/PER-xml-infoset-20031210 Editors: John Cowan, [email protected] Richard Tobin, [email protected] Please refer to the errata See also translations Copyright W3C ® MIT ERCIM Keio liability trademark document use software licensing Abstract This specification provides a set of definitions for use in other specifications that need to refer to the information in an XML document. This section describes the status of this document at the time of its publication. Other documents may supersede this document. A list of current W3C publications and the latest revision of this technical report can be found in the W3C technical reports index This document is a Recommendation This document updates the Infoset to cover XML 1.1 Namespaces 1.1 W3C XML Activity http://www.w3.org/2003/03/Translations/byTechnology?technology=xml-infoset Documentation of intellectual property possibly relevant to this recommendation may be found at the Working Group's public IPR disclosure page Please report errors in this document to [email protected] archives http://www.w3.org/2001/10/02/xml-infoset-errata.html Contents 1. Introduction 2. Information Items 2.1 The Document Information Item 2.2 Element Information Items 2.3 Attribute Information Items 2.4 Processing Instruction Information Items 2.5 Unexpanded Entity Reference Information Items 2.6 Character Information Items 2.7 Comment Information Items 2.8 The Document Type Declaration Information Item 2.9 Unparsed Entity Information Items 2.10 Notation Information Items 2.11 Namespace Information Items 3. Conformance Appendix A: References Appendix B: XML Reporting Requirements (informative) Appendix C: Example (informative) Appendix D: What is not in the Information Set Appendix E: RDF Schema (informative) 1. Introduction This specification defines an abstract data set called the XML Information Set Infoset [XML] It does not attempt to be exhaustive; the primary criterion for inclusion of an information item or property has been that of expected usefulness in future specifications. Nor does it constitute a minimum set of information that must be returned by an XML processor. An XML document has an information set if it is well-formed and satisfies the namespace constraints described below Information sets may be created by methods (not described in this specification) other than parsing an XML document. See Synthetic Infosets An XML document's information set consists of a number of information items document properties [thus] section 2 The XML Information Set does not require or favor a specific interface or class of interfaces. This specification presents the information set as a modified tree for the sake of clarity and simplicity, but there is no requirement that the XML Information Set be made available through a tree structure; other types of interfaces, including (but not limited to) event-based and query-based interfaces, are also capable of providing information conforming to the XML Information Set. The terms "information set" and "information item" are similar in meaning to the generic terms "tree" and "node", as they are used in computing. However, the former terms are used in this specification to reduce possible confusion with other specific data models. Information items do not In this specification, the words "must", "should", and "may" assume the meanings specified in [RFC2119] XML Versions Different versions of the XML specification may specify different parsing rules. The information set of an XML document is defined to be the one obtained by parsing it according to the rules of the specification whose version corresponds to that of the document. Namespaces XML documents that do not conform to [Namespaces] [Namespaces] Furthermore, this specification does not define an information set for documents which use relative URI references in namespace declarations. This is in accordance with the decision of the W3C XML Plenary Interest Group described in [Relative Namespace URI References] The value of a [namespace name] property is the normalized value of the corresponding namespace attribute; no additional URI escaping is applied to it by the processor. Entities An information set describes its XML document with entity references already expanded, that is, represented by the information items corresponding to their replacement text. However, there are various circumstances in which a processor may not perform this expansion. An entity may not be declared, or may not be retrievable. A non-validating processor may choose not to read all declarations, and even if it does, may not expand all external entities. In these cases an unexpanded entity reference End-of-Line Handling The values of all properties in the Infoset take account of the end-of-line normalization described in [XML] Base URIs Several information items have a [base URI] or [declaration base URI] property. These are computed according to [XML Base] The value of these properties does not reflect any URI escaping that may be required for retrieval of the resource, but it may include escaped characters if these were specified in the document, or returned by a server in the case of redirection. In some cases (such as a document read from a string or a pipe) the rules in [XML Base] When resolving relative URIs the [base URI] property should be used in preference to the values of xml:base attributes; they may be inconsistent in the case of Synthetic Infosets ``Unknown'' and ``No Value'' Some properties may sometimes have the value unknown no value null Inconsistencies Resulting from Invalidity As noted above, an XML document need not be valid to have an information set. However, certain kinds of invalidity affect the values assigned to some properties. Entities, notations, elements and attributes may be undeclared. Notations and elements may be multiply declared (multiple declarations are valid for entities and attributes). An ID may be undefined or multiply defined. Such cases are noted where relevant in the Information Item definitions below. Synthetic Infosets This specification describes the information set resulting from parsing an XML document. Information sets may be constructed by other means, for example by use of an API such as the DOM or by transforming an existing information set. An information set corresponding to a real document will necessarily be consistent in various ways; for example the [in-scope namespaces] property of an element will be consistent with the [namespace attributes] properties of the element and its ancestors. This may not be true of an information set constructed by other means; in such a case there will be no XML document corresponding to the information set, and to serialize it will require resolution of the inconsistencies (for example, by outputting namespace declarations that correspond to the namespaces in scope). 2. Information Items An information set can contain up to eleven different types of information item, as explained in the following sections. Every information item has properties. For ease of reference, each property is given a name, indicated [thus] [XML] 2.1. The Document Information Item XML Definition: document Documents XML Syntax: Document Well-Formed XML Documents There is exactly one document information item The document information item has the following properties: [children] element processing instruction comment document type declaration [document element] element [notations] notation If any notation is multiply declared, this property has no value. [unparsed entities] unparsed entity [base URI] [character encoding scheme] [standalone] [version] [all declarations processed] 2.2. Element Information Items XML Definition: element Logical Structures XML Syntax: Element Logical Structures There is an element information item An element information item has the following properties: [namespace name] [local name] [prefix] [children] element processing instruction unexpanded entity reference character comment [attributes] attribute [namespace attributes] attribute Declarations of the form xmlns="" and xmlns:name="", which undeclare the default namespace and prefixes respectively, count as namespace declarations. Prefix undeclaration was added in Namespaces in XML 1.1 xmlns http://www.w3.org/2000/xmlns/ [in-scope namespaces] namespace xml http://www.w3.org/XML/1998/namespace xmlns except for any representing declarations of the form xmlns="" or xmlns:name="", which do not declare a namespace but rather undeclare the default namespace and prefixes. Synthetic Infosets [base URI] [parent] 2.3. Attribute Information Items XML Definition: attribute Start-Tags, End-Tags, and Empty-Element Tags XML Syntax: Attribute Start-Tags, End-Tags, and Empty-Element Tags There is an attribute information item Attributes declared in the DTD with no default value and not specified in the element's start tag are not represented by attribute information items. An attribute information item has the following properties: [namespace name] [local name] [prefix] [normalized value] 3.3.3 Attribute-Value Normalization [XML] [specified] [attribute type] The value of this property is not affected by the validity of the attribute value. [references] element unparsed entity notation or if the type is NOTATION and there are multiple declarations for the notation, [owner element] 2.4. Processing Instruction Information Items XML Definition: processing instruction Processing Instructions XML Syntax: PI Processing Instructions There is a processing instruction information item A processing instruction information item has the following properties: [target] [content] [base URI] xml:base [notation] notation or there are multiple declarations, [parent] declaration 2.5. Unexpanded Entity Reference Information Items XML Definition: Included If Validating A unexpanded entity reference information item An unexpanded entity reference information item has the following properties: [name] [system identifier] [public identifier] 4.2.2 External Entities [XML] [declaration base URI] [parent] 2.6. Character Information Items XML Syntax: Char Characters There is a character information item Each character is a logically separate information item, but XML applications are free to chunk characters into larger groups as necessary or desirable. A character information item has the following properties: [character code] [element content whitespace] [XML] required or there are multiple declarations, [parent] 2.7. Comment Information Items XML Definition: comment Comments XML Syntax: Comment Comments There is a comment information item A comment information item has the following properties: [content] [parent] 2.8. The Document Type Declaration Information Item XML Definition: document type declaration Prolog and Document Type Declaration XML Syntax: doctypedecl Prolog and Document Type Declaration If the XML document has a document type declaration, then the information set contains a single document type declaration information item A document type declaration information item has the following properties: [system identifier] [public identifier] 4.2.2 External Entities [XML] [children] processing instruction [parent] 2.9. Unparsed Entity Information Items XML Definition: entity Physical Structures XML Syntax: GEDecl Entities There is an unparsed entity information item An unparsed entity information item has the following properties: [name] [system identifier] [public identifier] 4.2.2 External Entities [XML] [declaration base URI] [notation name] [notation] notation or there are multiple declarations, 2.10. Notation Information Items XML Definition: notation Notations XML Syntax: NotationDecl Notations There is a notation information item A notation information item has the following properties: [name] [system identifier] [public identifier] 4.2.2 External Entities [XML] [declaration base URI] 2.11. Namespace Information Items Each element in the document has a namespace information item A namespace information item has the following properties: [prefix] xmlns: xmlns [namespace name] 3. Conformance Since the purpose of the Information Set is to provide a set of definitions, conformance is a property of specifications that use those definitions, rather than of implementations. Specifications referring to the Infoset must: Indicate the information items and properties that are needed to implement the specification. (This indirectly imposes conformance requirements on processors used to implement the specification.) Specify how other information items and properties are treated (for example, they might be passed through unchanged). Note any information required from an XML document that is not defined by the Infoset. Note any difference in the use of terms defined by the Infoset (this should be avoided). If a specification allows the construction of an infoset that has inconsistencies as described above under Synthetic Infosets Appendix A. References Normative References ISO/IEC 10646 ISO (International Organization for Standardization). ISO/IEC 10646-1:2000. Information technology — Universal Multiple-Octet Coded Character Set (UCS) — Part 1: Architecture and Basic Multilingual Plane ISO/IEC 10646-2:2001.Information technology — Universal Multiple-Octet Coded Character Set (UCS) — Part 2: Supplementary Planes http://www.iso.ch Namespaces Namespaces in XML, http://www.w3.org/TR/REC-xml-names Namespaces 1.1 Namespaces in XML 1.1, http://www.w3.org/TR/xml-names11 RFC2119 Key words for use in RFCs to Indicate Requirement Levels, http://www.ietf.org/rfc/rfc2119.txt XML Extensible Markup Language (XML) 1.0 (Third Edition), http://www.w3.org/TR/REC-xml XML 1.1 Extensible Markup Language (XML) 1.1, http://www.w3.org/TR/xml11 XML Base XML Base, http://www.w3.org/TR/xmlbase Informative References DOM Document Object Model (DOM) Level 1 Specification, http://www.w3.org/TR/REC-DOM-Level-1 XPointer-Liaison XPointer-Information Set Liaison Statement, http://www.w3.org/TR/NOTE-xptr-infoset-liaison Relative Namespace URI References Results of W3C XML Plenary Ballot on relative URI References in namespace declarations, 3-17 July 2000, http://www.w3.org/2000/09/xppa RDF Schema for the XML Information Set RDF Schema for the XML Information Set, http://www.w3.org/TR/xml-infoset-rdfs Appendix B: XML Reporting Requirements (informative) Although the XML Recommendation [XML] The reporting requirements include errors, which are outside the scope of this specification, and document information. All of the XML requirements for document information reporting have been integrated into the XML Information Set; numbers in parentheses refer to sections of the XML Recommendation: An XML processor must always provide all characters in a document that are not part of markup to the application (2.10). A validating XML processor must inform the application which of the character data in a document is white space appearing within element content (2.10). An XML processor must normalize line-ends to LF before passing them to the application (2.11). An XML processor must normalize the value of attributes according to the rules in clause 3.3.3 before passing them to the application. An XML processor must pass the names and external identifiers (system identifiers, public identifiers or both) of declared notations to the application (4.7). When the name of an unparsed entity appears as the explicit or default value of an ENTITY or ENTITIES attribute, an XML processor must provide the names, system identifiers, and (if present) public identifiers of both the entity and its notation to the application (4.6, 4.7). An XML processor must pass processing instructions to the application (2.6). An XML processor (necessarily a non-validating one) that does not include the replacement text of an external parsed entity in place of an entity reference must notify the application that it recognized but did not read the entity (4.4.3). A validating XML processor must include the replacement text of an entity in place of an entity reference (5.2). An XML processor must supply the default value of attributes declared in the DTD for a given element type but not appearing in the element's start tag (3.3.2). Appendix C: Example (informative) Consider the following example XML document: <?xml version="1.0"?>
<msg:message doc:date="19990421" xmlns:doc="http://doc.example.org/namespaces/doc" xmlns:msg="http://message.example.org/" >Phone home!</msg:message> The information set for this XML document contains the following information items: A document An element http://message.example.org/ message msg An attribute http://doc.example.org/namespaces/doc date doc 19990421 Three namespace http://www.w3.org/XML/1998/namespace http://doc.example.org/namespaces/doc http://message.example.org/ Two attribute Eleven character Appendix D: What is not in the Information Set The following information is not represented in the current version of the XML Information Set (this list is not intended to be exhaustive): The content models of elements, from ELEMENT declarations in the DTD. The grouping and ordering of attribute declarations in ATTLIST declarations. The document type name. White space outside the document element. White space immediately following the target name of a PI. Whether characters are represented by character references. The difference between the two forms of an empty element: <foo/> <foo></foo> White space within start-tags (other than significant white space in attribute values) and end-tags. The difference between CR, CR-LF, and LF line termination. The order of attributes within a start-tag. The order of declarations within the DTD. The boundaries of conditional sections in the DTD. The boundaries of parameter entities in the DTD. Comments in the DTD. The location of declarations (whether in internal or external subset or parameter entities). Any ignored declarations, including those within an IGNORE conditional section, as well as entity and attribute declarations ignored because previous declarations override them. The kind of quotation marks (single or double) used to quote attribute values. The boundaries of general parsed entities. The boundaries of CDATA marked sections. The default value of attributes declared in the DTD. Appendix E: RDF Schema (informative) See RDF Schema for the XML Information Set