D o c u m e n t

E l e m e n t

E l e m e n t

T e x t

E l e m e n t

E l e m e n t

T e x t

E l e m e n t

T e x t

E l e m e n t

T e x t

Figure 3-4 Sample generated DOM tree

Document represents the whole documents, and the interface define methods for creating elements, attributes, comments, and so on. Attributes of a Node are manipulated using the methods of the Element interface. It should be noticed that while a DOM application reads an XML document and an object representation is formed, that representation remains only in memory. Changing a DOM object in memory does not automatically modify the original file. That is something an application program has to do for itself.

XML namespace support

The DOM Level2 supports XML namespace. It allows creating and manipulating elements and attributes associated to a namespace. As far as the DOM is concerned, special attributes used for declaring XML namespaces are exposed and can be manipulated just like any other attribute. However, nodes are permanently bound to namespace URIs as they get created. Consequently, moving a node within a document, using the DOM, in no case results in a change of its namespace prefix or namespace URI. Similarly, creating a node with a namespace prefix and namespace URI, or changing the namespace prefix of a node, does not result in any addition, removal, or modification of any special attributes declaring the appropriate XML namespaces. Namespace validation is not enforced; the DOM application is responsible.

DOM Level2 does not perform any URI normalization. The URIs given to the DOM are assumed to be valid. Absolute URI references are treated as strings and compared literally. How relative namespace URI references are treated is undefined. To ensure inter operability, only absolute namespace URI references should be used. Note that the empty string will be treated as a real namespace

64 The XML Files: Development of XML/XSL Applications Using WebSphere Studio

Page 80
Image 80
IBM Version 5 manual Sample generated DOM tree