PDF version of document
pdf
Discuss this document
discuss
Download archive for this document
download
Go back to homepage
home

DOM 1.0 - Conformance Testing

Author :
Nazmul Idris 
Date :
Jun 4 1999
Links :
Copyright 1999 - 2006 Nazmul Idris. All Rights Reserved.

Overview

This is a preliminary report, the formatting and documentation is quite sparse. We will keep updating it, so check back soon.

We performed this test on the Sun Java2 Virtual Machine for Windows (JDK 1.2.1). The parsers are of the following versions:

Status: This report has been submitted to the OASIS XML Conformance Working Group and is currently being reviewed by NIST and OASIS.

Results

We found that the Sun Project X Parser is almost 100% conformant except for 2 small deviations from the DOM 1.0 Recommendation. The Datachannel parser comes in second. The IBM parser is less conformant than Datachannel's parser. OpenXML comes in last as being the least conformant of all the parsers.

DOM Structure Testing

Description of test: 

A DOM Node may contain other Node objects as its children. The Structure test determines whether parsers allow any Node object type to be a child of any other Node . In the DOM 1.0 recommendation there are many restrictions on what types of children Nodes a given Node type can have. Certain Node types may not have children at all and the following test does not use these Node types; it primarily tests Node types that can have children (Document, DocumentFragment, EntityReference, etc.).

Document
can have child node: Sun IBM DataChannel OpenXML
Element Yes Yes Yes
ProcessingInstruction Yes Yes Yes
Commment Yes Yes Yes
DocumentType n/a n/a n/a n/a
Maximum of one Element Yes Yes Yes
deviations from recommendation
Text Node can be added to a Document object

DocumentFragment
can have child node: Sun IBM DataChannel OpenXML
Element Yes Yes Yes
ProcessingInstruction Yes Yes Yes
Comment Yes Yes Yes
Text Yes Yes Yes
CDATASection Yes Yes Yes
EntityReference Yes Yes Yes

EntityReference
can have child node: Sun IBM DataChannel OpenXML
Element Yes Yes Yes
ProcessingInstruction Yes Yes Yes
Comment Yes Yes Yes
Text Yes Yes Yes
CDATASection Yes Yes Yes
EntityReference Yes Yes Yes





Element
can have child node: Sun IBM DataChannel OpenXML
Element Yes Yes Yes
ProcessingInstruction Yes Yes Yes
Comment Yes Yes Yes
Text Yes Yes Yes
CDATASection Yes Yes Yes
EntityReference Yes Yes Yes





Attr
can have child node: Sun IBM DataChannel OpenXML
Text No Yes Yes
EntityReference No Yes Yes
deviations from recommendation Text and EntityReference objects can't be added to an Attr object


ProcessingInstruction
can have child node: Sun IBM DataChannel OpenXML
no children Yes Yes Yes





Text
can have child node: Sun IBM DataChannel OpenXML
no children Yes Yes NO
deviations from recommendation

Can add Element, ProcssingInstruction, Comment, Text, CDATASection, EntityReference to Text object

CDATASection
can have child node: Sun IBM DataChannel OpenXML
no children Yes Yes Yes





DocumentType *
can have child node: Sun IBM DataChannel OpenXML
no children n/a n/a n/a n/a

Entity *
can have child node: Sun IBM DataChannel OpenXML
Element n/a n/a n/a n/a
ProcessingInstruction n/a n/a n/a n/a
Comment n/a n/a n/a n/a
Text n/a n/a n/a n/a
CDATASection n/a n/a n/a n/a
EntityReference n/a n/a n/a n/a

Notation *
can have child node: Sun IBM DataChannel OpenXML
no children n/a n/a n/a n/a

* DocumentType, Entity, and Notation classes are not tested for their structure because they are declared in DTD (Document Type Definition).


Node type Testing

Description of test: 

A Node can have 3 properties: nodeName, nodeValue, attributes. These 3 properties are different for each of the 12 Node types in DOM. The following test determines whether each of the 12 Node types contains the correct types of values in each property. 

In DOM 1.0, a Node object can have a type (eg, a Node can be an element node or an attribute node, etc.). There are 12 such predefined types which are listed in the table below:
 
