07 April 2004

# Appendix C: Infoset Mapping

Editor:
  Philippe Le Hégaret, W3C

## Table of contents

This appendix contains the mappings between the XML Information Set [XML Information Set] model and the Document Object Model. Starting from a `Document` node, each information item is mapped to its respective `Node`, and each `Node` is mapped to its respective information item. As used in the Infoset specification, the Infoset property names are shown in square brackets, [thus].

Unless specified, the Infoset to DOM node mapping makes no distinction between unknown and no value since both will be exposed as `null` (or `false` if the DOM attribute is of type `boolean`).

## C.1 Document Node Mapping

### C.1.1 Infoset to Document Node

An document information item maps to a `Document` node. The attributes of the corresponding `Document` node are constructed as follows:

Attribute | Value
--- | ---
`Node.nodeName` | `"#document"`
`Node.nodeValue` | `null`
`Node.nodeType` | `Node.DOCUMENT_NODE`
`Node.parentNode` | `null`
`Node.childNodes` | A `NodeList` containing the information items in the [children] property.
`Node.firstChild` | The first node contained in `Node.childNodes`
`Node.lastChild` | The last node contained in `Node.childNodes`
`Node.previousSibling` | `null`
`Node.nextSibling` | `null`
`Node.attributes` | `null`
`Node.ownerDocument` | `null`
`Node.namespaceURI` | `null`
`Node.prefix` | `null`
`Node.localName` | `null`
`Node.baseURI` | same as `Document.documentURI`
`Node.textContent` | `null`
`Document.doctype` | The document type information item
`Document.implementation` | The `DOMImplementation` object used to create this node
`Document.documentElement` | The [document element] property
`Document.inputEncoding` | The [character encoding scheme] property
`Document.xmlEncoding` | `null`
`Document.xmlStandalone` | The [standalone] property, or `false` if the latter has no value.
`Document.xmlVersion` | The [version] property, or `"1.0"` if the latter has no value.
`Document.strictErrorChecking` | `true`
`Document.documentURI` | The [base URI] property
`Document.domConfig` | A `DOMConfiguration` object whose parameters are set to their default values

The [notations], [unparsed entities] properties are being exposed in the `DocumentType` node.

Note: The [all declarations processed] property is not exposed through the `Document` node.

### C.1.2 Document Node to Infoset

A `Document` node maps to an document information item. `Document` nodes with no namespace URI (`Node.namespaceURI` equals to `null`) cannot be represented using the Infoset. The properties of the corresponding document information item are constructed as follows:

Property | Value
--- | ---
[children] | `Node.childNodes`
[document element] | `Document.documentElement`
[notations] | `Document.doctype.notations`
[unparsed entities] | The information items from `Document.doctype.entities`, whose `Node.childNodes` is an empty list
[base URI] | `Document.documentURI`
[character encoding scheme] | `Document.inputEncoding`
[standalone] | `Document.xmlStandalone`
[version] | `Document.xmlVersion`
[all declarations processed] | The value is implementation dependent

## C.2 Element Node Mapping

### C.2.1 Infoset to Element Node

An element information item maps to a `Element` node. The attributes of the corresponding `Element` node are constructed as follows:

Attribute | Value
--- | ---
`Node.nodeName` | same as `Element.tagName`
`Node.nodeValue` | `null`
`Node.nodeType` | `Node.ELEMENT_NODE`
`Node.parentNode` | The [parent] property
`Node.childNodes` | A `NodeList` containing the information items in the [children] property
`Node.firstChild` | The first node contained in `Node.childNodes`
`Node.lastChild` | The last node contained in `Node.childNodes`
`Node.previousSibling` | The information item preceding the current one on the [children] property contained in the [parent] property
`Node.nextSibling` | The information item following the current one on the [children] property contained in the [parent] property
`Node.attributes` | The information items contained in the [attributes] and [namespace attributes] properties
`Node.ownerDocument` | The document information item
`Node.namespaceURI` | The [namespace name] property
`Node.prefix` | The [prefix] property
`Node.localName` | The [local name] property
`Node.baseURI` | The [base URI] property
`Node.textContent` | Concatenation of the `Node.textContent` attribute value of every child node, excluding `COMMENT_NODE` and `PROCESSING_INSTRUCTION_NODE` nodes. This is the empty string if the node has no children.
`Element.tagName` | If the [prefix] property has no value, this contains the [local name] property. Otherwise, this contains the concatenation of the [prefix] property, the colon ':' character, and the [local name] property.
`Element.schemaTypeInfo` | A `TypeInfo` object whose `TypeInfo.typeNamespace` and `TypeInfo.typeName` are inferred from the schema in use if available.

