This appendix contains the changes from the 1 October 1998 specification.
Each document contains zero or one doctype nodes, one root element node, and zero or more comments or processing instructions; the root element serves as the root of the element tree for the document.
One important property of DOM structure models is structural isomorphism: if any two Document Object Model implementations are used to create a representation of the same document, they will create the same structure model, with precisely the same objects and relationships.
One important property of DOM structure models is structural isomorphism: if any two Document Object Model implementations are used to create a representation of the same document, they will create the same structure model, in accordance with the XML Information Set [Infoset].
Note: There may be some variations depending on the parser being used to build the DOM. For instance, the DOM may not contain whitespaces in element content if the parser discards them.
The Document Object Model does not define "the true inner semantics" of XML or HTML. The semantics of those languages are defined by W3C Recommendations for these languages. The DOM is a programming model designed to respect these semantics. The DOM does not have any ramifications for the way you write XML and HTML documents; any document that can be written in these languages can be represented in the DOM.
The Document Object Model does not define what information in a document is relevant or how information in a document is structured. For XML, this is specified by the W3C XML Information Set [Infoset]. The DOM is simply an API to this information set.
DOMString type was defined as "a sequence of
16-bit quantities". Instead, it is now defined as "sequence of
16-bit units".
Please note that for both HTML and XML, the document character
set (and therefore the notation of numeric character
references) is based on UCS-4. A single numeric character
reference in a source document may therefore in some cases
correspond to two array positions in a DOMString
(a high surrogate and a low surrogate).
Please note that for both HTML and XML, the document
character set (and therefore the notation of numeric
character references) is based on UCS [ISO-10646]. A single
numeric character reference in a source document may
therefore in some cases correspond to two 16-bit units in a
DOMString (a high surrogate and a low
surrogate).
For the purposes of the DOM, string matching takes place on a character code by character code basis, on the 16 bit value of a DOMString. As such, the DOM assumes that any normalizations will take place in the processor, before the DOM structures are built.
For the purposes of the DOM, string matching is performed purely by binary comparison of the 16-bit units of the DOMString. In addition, the DOM assumes that any normalizations take place in the processor, before the DOM structures are built.
Note: Besides case folding, there are additional normalizations that can be applied to text. The W3C I18N Working Group is in the process of defining exactly which normalizations are necessary, and where they should be applied. The W3C I18N Working Group expects to require early normalization, which means that data read into the DOM is assumed to already be normalized. The DOM and applications built on top of it in this case only have to assure that text remains normalized when being changed. For further details, please see [Charmod].
value attribute
raises a NO_MODIFICATION_ALLOWED_ERR DOMException
when the node is readonly was added.value attribute:
See also the methodgetAttributeon theElementinterface.
I.e. any characters that an XML processor would recognize as markup are instead treated as literal text. See also the methodsetAttributeon theElementinterface.
specified attribute:If the attribute is not associated to any element (i.e. because it was just created or was obtained from some removal or cloning operation)specifiedistrue.
As explained in the DOMString interface, text
strings in the DOM are represented in UTF-16, i.e. as a sequence
of 16-bit units. In the following, the term 16-bit units is used whenever
necessary to indicate that indexing on CharacterData is done in
16-bit units.
length attribute
read:
The number of characters that are available through data and
the substringData method below.
The number of 16-bit
units that are available through data and the
substringData method below.
count parameter of the
substringData method read:The number of characters to extract.
The number of 16-bit units to extract.
The specified substring. If the sum ofoffsetandcountexceeds thelength, then all characters to the end of the data are returned.
The specified substring. If the sum ofoffsetandcountexceeds thelength, then all 16-bit units to the end of the data are returned.
Raised if the specifiedoffsetis negative or greater than the number of characters in data, or if the specifiedcountis negative.
Raised if the specifiedoffsetis negative or greater than the number of 16-bit units in data, or if the specifiedcountis negative.
insertData method read:Insert a string at the specified character offset.
Insert a string at the specified 16-bit unit offset.
offset parameter
read:The character offset at which to insert.
The 16-bit unit offset at which to insert.
Raised if the specifiedoffsetis negative or greater than the number of characters in data, or if the specifiedcountis negative.
Raised if the specifiedoffsetis negative or greater than the number of 16-bit units in data, or if the specifiedcountis negative.
deleteData method read:Remove a range of characters from the node.
Remove a range of 16-bit units from the node.
count parameter
read:The number of characters to delete. If the sum ofoffsetandcountexceedslengththen all characters fromoffsetto the end of the data are deleted.
The number of 16-bit units to delete. If the sum ofoffsetandcountexceedslengththen all 16-bit units fromoffsetto the end of the data are deleted.
replaceData method read:Replace the characters starting at the specified character offset with the specified string.
Replace the characters starting at the specified 16-bit unit offset with the specified string.
count parameter
read:The number of characters to replace. If the sum ofoffsetandcountexceedslength, then all characters to the end of the data are replaced
The number of 16-bit units to replace. If the sum ofoffsetandcountexceedslength, then all 16-bit units to the end of the data are replaced
Raised if the specifiedoffsetis negative or greater than the number of characters in data, or if the specifiedcountis negative.
Raised if the specifiedoffsetis negative or greater than the number of 16-bit units in data, or if the specifiedcountis negative.
feature parameter
read:The package name of the feature to test. In Level 1, the legal values are "HTML" and "XML" (case-insensitive).
The name of the feature to test (case-insensitive). The values used by DOM features are defined throughout this specification and listed i n the Compliance section. The name must be an XML name. To avoid possible conflicts, as a convention, names referring to features defined outside the DOM specification should be made unique by reversing the name of the Internet domain name of the person (or the organization that the person belongs to) who defines the feature, component by component, and using this as a prefix. For instance, the W3C SYMM Working Group defines the feature "org.w3c.dom.smil".
version parameter
read:This is the version number of the package name to test. In Level 1, this is the string "1.0".
This is the version number of the feature to test. In Level 1, this is the string "1.0".
createElement method
was missing the following piece:In addition, if there are known attributes with default values, Attr nodes representing them are automatically created and attached to the element.
createEntityReference method
was missing the following piece:In addition, if the referenced entity is known, the child list of theEntityReferencenode is made the same as that of the correspondingEntitynode.
doctype attribute was
missing the following piece:The DOM Level 1 does not support editing the Document Type Declaration, thereforedocTypecannot be altered in any way, including through the use of methods, such asinsertNodeorremoveNode, which are inherited from theNodeinterface.
createAttribute method was
said to be:Creates anAttrof the given name. Note that theAttrinstance can then be set on anElementusing thesetAttributemethod.
Creates anAttrof the given name. Note that theAttrinstance can then be set on anElementusing thesetAttributeNodemethod.
The value of the attribute is the emtpy string.
createElement, createAttribute,
createEntityReference and
createProcessingInstruction methods was said to
be:Raised if the specified name contains an invalid character.
Raised if the specified name contains an illegal character.
entities attribute has been
modified:
A NamedNodeMap containing the general entities, both
external and internal, declared in the DTD. Duplicates are
discarded.
A NamedNodeMap containing the general entities, both
external and internal, declared in the DTD. Parameter entities
are not contained. Duplicates are discarded.
the interface provides access to<!DOCTYPE ex SYSTEM "ex.dtd" [ <!ENTITY foo "foo"> <!ENTITY bar "bar"> <!ENTITY % baz "baz"> ]> <ex/>fooandbarbut notbaz. [ ...]
the interface provides access to<!DOCTYPE ex SYSTEM "ex.dtd" [ <!ENTITY foo "foo"> <!ENTITY bar "bar"> <!ENTITY bar "bar2"> <!ENTITY % baz "baz"> ]> <ex/>fooand the first declaration ofbarbut not the second declaration ofbarorbaz. [...]
By far the vast majority of objects (apart from text) that authors encounter when traversing a document areElementnodes. Assume the following XML document:<elementExample id="demo"> <subelement1/> <subelement2><subsubelement/></subelement2> </elementExample>
When represented using DOM, the top node is aDocumentnode containing anElementnode for "elementExample" which contains two childElementnodes, one for "subelement1" and one for "subelement2". "subelement1" contains no child nodes.
The Element interface represents an element in an
HTML or XML document.
the generic Node interface method getAttributes
may be used to retrieve the set of all attributes for an
element.getAttributes method per
se, although it may exist in some language binding such as the
java one. So this section now reads:
the generic Node interface attribute attributes
may be used to retrieve the set of all attributes for an
element.removeAttribute method description read:If the removed attribute has a default value it is immediately replaced.
If the removed attribute is known to have a default value, an attribute immediately appears containing the default value.
removeAttributeNode method description read:Removes the specified attribute.
Removes the specified attribute. If the removed Attr
has a default value it is immediately replaced.
oldAttr has been chagned
according to the previous change:TheAttrnode to remove from the attribute list. If the removedAttrhas a default value it is immediately replaced.
The Attr node to remove from the attribute list.
normalize method:Note: In cases where the document contains
CDATASections, the normalize operation alone may not be sufficient, since XPointers do not differentiate betweenTextnodes andCDATASectionnodes.
Puts allTextnodes in the full depth of the sub-tree underneath thisElementinto a "normal" form where only markup (e.g., tags, comments, processing instructions, CDATA sections, and entity references) separatesTextnodes, i.e., there are no adjacentTextnodes.
Puts allTextnodes in the full depth of the sub-tree underneath thisElement, including attribute nodes, into a "normal" form where only markup (e.g., tags, comments, processing instructions, CDATA sections, and entity references) separatesTextnodes, i.e., there are no adjacentTextnodes.
setAttribute method was said to be:Raised if the specified name contains an invalid character.
Raised if the specified name contains an illegal character.
setAttributeNode was said to be:Adds a new attribute.
Adds a new attribute node.
setAttributeNode return value
was said to be:If thenewAttrattribute replaces an existing attribute with the same name, the previously existingAttrnode is returned, otherwisenullis returned.
If thenewAttrattribute replaces an existing attribute, the replacedAttrnode is returned, otherwisenullis returned.
ExceptionCode group:
Note: Other numeric codes are reserved for W3C for possible future use.
If an invalid character is specified, such as in a name.
If an invalid or illegal character is specified, such as in a name. See production 2 in the XML specification for the definition of a legal character, and production 5 for the definition of a legal name character.
setNamedItem was missing (moved
from the description of the arg parameter):
If a node with that name is already present in this map, it is replaced by the new one.
removeNamedItem method read:The node removed from the map or null if no node with such a name exists.
The node removed from the map if a node with such a name exists.
removeNamedItem method
now includes the following note that was missing:When this map contains the attributes attached to an element, if the removed attribute is known to have a default value, an attribute immediately appears containing the default value.
removeNamedItem
method raises a NO_MODIFICATION_ALLOWED_ERR
DOMException when the NamedNodeMap is
readonly.nodeValue
attribute that setting it, when it is defined to be
null, has no effect.parentNode attribute that Entity and
Notation nodes do not have a parent.NodeType
group:Numeric codes up to 200 are reserved to W3C for possible future use.
The content of the returnedNodeListis "live" in the sense that, for instance, changes to the children of the node object that it was created from are immediately reflected in the nodes returned by theNodeListaccessors; it is not a static snapshot of the content of the node. This is true for everyNodeList, including the ones returned by thegetElementsByTagNamemethod.
insertBefore method read:
Raised if this node is readonly.
Raised if this node is readonly or if the parent of the node being inserted is readonly.
replaceChild method was missing:IfnewChildis aDocumentFragmentobject,oldChildis replaced by all of theDocumentFragmentchildren, which are inserted in the same order. If thenewChildis already in the tree, it is first removed.
replaceChild method read:
Raised if this node is readonly.
Raised if this node or the parent of the new node is readonly.
cloneNode method was missing:Note that cloning an immutable subtree results in a mutable copy, but the children of anEntityReferenceclone are readonly. In addition, clones of unspecifiedAttrnodes are specified. And, cloningDocument,DocumentType,Entity, andNotationnodes is implementation dependent.
NOT_SUPPORTED_ERR: Raised if this node is a of typeDOCUMENT_NODE,DOCUMENT_TYPE_NODE,ENTITY_NODE, orNOTATION_NODEand the implementation does not support cloning this type of node.
NodeList objects in the DOM are live.
This represents the content of a comment, i.e., all the characters between the starting '<!--' and ending '-->'.
TheTextinterface represents the textual content (termed character data in XML) of anElementorAttr.
If there is markup, it is parsed into a list of elements and
Text nodes that form the list of children of the
element.
Thenormalize()method onElementmerges any such adjacentTextobjects into a single node for each block of text; this is recommended before employing operations that depend on a particular document structure, such as navigation withXPointers.
CDATASections, the normalize operation alone may not
be sufficient, since XPointers do not differentiate between
Text nodes and CDATASection nodes, the
last part of the sentence (after the semi-colon) was dropped.splitText method:When theoffsetis equal to the length of this node, the newTextnode has no data.
slitText method has been
clarified:Breaks thisTextnode into twoTextat the specifiedoffset, ...
offset parameter of the
splitText method read:
The offset at which to split, starting from 0.
The 16-bit unitoffsetat which to split, starting from0.
The new Text node.
The new node, of the same type as this node.
Raised if the specified offset is negative or
greater than the number of characters in data.
Raised if the specified offset is negative or
greater than the number of 16-bit units in data.
A DOM application can use thehasFeaturemethod of theDOMImplementationinterface to determine whether they are supported or not. The feature string for all the interfaces listed in this section is "XML".
Note: Because no markup is recognized within a
CDATASection, character numeric references cannot be used as an escape mechanism when serializing. Therefore, action needs to be taken when serializing aCDATASectionwith a character encoding where some of the contained characters cannot be represented. Failure to do so would not produce well-formed XML.
One potential solution in the serialization process is to end the CDATA section before the character, output the character using a character reference or entity reference, and open a new CDATA section for any further characters in the text node. Note, however, that some code conversion libraries at the time of writing do not return an error or exception when a character is missing from the encoding, making the task of ensuring that data is not corrupted on serialization more difficult.
they are therefore readonly.
All the descendants of an Entity node are readonly.
Entity nodes and all their descendants are readonly.
As forEntitynodes,EntityReferencenodes and all their descendants are readonly.
Interoperability between implementations is only guaranteed for elements and attributes that are specified in these DTDs.
Interoperability between implementations is only guaranteed for elements and attributes that are specified in the HTML 4.0 DTDs.
defaultValue attribute
now reads:value "Text", "File" or "Password", this represents the HTML value attribute of the element. The value of this attribute does not change if the contents of the corresponding form control in an interactive user agent changes. Changing this attribute, however, resets the contents of the form control. See the value attribute definition in HTML 4.0.
value attribute now
reads:When thetypeattribute of the element has the value "Text", "File" or "Password", this represents the current contents of the corresponding form control in an interactive user agent. Changing this attribute changes the contents of the form control, but does not change the value of the HTML value attribute of the element. When thetypeattribute of the element has the value "Button", "Hidden", "Submit", "Reset", "Image", "Checkbox" or "Radio", this represents the HTML value attribute of the element. See the value attribute definition in HTML 4.0.
defaultChecked attribute
now reads:
When the type attribute of the element has the
value "Checkbox" or "Radio", this represents the HTML checked
attribute of the element. The value of this attribute does not
change if the state of the corresponding form control in an
interactive user agent changes. Changes to this attribute,
however, resets the state of the form control. See the checked attribute definition in HTML 4.0.
checked attribute now
reads:
When the type attribute of the element has the
value "Checkbox" or "Radio", this represents the current state
of the corresponding form control in am interactive user
agent. Changes to this attribute changes the state of the form
control, but does not change the value of the HTML value
attribute of the element.
index attribute was changed to
readonly and the selected attribute to
readwrite. It was also added that the index
attribute starts from 0.defaultSelected
attribute was unclear, it now reads:
Represents the value of the HTML selected attribute. The value
of this attribute does not change if the state of the
corresponding form control in an interactive user agent
changes. Changing defaultSelected, however, resets
the state of the form control. See the selected attribute definition in HTML 4.0.
Represents the current state of the corresponding form control in an interactive user agent. Changing this attribute changes the state of the form control, but does not change the value of the HTML selected attribute of the element.
type
attribute is the string "select-multiple" when the
multiple attribute is true and the
string "select-one" when false.index attribute starts
from 0.before parameter of the
add method read:
The element to insert before, or null for the head
of the list.
The element to insert before, or null for the tail
of the list.
DOMException is raised when the before
given to the add method is not a descendant of the
SELECT element.
cellIndex attribute was changed to
readonly and it was added that it starts from 0.index parameter of the
insertRow and deleteRow methods was
augmented with the following:This index starts from 0 and is relative to all the rows contained inside the table, regardless of section parentage.
insertRow method:The new row is inserted immediately before and in the same section as the currentindexth row in the table. If there is no such row, the row is inserted following the one before in the table. Finally, when the table is empty the row is inserted into aTBODYwhich is created and inserted into the table.
DOMException is raised when the index
given to the insertRow method is greater than the
number of rows, and when the index given to the
deleteRow method is greater than or equal to the
number of rows. In both case, the exception is also raised if the
index is negative.rowIndex, selectionRowIndex,
and cells attributes were changed to readonly. And
it was added that these indexes start from 0.index parameter of the
insertCell and deleteCell methods
starts from 0.insertCell:
If index is equal to the number of cells, the new
cell is appended.
DOMException is raised when the index
given to the insertCell method is greater than the
number of cells and when the index given to the
deleteCell method is greater than or equal to the
number of cells. In both case, the exception is also raised if the
index is negative.index parameter of the
insertRow and deleteRow methods was
augmented with the following:This index starts from 0 and is relative only to the rows contained inside this section, not all the rows in the table.
DOMException is raised when the index
given to the insertRow method is greater than the
number of rows, and when the index given to the
deleteRow method is greater than or equal to the
number of rows. In both case, the exception is also raised if the
index is negative.type attribute is now defined
to be the string "textarea".defaultValue attribute
was unclear, it now reads:Represents the contents of the element. The value of this attribute does not change if the contents of the corresponding form control in an interactive user agent changes. Changing this attribute, however, resets the contents of the form control.
value attribute was
unclear, it now reads:Represents the current contents of the corresponding form control in an interactive user agent. Changing this attribute changes the contents of the form control, but does not change the contents of the element.