Node type: Sun IBM DataChannel OpenXML
ELEMENT_NODE = 1 Yes Yes Yes
ATTRIBUTE_NODE = 2 Yes Yes Yes
TEXT_NODE = 3 Yes Yes Yes
CDATA_SECTION_NODE = 4 Yes Yes Yes
ENTITY_REFERENCE_NODE = 5 Yes Yes Yes
ENTITY_NODE = 6 n/a n/a n/a n/a
PROCESSING_INSTRUCTION_NODE = 7 Yes Yes Yes
COMMENT_NODE = 8 Yes Yes Yes
DOCUMENT_NODE = 9 Yes Yes Yes
DOCUMENT_TYPE_NODE = 10 n/a n/a n/a n/a
DOCUMENT_FRAGMENT_NODE = 11 Yes Yes Yes
NOTATION_NODE = 12 n/a n/a n/a n/a





The values of the properties: nodeName, nodeValue, and attributes vary according to the node type as follows:

Element
has properties: Sun IBM DataChannel OpenXML
nodeName = tagName Yes Yes Yes
nodeValue = null Yes Yes Yes
attributes = NamedNodeMap Yes Yes Yes

Attr
has properties: Sun IBM DataChannel OpenXML
nodeName = name of attribute Yes Yes Yes
nodeValue = value of attribute Yes Yes Yes
attributes = null Yes Yes Yes

Text
has properties: Sun IBM DataChannel OpenXML
nodeName = #text Yes Yes Yes
nodeValue = content of the text node Yes Yes Yes
attributes = null Yes Yes Yes

CDATASection
has properties: Sun IBM DataChannel OpenXML
nodeName = #cdata-section Yes Yes Yes
nodeValue = content of the CDATA Section Yes Yes Yes
attributes = null Yes Yes Yes

EntityReference
has properties: Sun IBM DataChannel OpenXML
nodeName = name of entity referenced Yes Yes Yes
nodeValue = null Yes Yes Yes
attributes = null Yes Yes Yes

ProcessingInstruction
has properties: Sun IBM DataChannel OpenXML
nodeName = target Yes Yes Yes
nodeValue = entire content excluding the target Yes Yes Yes
attributes = null Yes Yes Yes

Comment
has properties: Sun IBM DataChannel OpenXML
nodeName = #comment Yes Yes Yes
nodeValue = content of the comment Yes Yes Yes
attributes = null Yes Yes Yes

Document
has properties: Sun IBM DataChannel OpenXML
nodeName = #document Yes Yes Yes
nodeValue = null Yes Yes Yes
attributes = null Yes Yes Yes

DocumentFragment
has properties: Sun IBM DataChannel OpenXML
nodeName = #document-fragment Yes Yes Yes
nodeValue = null Yes Yes Yes
attributes = null Yes Yes Yes

Entity **
has properties: Sun IBM DataChannel OpenXML
nodeName = entity name n/a n/a n/a n/a
nodeValue = null n/a n/a n/a n/a
attributes = null n/a n/a n/a n/a

DocumentType **
has properties: Sun IBM DataChannel OpenXML
nodeName = document type name n/a n/a n/a n/a
nodeValue = null n/a n/a n/a n/a
attributes = null n/a n/a n/a n/a

Notation **
has properties: Sun IBM DataChannel OpenXML
nodeName = notation n/a n/a n/a n/a
nodeValue = null n/a n/a n/a n/a
attributes = null n/a n/a n/a n/a

** DocumentType, Entity, and Notation Node are not tested for their structure because they are declared in DTD (Document Type Definition).


Exception Testing

Description of test: 

This test determines whether methods in the DOM interfaces (Document, Node, Element, etc.) throw the correct exceptions when these exceptional circumstances exist. By doing invalid things in the invocation of each method in each of the DOM interfaces, the following table was generated.

Document interface:
createElement() 
throws this exception: Sun IBM DataChannel OpenXML
INVALID_CHARACTER_ERR = 5 Yes Yes Yes