Note: The [in-scope namespaces] property is not exposed through the `Element` node.

### C.2.2 Element Node to Infoset

An `Element` node maps to an element information item. Because the Infoset only represents unexpanded entity references, non-empty `EntityReference` nodes contained in `Node.childNodes` need to be replaced by their content. DOM applications could use the `Document.normalizeDocument()` method for that effect with the "entities" parameter set to `false`. The properties of the corresponding element information item are constructed as follows:

Property | Value
--- | ---
[namespace name] | `Node.namespaceURI`
[local name] | `Node.localName`
[prefix] | `Node.prefix`
[children] | `Node.childNodes`, whose expanded entity references (`EntityReference` nodes with children) have been replaced with their content.
[attributes] | The nodes contained in `Node.attributes`, whose `Node.namespaceURI` value is different from `"http://www.w3.org/2000/xmlns/"`
[namespace attributes] | The nodes contained in `Node.attributes`, whose `Node.namespaceURI` value is `"http://www.w3.org/2000/xmlns/"`
[in-scope namespaces] | The namespace information items computed using the [namespace attributes] properties of this node and its ancestors. If the [DOM Level 3 XPath] module is supported, the namespace information items can also be computed from the `XPathNamespace` nodes.
[base URI] | `Node.baseURI`
[parent] | `Node.parentNode`

## C.3 Attr Node Mapping

### C.3.1 Infoset to Attr Node

An attribute information item map to a `Attr` node. The attributes of the corresponding `Attr` node are constructed as follows:

Attribute/Method | Value
--- | ---
`Node.nodeName` | same as `Attr.name`
`Node.nodeValue` | same as `Attr.value`
`Node.nodeType` | `Node.ATTRIBUTE_NODE`
`Node.parentNode` | `null`
`Node.childNodes` | A `NodeList` containing one `Text` node whose text content is the same as `Attr.value`.
`Node.firstChild` | The `Text` node contained in `Node.childNodes`
`Node.lastChild` | The `Text` node contained in `Node.childNodes`
`Node.previousSibling` | `null`
`Node.nextSibling` | `null`
`Node.attributes` | `null`
`Node.ownerDocument` | The document information item
`Node.namespaceURI` | The [namespace name] property
`Node.prefix` | The [prefix] property
`Node.localName` | The [local name] property
`Node.baseURI` | `null`
`Node.textContent` | the value of `Node.textContent` of the `Text` child. same as `Node.nodeValue` (since this attribute node only contains one `Text` node)
`Attr.name` | If the [prefix] property has no value, this contains the [local name] property. Otherwise, this contains the concatenation of the [prefix] property, the colon ':' character, and the [local name] property.
`Attr.specified` | The [specified] property
`Attr.value` | The [normalized value] property
`Attr.ownerElement` | The [owner element] property
`Attr.schemaTypeInfo` | A `TypeInfo` object whose `TypeInfo.typeNamespace` is `"http://www.w3.org/TR/REC-xml"` and `TypeInfo.typeName` is the [attribute type] property
`Attr.isId` | if the [attribute type] property is ID, this method return `true`

### C.3.2 Attr Node to Infoset

An `Attr` node maps to an attribute information item. `Attr` nodes with no namespace URI (`Node.namespaceURI` equals to `null`) cannot be represented using the Infoset. The properties of the corresponding attribute information item are constructed as follows:

