19.6 DOM Level 3 Interfaces

   

DOM Level 3 includes several new interfaces that support features, such as:

  • XML Version 1.1

  • Dynamic DOM implementation selection

  • Generic post-validation document type information

  • Dynamic error handling

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

19.6.1 DOMStringList

The DOMStringList interface models a simple utility class that contains an ordered list of DOMString objects. Table 19-16 describes the DOMStringList interface.

Table 19-16. The DOMStringList interface

Name

Type

Read-only

Attribute

   

length

unsigned long

figs/check.gif

Methods

   

contains

boolean

 

item

DOMString

 

19.6.1.1 NameList

The NameList interface models an ordered collection of names and corresponding namespace URIs. One use of this interface is in modeling the linkage between namespace prefixes and namespace URIs. Table 19-17 describes the NameList interface.

Table 19-17. The NameList interface

Name

Type

Read-only

Attribute

   

length

unsigned long

figs/check.gif

Methods

   

contains

boolean

 

containsNS

boolean

 

getName

DOMString

 

getNamespaceURI

DOMString

 

19.6.1.2 DOMImplementationList

The DOMImplementationList interface models a list of DOMImplementation objects, as shown in Table 19-18.

Table 19-18. The DOMImplementationList interface

Name

Type

Read-only

Attribute

   

length

unsigned long

figs/check.gif

Method

   

item

DOMImplementation

 

19.6.1.3 DOMImplementationSource

The DOMImplementationSource interface, shown in Table 19-19, allows a DOM client to dynamically select a particular DOM implementation from a list of available implementations based on a requested feature set. It also allows the client to retrieve a complete list of all DOMImplementation objects that are available at runtime.

Table 19-19. The DOMImplementationSource interface

Name

Type

Read-only

Methods

   

getDOMImplementation

DOMImplementation

 

getDOMImplementationList

DOMImplementationList

 

19.6.1.4 TypeInfo

One of the major enhancements provided by DOM Level 3 is the presence of type information within the DOM tree after a document has been parsed and validated . The TypeInfo interface, described in Table 19-20, provides a very simple interface that allows a DOM implementation to provide schema-independent type information for elements and attributes within the DOM tree.

Table 19-20. The TypeInfo interface

Name

Type

Read-only

Attributes

   

typeName

DOMString

figs/check.gif

typeNamespace

DOMString

figs/check.gif

Method

   

isDerivedFrom

boolean

 

19.6.1.5 UserDataHandler

DOM Level 3 provides the ability for developers to attach their own user -defined data to any Node within a live DOM tree. The UserDataHandler interface is a callback interface that may be implemented by the developer when he wishes to receive notifications regarding operations that might be performed on various nodes (i.e., nodes are cloned, deleted, moved, and so forth). Its method is listed in Table 19-21.

Table 19-21. The UserDataHandler interface

Name

Type

Read-only

Method

   

handle

void

 

19.6.1.6 DOMError

Prior to Level 3, all error handling within the DOM was done through the DOMException mechanism. Level 3 provides a new error handling facility that allows the developer to register a callback object (which implements the DOMErrorHandler interface) that will be notified when an error occurs during DOM operations. The DOMError interface describes an object that contains the details of such an error. The DOMError interface is described in Table 19-22.

Table 19-22. The DOMError interface

Name

Type

Read-only

Attributes

   

location

DOMLocator

figs/check.gif

message

DOMString

figs/check.gif

relatedData

DOMObject

figs/check.gif

relatedException

DOMObject

figs/check.gif

severity

unsigned short

figs/check.gif

type

DOMString

figs/check.gif

19.6.1.7 DOMErrorHandler

Unlike earlier DOM Levels, Level 3 allows a DOM developer to create a callback object that may receive notifications when errors occur during DOM processing. This is done by developing an object that implements the DOMErrorHandler interface. Then, when an error occurs during a DOM operation (such as a validity error during a node insert), the handleError( ) method will be called with detailed error information. Its method is listed in Table 19-23.

Table 19-23. The DOMErrorHandler interface

Name

Type

Read-only

Method

   

handleError

boolean

 

19.6.1.8 DOMLocator

The DOMLocator interface, shown in Table 19-24, describes a location within a DOM document. It is primarily used by the new DOMError interface to provide detailed information about where a particular error has occurred.

Table 19-24. The DOMLocator interface

Name

Type

Read-only

Attributes

   

byteOffset

long

figs/check.gif

columnNumber

long

figs/check.gif

lineNumber

long

figs/check.gif

relatedNode

Node

figs/check.gif

utf16Offset

long

figs/check.gif

uri

DOMString

figs/check.gif

19.6.1.9 DOMConfiguration

The DOMConfiguration interface, shown in Table 19-25, provides a generic container for configuring various parameters that influence the processing of XML documents when they are first parsed or when they are reprocessed using the Document.normalizeDocument( ) method. For a complete list of parameters that are recognized by DOM Level 3 implementations, see the DOMConfiguration reference section in Chapter 25.

Table 19-25. The DOMConfiguration interface

Name

Type

Read-only

Attribute

   

parameterNames

DOMStringList

figs/check.gif

Methods

   

canSetParameter

boolean

 

getParameter

DOMUserData

 

setParameter

void

 



XML in a Nutshell
XML in a Nutshell, Third Edition
ISBN: 0596007647
EAN: 2147483647
Year: 2003
Pages: 232

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net