createCDATASection() 
throws this exception: Sun IBM DataChannel OpenXML
NOT_SUPPORTED_ERR = 9 *** n/a n/a n/a n/a

createProcessingInstruction() 
throws this exception: Sun IBM DataChannel OpenXML
INVALID_CHARACTER_ERR = 5 Yes Yes Yes
NOT_SUPPORTED_ERR = 9 *** n/a n/a n/a n/a

createAttribute() 
throws this exception: Sun IBM DataChannel OpenXML
INVALID_CHARACTER_ERR = 5 Yes Yes Yes

createEntityReference() 
throws this exception: Sun IBM DataChannel OpenXML
INVALID_CHARACTER_ERR = 5 Yes Yes Yes
NOT_SUPPORTED_ERR = 9 *** n/a n/a n/a n/a

Node interface:
insertBefore() 
throws this exception: Sun IBM DataChannel OpenXML
HIERARCHY_REQUEST_ERR = 3 Yes Yes No 1
WRONG_DOCUMENT_ERR = 4 Yes No 3 Yes
NO_MODIFICATION_ALLOWED_ERR =7 **** n/a n/a n/a n/a
NOT_FOUND_ERR = 8 Yes Yes No 2
deviations from recommendation
3 No exception is thrown 1 No exception is thrown. 

2 Given a parent Node, when trying to add a new Node before a Node (which is not a child of this parent), a DOMException is not thrown. Instead a parser specific exception is thrown. Trying to do what is described here simply violates the semantics of insert BEFORE.


replaceChild() 
throws this exception: Sun IBM DataChannel OpenXML
HIERARCHY_REQUEST_ERR = 3 Yes No 3 No
WRONG_DOCUMENT_ERR = 4 Yes No 3 Yes
NO_MODIFICATION_ALLOWED_ERR = 7 ***** n/a n/a n/a n/a
NOT_FOUND_ERR = 8 Yes Yes No 2
deviations from recommendation
3 No exception is thrown 1 No exception is thrown. 

2 Given a parent Node, when trying to replace a Node (which is not a child of this parent), a DOMException is not thrown. Instead a parser specific exception is thrown. Trying to do what is described here simply violates the semantics of replace one's own child.


removeChild() 
throws this exception: Sun IBM DataChannel OpenXML
NO_MODIFICATION_ALLOWED_ERR**** n/a n/a n/a n/a
NOT_FOUND_ERR = 8 Yes Yes Yes

appendChild() 
throws this exception: Sun IBM DataChannel OpenXML
HIERARCHY_REQUEST_ERR = 3 Yes Yes No 1
WRONG_DOCUMENT_ERR = 4 Yes No 2 Yes
NO_MODIFICATION_ALLOWED_ERR = 7 *** n/a n/a n/a n/a
deviations from recommendation
2 No exception is thrown 1 Given an Attribute object, when trying to append a Element Node, an exception (NullPointerException) is thrown (which is not a DOMException, but a parser specific one).

NamedNodeMap interface:
setNamedItem() 
throws this exception: Sun IBM DataChannel OpenXML
WRONG_DOCUMENT_ERR = 4 Yes Yes No
NO_MODIFICATION_ALLOWED_ERR = 7 **** n/a n/a n/a n/a
INUSE_ATTRIBUTE_ERR = 10 Yes No 3 No 2
deviations from recommendation
3 No exception is thrown 1 No exception is thrown. 

2 Adding an attribute that is already an attribute of another Element throws a parser specific Exception (NullPointerException) instead of DOMException.


removeNamedItem 
throws this exception: Sun IBM DataChannel OpenXML
NOT_FOUND_ERR = 8 Yes Yes Yes

Element interface:
setAttribute() 
throws this exception: Sun IBM DataChannel OpenXML
INVALID_CHARACTER_ERR = 5 Yes Yes No
NO_MODIFICATION_ALLOWED_ERR = 7 **** n/a n/a n/a n/a



1 No exception is thrown. 

removeAttribute() 
throws this exception: Sun IBM DataChannel OpenXML
NO_MODIFICATION_ALLOWED_ERR = 7 **** n/a n/a n/a n/a