Property | Value
--- | ---
[namespace name] | `Node.namespaceURI`
[local name] | `Node.localName`
[prefix] | `Node.prefix`
[normalized value] | `Attr.value`
[specified] | `Attr.specified`
[attribute type] | Using the `TypeInfo` object referenced from `Attr.schemaTypeInfo`, the value of `TypeInfo.typeName` if `TypeInfo.typeNamespace` is `"http://www.w3.org/TR/REC-xml"`.
[references] | if the computed [attribute type] property is IDREF, IDREFS, ENTITY, ENTITIES, or NOTATION, the value of this property is an ordered list of the element, unparsed entity, or notation information items referred to in the attribute value, in the order that they appear there. The ordered list is computed using `Node.ownerDocument.getElementById`, `Node.ownerDocument.doctype.entities`, and `Node.ownerDocument.doctype.notations`.
[owner element] | `Attr.ownerElement`

## C.4 ProcessingInstruction Node Mapping

### C.4.1 Infoset to ProcessingInstruction Node

A processing instruction information item map to a `ProcessingInstruction` node. The attributes of the corresponding `ProcessingInstruction` node are constructed as follows:

Attribute | Value
--- | ---
`Node.nodeName` | same as `ProcessingInstruction.target`
`Node.nodeValue` | same as `ProcessingInstruction.data`
`Node.nodeType` | `Node.PROCESSING_INSTRUCTION_NODE`
`Node.parentNode` | The [parent] property
`Node.childNodes` | empty `NodeList`
`Node.firstChild` | `null`
`Node.lastChild` | `null`
`Node.previousSibling` | `null`
`Node.nextSibling` | `null`
`Node.attributes` | `null`
`Node.ownerDocument` | The document information item
`Node.namespaceURI` | `null`
`Node.prefix` | `null`
`Node.localName` | `null`
`Node.baseURI` | The [base URI] property of the parent element if any. The [base URI] property of the processing instruction information item is not exposed through the `ProcessingInstruction` node.
`Node.textContent` | same as `Node.nodeValue`
`ProcessingInstruction.target` | The [target] property
`ProcessingInstruction.data` | The [content] property

### C.4.2 ProcessingInstruction Node to Infoset

A `ProcessingInstruction` node maps to an processing instruction information item. The properties of the corresponding processing instruction information item are constructed as follows:

Property | Value
--- | ---
[target] | `ProcessingInstruction.target`
[content] | `ProcessingInstruction.data`
[base URI] | `Node.baseURI` (which is equivalent to the base URI of its parent element if any)
[notation] | The `Notation` node named by the target and if available from `Node.ownerDocument.doctype.notations`
[parent] | `Node.parentNode`

## C.5 EntityReference Node Mapping

### C.5.1 Infoset to EntityReference Node

An unexpanded entity reference information item maps to a `EntityReference` node. The attributes of the corresponding `EntityReference` node are constructed as follows:

Attribute | Value
--- | ---
`Node.nodeName` | The [name] property
`Node.nodeValue` | `null`
`Node.nodeType` | `Node.ENTITY_REFERENCE_NODE`
`Node.parentNode` | the [parent] property
`Node.childNodes` | Empty `NodeList`
`Node.firstChild` | `null`
`Node.lastChild` | `null`
`Node.previousSibling` | `null`
`Node.nextSibling` | `null`
`Node.attributes` | `null`
`Node.ownerDocument` | The document information item
`Node.namespaceURI` | `null`
`Node.prefix` | `null`
`Node.localName` | `null`
`Node.baseURI` | The [declaration base URI] property
`Node.textContent` | `null` (the node has no children)

Note: The [system identifier] and [public identifier] properties are not exposed through the `EntityReference` node, but through the `Entity` node reference from this `EntityReference` node, if any.

### C.5.2 EntityReference Node to Infoset

An `EntityReference` node maps to an unexpanded entity reference information item. `EntityReference` nodes with children (`Node.childNodes` contains a non-empty list) cannot be represented using the Infoset. The properties of the corresponding unexpanded entity reference information item are constructed as follows:

Property | Value
--- | ---
[name] | `Node.nodeName`
[system identifier] | The `Entity.systemId` value of the `Entity` node available from `Node.ownerDocument.doctype.entities` if available
[public identifier] | The `Entity.publicId` value of the `Entity` node available from `Node.ownerDocument.doctype.entities` if available
[declaration base URI] | `Node.baseURI`
[parent] | `Node.parentNode`

