OpenEdge Development: Working with XML - Product ...
OpenEdge Development: Working with XML - Product ...
OpenEdge Development: Working with XML - Product ...
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
The ABL DOM interface<br />
If you are an ABL programmer not yet experienced <strong>with</strong> built-in ABL objects, then you will<br />
find this an easy skill to acquire. If you do not understand something in this chapter, you can<br />
refer to the <strong>OpenEdge</strong> <strong>Development</strong>: ABL Reference for complete information about the object,<br />
handle, attribute, or method. Note that this ABL skill level does not require you to know or<br />
understand the support for true object-oriented programming also provided by the ABL. Think<br />
of ABL built-in or system objects as useful, consistent, easy-to-use encapsulations of system<br />
resources or technologies that increase the richness of the ABL programming environment.<br />
Representing an <strong>XML</strong> document in ABL DOM<br />
DOM builds a hierarchical tree structure that persists in memory and represents your entire<br />
<strong>XML</strong> document. With the ABL interface, you can call the parser to build such a tree for you in<br />
memory from an <strong>XML</strong> document. The DOM tree is then available for you to easily manipulate<br />
using standard tree-traversal logic. For example, an <strong>XML</strong> document may represent a list of<br />
address changes generated from a self-service Web site. Your application might need to traverse<br />
the tree and do some logical validation before using the <strong>XML</strong> data in the tree to update customer<br />
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 />
Note: ABL has defined a set of extensions to ABL to allow the use of <strong>XML</strong> through the DOM<br />
interface. These extensions provide ABL applications <strong>with</strong> the basic input, output, and<br />
low-level data manipulation capabilities required to use data contained in <strong>XML</strong><br />
documents. They are not intended to provide access to the entire DOM interface, nor<br />
are they intended to include all the high-level constructs.<br />
In an ABL application, an X-document object can represent an <strong>XML</strong> document. Like all ABL<br />
objects, the programming flow for using an X-document object follows this pattern:<br />
• Define a variable of type HANDLE<br />
• Use the appropriate CREATE statement to create the object in memory and assign the pointer<br />
to that object to your HANDLE variable—the HANDLE variable is your interface to the object<br />
• Use attributes and methods on the handle to initialize or configure the object<br />
• Use attributes and methods on the handle to complete your programming tasks<br />
• Use the DELETE OBJECT statement to destroy the object and remove it from memory<br />
For example:<br />
DEFINE VARIABLE hDocument AS HANDLE NO-UNDO.<br />
CREATE X-DOCUMENT hDocument.<br />
. . .<br />
DELETE OBJECT hDocument.<br />
2–7