setAttributeNode() 
throws this exception: Sun IBM DataChannel OpenXML
WRONG_DOCUMENT_ERR = 4 Yes Yes No 1
NO_MODIFICATION_ALLOWED_ERR = 7 **** n/a n/a n/a n/a
INUSE_ATTRIBUTE_ERR = 10 Yes No 3 No 2
deviations from recommendation
3 No exception is thrown 1 Setting an attribute that is created by other document object throws a parser specific Exception (NullPointerException) instead of a DOMException. 

2 Setting an attribute that is already attribute of another element object throws a parser specific Exception (NullPointerException) instead of a DOMException.


removeAttributeNode() 
throws this exception: Sun IBM DataChannel OpenXML
NO_MODIFICATION_ALLOWED_ERR = 7 **** n/a n/a n/a n/a
NOT_FOUND_ERR = 8 Yes No 2 No 1
deviations from recommendation
2 No exception is thrown 1 Trying to remove an attribute that does not exist thows a parser specific Exception (NullPointerException) instead of a DOMException.

CharacterData interface:
 
substringData() 
throws this exception: Sun IBM DataChannel OpenXML
INDEX_SIZE_ERR = 1 Yes Yes No
DOMSTRING_SIZE_ERR = 2 ***** n/a n/a n/a n/a
deviations from recommendation

Given an offset that is not a valid range throws an exception (StringIndexOutOfBoundsException) instead of a DOMException.

appendData() 
throws this exception: Sun IBM DataChannel OpenXML
NO_MODIFICATION_ALLOWED_ERR = 7 **** n/a n/a n/a n/a

insertData() 
throws this exception: Sun IBM DataChannel OpenXML
INDEX_SIZE_ERR = 1 Yes Yes Yes
NO_MODIFICATION_ALLOWED_ERR = 7 **** n/a n/a n/a n/a

deleteData() 
throws this exception: Sun IBM DataChannel OpenXML
INDEX_SIZE_ERR = 1 Yes Yes Yes
NO_MODIFICATION_ALLOWED_ERR = 7 **** n/a n/a n/a n/a

replaceData() 
throws this exception: Sun IBM DataChannel OpenXML
INDEX_SIZE_ERR = 1 Yes Yes Yes
NO_MODIFICATION_ALLOWED_ERR = 7 **** n/a n/a n/a n/a

Text interface:
 
splitText() 
throws this exception: Sun IBM DataChannel OpenXML
INDEX_SIZE_ERR = 1 Yes Yes Yes
NO_MODIFICATION_ALLOWED_ERR = 7 **** n/a n/a n/a n/a

*** NOT_SUPPORTED_ERR - This error is not tested because an HTML object is not created.

**** NO_MODIFICATION_ALLOWED_ERR -  Could not create a Read-Only node for this testing.

***** DOMSTRING_SIZE_ERR - This error is not tested because DOMString is bound to the String type.


Explanations

For the Node Interface Exception Test: 

In the DataChannel XJParser, a DOMException is sometimes thrown when a Node object is inserted or replaced. 

The following example demonstrates this behaviour (which is reproducible). Take the tree of nodes below as an example: 

document
   +
  node0
    + node1
       + node2
           + node3

When node4 (a new Node object) is created by the document object, invoking the following methods throws NullPointerExceptions: 

node3.insertBefore(node4, node1)
node3.replaceChild(node4, node1)

Trying to insert the node4 object in the node3 object before the node1 object throws a NullPointerException; it should throw a DOMException. This case violates the semantics of insert before.

Also, tryring to replace node1 with node4 from node3 results in a NullPointerException being thrown.

Invoking the following methods results in DOMExceptions being thrown:

node2.insertBefore(node4, node1)
node2.replaceChild(node4, node1)

Trying to insert node4 to node2, before node1 causes a DOMException to be thrown.

Also, tryring to replace node1 with node4 from node2 causes a DOMException to be thrown.

In conclusion, the DataChannel parser throws a NullPointerException when the parser tries to reference a child node from a childless node. It should thrown a DOMException instead.


PDF version of document
pdf
Discuss this document
discuss
Download archive for this document
download
Go back to homepage
home