## C.6 Text and CDATASection Nodes Mapping

Since the [XML Information Set] doesn't represent the boundaries of CDATA marked sections, `CDATASection` nodes cannot occur from an infoset mapping.

### C.6.1 Infoset to Text Node

Consecutive character information items map to a `Text` node. The attributes of the corresponding `Text` node are constructed as follows:

Attribute/Method | Value
--- | ---
`Node.nodeName` | `"#text"`
`Node.nodeValue` | same as `CharacterData.data`
`Node.nodeType` | `Node.TEXT_NODE`
`Node.parentNode` | The [parent] property
`Node.childNodes` | empty `NodeList`
`Node.firstChild` | `null`
`Node.lastChild` | `null`
`Node.previousSibling` | `null`
`Node.nextSibling` | `null`
`Node.attributes` | `null`
`Node.ownerDocument` | The document information item
`Node.namespaceURI` | `null`
`Node.prefix` | `null`
`Node.localName` | `null`
`Node.baseURI` | null
`Node.textContent` | same as `Node.nodeValue`
`CharacterData.data` | A `DOMString` including all [character code] contained in the character information items
`CharacterData.length` | The number of 16-bit units needed to encode all ISO 10646 character code contained in the character information items using the UTF-16 encoding.
`Text.isElementContentWhitespace` | The [element content whitespace] property
`Text.wholeText` | same as `CharacterData.data`

Note: By construction, the values of the [parent] and [element content whitespace] properties are necessarily the sames for all consecutive character information items.

### C.6.2 Text and CDATASection Nodes to Infoset

The text content of a `Text` or a `CDATASection` node maps to a sequence of character information items. The number of items is less or equal to `CharacterData.length`. Text nodes contained in `Attr` nodes are mapped to the Infoset using the `Attr.value` attribute. Text nodes contained in `Document` nodes cannot be represented using the Infoset. The properties of the corresponding character information items are constructed as follows:

Property | Value
--- | ---
[character code] | The ISO 10646 character code produced using one or two 16-bit units from `CharacterData.data`
[element content whitespace] | `Text.isElementContentWhitespace`
[parent] | `Node.parentNode`

## C.7 Comment Node Mapping

### C.7.1 Infoset to Comment Node

A comment information item maps to a `Comment` node. The attributes of the corresponding `Comment` node are constructed as follows:

Attribute | Value
--- | ---
`Node.nodeName` | `"#comment"`
`Node.nodeValue` | same as `CharacterData.data`
`Node.nodeType` | `Node.COMMENT_NODE`
`Node.parentNode` | The [parent] property
`Node.childNodes` | empty `NodeList`
`Node.firstChild` | `null`
`Node.lastChild` | `null`
`Node.previousSibling` | `null`
`Node.nextSibling` | `null`
`Node.attributes` | `null`
`Node.ownerDocument` | The document information item
`Node.namespaceURI` | `null`
`Node.prefix` | `null`
`Node.localName` | `null`
`Node.baseURI` | `null`
`Node.textContent` | same as `Node.nodeValue`
`CharacterData.data` | The [content] property encoded using the UTF-16 encoding.
`CharacterData.length` | The number of 16-bit units needed to encode all ISO character code contained in the [content] property using the UTF-16 encoding.

### C.7.2 Comment Node to Infoset

A `Comment` maps to a comment information item. The properties of the corresponding comment information item are constructed as follows:

Property | Value
--- | ---
[content] | `CharacterData.data`
[parent] | `Node.parentNode`

## C.8 DocumentType Node Mapping

### C.8.1 Infoset to DocumentType Node

A document type declaration information item maps to a `DocumentType` node. The attributes of the corresponding `DocumentType` node are constructed as follows:

Attribute | Value
--- | ---
`Node.nodeName` | same as `DocumentType.name`
`Node.nodeValue` | `null`
`Node.nodeType` | `Node.DOCUMENT_TYPE_NODE`
`Node.parentNode` | The [parent] property
`Node.childNodes` | empty `NodeList`
`Node.firstChild` | `null`
`Node.lastChild` | `null`
`Node.previousSibling` | `null`
`Node.nextSibling` | `null`
`Node.attributes` | `null`
`Node.ownerDocument` | The document information item
`Node.namespaceURI` | `null`
`Node.prefix` | `null`
`Node.localName` | `null`
`Node.baseURI` | `null`
`Node.textContent` | `null`
`DocumentType.name` | The name of the document element.
`DocumentType.entities` | The [unparsed entities] property available from the document information item.
`DocumentType.notations` | The [notations] property available from the document information item.
`DocumentType.publicId` | The [public identifier] property
`DocumentType.systemId` | The [system identifier] property
`DocumentType.internalSubset` | The value is implementation dependent

Note: The [children] property is not exposed through the `DocumentType` node.

### C.8.2 DocumentType Node to Infoset

A `DocumentType` maps to a document type declaration information item. The properties of the corresponding document type declaration information item are constructed as follows:

Property | Value
--- | ---
[system identifier] | `DocumentType.systemId`
[public identifier] | `DocumentType.publicId`
[children] | The value of this property is implementation dependent
[parent] | `Node.parentNode`

## C.9 Entity Node Mapping

### C.9.1 Infoset to Entity Node

An unparsed entity information item maps to a `Entity` node. The attributes of the corresponding `Entity` node are constructed as follows:

Attribute | Value
--- | ---
`Node.nodeName` | The [name] property
`Node.nodeValue` | `null`
`Node.nodeType` | `Node.ENTITY_NODE`
`Node.parentNode` | `null`
`Node.childNodes` | Empty `NodeList`
`Node.firstChild` | `null`
`Node.lastChild` | `null`
`Node.previousSibling` | `null`
`Node.nextSibling` | `null`
`Node.attributes` | `null`
`Node.ownerDocument` | The document information item
`Node.namespaceURI` | `null`
`Node.prefix` | `null`
`Node.localName` | `null`
`Node.baseURI` | The [declaration base URI] property
`Node.textContent` | `""` (the node has no children)
`Entity.publicId` | The [public identifier] property
`Entity.systemId` | The [system identifier] property
`Entity.notationName` | The [notation name] property
`Entity.inputEncoding` | `null`
`Entity.xmlEncoding` | `null`
`Entity.xmlVersion` | `null`

Note: The [notation] property is available through the `DocumentType` node.

### C.9.2 Entity Node to Infoset

An `Entity` node maps to an unparsed entity information item. `Entity` nodes with children (`Node.childNodes` contains a non-empty list) cannot be represented using the Infoset. The properties of the corresponding unparsed entity information item are constructed as follows:

Property | Value
--- | ---
[name] | `Node.nodeName`
[system identifier] | `Entity.systemId`
[public identifier] | `Entity.publicId`
[declaration base URI] | `Node.baseURI`
[notation name] | `Entity.notationName`
[notation] | The `Notation` node referenced from `DocumentType.notations` whose name is the [notation name] property

## C.10 Notation Node Mapping

### C.10.1 Infoset to Notation Node

A notation information item maps to a `Notation` node. The attributes of the corresponding `Notation` node are constructed as follows:

Attribute | Value
--- | ---
`Node.nodeName` | The [name] property
`Node.nodeValue` | `null`
`Node.nodeType` | `Node.NOTATION_NODE`
`Node.parentNode` | `null`
`Node.childNodes` | Empty `NodeList`
`Node.firstChild` | `null`
`Node.lastChild` | `null`
`Node.previousSibling` | `null`
`Node.nextSibling` | `null`
`Node.attributes` | `null`
`Node.ownerDocument` | The document information item
`Node.namespaceURI` | `null`
`Node.prefix` | `null`
`Node.localName` | `null`
`Node.baseURI` | The [declaration base URI] property
`Node.textContent` | `null`
`Notation.publicId` | The [public identifier] property
`Notation.systemId` | The [system identifier] property

### C.10.2 Notation Node to Infoset

A `Notation` maps to a notation information item. The properties of the corresponding notation information item are constructed as follows:

Property | Value
--- | ---
[name] | `Node.nodeName`
[system identifier] | `Notation.systemId`
[public identifier] | `Notation.publicId`
[parent] | `Node.parentNode`