XML technologies / XML / XML in a Nutshell / The Document Object Model (DOM) / DOM Level 3 interfaces

(Excerpt from "XML in a Nutshell" by Elliotte Rusty Harold & W. Scott Means)

DOM Level 3 includes new interfaces supporting the following features:

The following sections describe the new interfaces introduced in DOM Level 3.

DOMStringList

The interface DOMStringList models a simple helper class containing an ordered list of DOMString objects. The following table describes the interface DOMStringList.

Table: The interface DOMStringList

Name

Type

Read-only?

Attribute

length

unsigned long

✗

Methoden

contains

boolean

item

DOMString

NameList

The interface NameListmodels an ordered collection of names and corresponding URIs. One possible use is to model the association between namespace prefixes and namespace URIs. The following table describes the interface NameList.

Table: The NameList interface

Name

Type

Read-only?

Attribute

length

unsigned long

✗

Methoden

contains

boolean

containsNS

boolean

getName

DOMString

getNamespaceURI

DOMString

DOMImplementationList

The interface DOMImplementationList models a list of DOMImplementation objects. It is shown in the following table.

Table: The DOMImplementationList interface

Name

Type

Read-only?

Attribute

length

unsigned long

✗

Methoden

item

DOMImplementation

DOMImplementationSource

The interface shown in the next table DOMImplementationSource allows a DOM client to select a particular implementation dynamically from those available, based on a required set of features. It also lets the client retrieve the complete list of all DOMImplementation objects available at runtime.

Table: The interface DOMImplementationSource

Name

Type

Read-only?

Methoden

getDOMImplementation

DOMImplementation

getDOMImplementationList

DOMImplementationList

TypeInfo

One of the most important improvements in DOM Level 3 is the availability of type information in the DOM tree after a document has been parsed and validated. The interface described in the following table TypeInfo provides a very simple interface through which a DOM implementation can supply schema-independent type information for elements and attributes in the DOM tree.

Table: The TypeInfo interface

Name

Type

Read-only?

Attribute

typeName

DOMString

✗

typeNamespace

DOMString

✗

Methoden

isDerivedFrom

boolean

UserDataHandler

DOM Level 3 lets developers attach their own custom data to any Node in the current DOM tree. The interface UserDataHandler is a callback interface developers can implement to receive notifications of operations performed on nodes, such as cloning, deletion, or movement. Its method is listed in the following table.

Table: The UserDataHandler interface

Name

Type

Read-only?

Methode

handle

void

DOMError

Before Level 3, all DOM error handling used the DOMException mechanism. Level 3 introduces a new error-handling facility that lets developers register a callback object implementing the interface DOMErrorHandler, which is notified when an error occurs during DOM operations. The interface DOMError describes an object containing information about such an error. The interface DOMError is described in the following table.

Table: The interface DOMError

Name

Type

Read-only?

Attribute

location

DOMLocator

✗

message

DOMString

✗

relatedData

DOMObject

✗

relatedException

DOMObject

✗

severity

unsigned short

✗

type

DOMString

✗

DOMErrorHandler

Unlike earlier DOM levels, Level 3 lets developers create a callback object that can be notified when an error occurs during DOM processing. This is done by creating an object implementing the interface DOMErrorHandler. If an error occurs during a DOM operation, such as a validity error while inserting a node, the method handleError( ) is called with detailed error information. The interface’s method appears in the following table.

Table: The interface DOMErrorHandler

Name

Type

Read-only?

Methode

handleError

boolean

DOMLocator

The interface shown in the next table DOMLocator describes a location within a DOM document. It is used mainly by the new DOMError interface to supply detailed information about where an error occurred.

Table: The interface DOMLocator

Name

Type

Read-only?

Attribute

byteOffset

long

✗

columnNumber

long

✗

lineNumber

long

✗

relatedNode

Node

✗

utf16Offset

long

✗

uri

DOMString

✗

DOMConfiguration

The interface shown in the following table DOMConfiguration provides a general container for configuration parameters affecting XML processing when it is first parsed or processed again with the method Document.normalizeDocument( ). For a complete list of parameters recognized by DOM Level 3 implementations, see DOMConfiguration in the DOM reference.

Table: The interface DOMConfiguration

Name

Type

Read-only?

Attribute

parameterNames

DOMStringList

✗

Methoden

canSetParameter

boolean

getParameter

DOMUserData

setParameter

void

  

 

 

 

back to top