With the default SAX2 namespace processing, the XML reader would report a start and end element event with the namespace URI http://www.ibm.com and the local name hr. Most XMLReader implementations also report the original qName html:hr, but that parameter might simply be an empty string (except for elements that are not in the namespace).

For attributes, you can look up the value of a named attribute using the getValue method, and you can look up the namespace URI or local name of an attribute by its index using the getURI and getLocalName methods. If the URI were the empty string, you would normally use the qName to identify the attributes.

In addition to those events, SAX2 reports the scope of namespace declarations using the startPrefixMapping and endPrefixMapping methods, so that applications can resolve prefixes in attribute values or character data if necessary.

3.4 DOM level2

While XML is a language to describe tree-structures data, the Document Object Model (DOM) defines a set of interfaces to access tree-structures XML documents. DOM specifies how XML and HTML documents can be represented as objects. Unlike SAX, DOM also allows creating and manipulating the contents of XML documents.

DOM level2, contains interfaces for creating a document, importing a node from one document to another, supporting XML Namespaces, associating stylesheets with a document, the Cascading Style Sheets object model, the Range object model, filters and iterators, and the Events object model. The DOM Core API allows the creation and population of a Document object using only DOM API calls; loading a Document and saving it persistently is left to the product that implements the DOM API.

DOM hierarchy

The DOM provides a set of standard object interfaces that an XML parser can use to expose the contents of a document to a client application. These interfaces provide access to all the information from the original document, organized in a hierarchical tree structure. The base interface for navigating this tree structure is the Node interface, that defines the necessary methods to navigate and manipulate the tree-structure of XML documents. The methods include getting, deleting, and modifying the children of a node, as well as inserting new children to it. Every specific document structure is represented in the DOM by one of the following specialized interfaces:

￿Document

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

Page 78
Image 78
IBM Version 5 manual DOM level2, DOM hierarchy