Release 10.1A: OpenEdge Development:
Programming Interfaces

> ## XML and Progress

> There are two APIs for XML documents: Simple API for XML (SAX) and the Document Object Model (DOM) as well as temp-table and ProDataSet methods for reading and writing XML.

> ##### Progress SAX

> The Simple API for XML (SAX) is an application programming interface (API) for XML documents. It defines the way an XML document is accessed and manipulated. In the SAX specification, the term “document” is used in the broad sense to include many different kinds of information that might be stored in diverse systems. Much of this would traditionally be seen as data rather than as documents. Nevertheless, XML presents this data as documents, and SAX lets you manage them.

> When an XML document is accessed by a SAX application, as the XML parser encounters an XML element, it parses that element and provides its information to the application immediately, through a callback. This contrasts with the Document Object Model (DOM), which requires the entire XML document to be loaded before information on the document’s XML elements is provided.

> Two major advantages of SAX over the DOM interface are:

> 1. SAX requires much less memory than DOM does.

> 2. An application using SAX can stop the XML parser as soon as it has all the data it needs, even if it has parsed only part of the XML document. This might save a lot of processing time.

> Yet, Progress SAX is just as easy to set up as Progress DOM.

> For more information on Progress SAX, see Chapter 20 "Simple API for XML (SAX): SAX-Reader and SAX-Attributes" and Chapter 21 "Simple API for XML (SAX): SAX-writer".

> ##### Note on SAX compatibility with the Progress 4GL

> The SAX API is designed to be compatible with a wide range of programming languages. For the most part, Progress has followed the SAX Java API naming conventions. In a very few cases, Progress Software Corporation (PSC) elected to use the familiar names already used in the 4GL rather than the names given in the SAX specification. Similarly, where there are existing 4GL features that provide the same capability as the SAX interfaces, PSC has chosen to use the 4GL implementation rather than introduce new language features that match SAX more closely.

> ##### Progress DOM

> The Document Object Model (DOM) is an application programming interface (API) for XML documents. It defines the logical structure of documents and the way a document is accessed and manipulated. In the DOM specification, the term document is used in the broad sense to include many different kinds of information that might be stored in diverse systems. When you read an XML document via the DOM API, the DOM parser reads and parses the complete input document before making it available to the application.

> Progress has defined an initial set of extensions to the Progress 4GL to allow the use of XML through the DOM interface. These extensions provide 4GL applications with the basic input, output, and low-level data manipulation capabilities required to use data contained in XML documents. They are not intended to provide access to the entire DOM interface, nor are they intended to include all the high-level constructs.

> ##### Note on DOM compatibility with the 4GL

> The DOM API is designed to be compatible with a wide range of programming languages, but the naming convention chosen by the World Wide Web Consortium (W3C) does not match what already exists in the Progress 4GL. In some cases, PSC elected to use the familiar names already used in the 4GL rather than the names given in the DOM specification. Similarly, where there are existing 4GL features that provide the same capability as the DOM interfaces, PSC has chosen to use the 4GL implementation rather than introduce new language features that match the DOM more closely.

> ##### Accessing XML with the Progress 4GL

> The DOM presents documents as a hierarchy or tree of node objects that also implement other, more specialized interfaces. Progress implements the node interface as a Progress object. The document interface also inherits from the node interface. Progress has extended it to provide special methods.

> This gives us two new object types in the 4GL for XML document manipulation:

> - `X-DOCUMENT` — Which represents an entire XML document tree.

> - `X-NODEREF` — Which represents a reference to a single node in the XML tree of the document.

> Similarly, Progress SAX interface provides two 4GL objects, `SAX-reader` and `SAX-attributes`, and their attributes and methods. For more information on these new SAX objects, see Chapter 20, " Simple API for XML (SAX): SAX-Reader and SAX-Attributes."

Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095