24.03.2013 Views

OpenEdge Development: Working with XML - Product ...

OpenEdge Development: Working with XML - Product ...

OpenEdge Development: Working with XML - Product ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Developing <strong>with</strong> <strong>XML</strong> in <strong>OpenEdge</strong><br />

Developing <strong>XML</strong>-enabled ABL applications <strong>with</strong> DOM<br />

1–6<br />

The Document Object Model (DOM) is the original application programming interface (API)<br />

for <strong>XML</strong> documents, as defined by the W3C. It continues to be the W3C recommendation for<br />

<strong>XML</strong> parsing.<br />

You use the DOM API to build a hierarchical tree structure that persists in memory and<br />

represents your entire <strong>XML</strong> document. With this API, you can call the parser to build such a<br />

tree for you in memory from an <strong>XML</strong> document. The DOM tree is then available for you to<br />

easily manipulate using standard tree-traversal logic. For example, an <strong>XML</strong> document may<br />

represent a list of address changes generated from a self-service Web site. Your application<br />

might need to load the <strong>XML</strong> document into a DOM tree, perform some logical validation on the<br />

data, and only then use the data to update customer address records in your database.<br />

You could also use the API to programmatically build a DOM tree in memory and then write<br />

that tree out as an <strong>XML</strong> document. For example, you may need to generate a list of customer<br />

address changes for a business partner.<br />

DOM advantages<br />

The general advantages of DOM include:<br />

• Data persists in memory<br />

• You can go forwards and backwards in the tree (random access)<br />

• You can make changes directly to the tree in memory<br />

DOM limits<br />

The general limits of DOM include:<br />

• The entire document must be parsed before the tree is available to the application.<br />

• You cannot load a subset of the document.<br />

• Because the whole tree must exist in memory, it may not be suitable for handling very<br />

large <strong>XML</strong> documents.<br />

• A single error in the <strong>XML</strong> file may prevent the document from being loaded. This limit<br />

makes DOM less attractive for use cases where <strong>XML</strong> is being retrieved in a stream rather<br />

than as a static document.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!