About PBDOM

PBDOM is the PowerBuilder implementation of the Document Object Model (DOM), a programming interface defining the means by which XML documents can be accessed and manipulated.

Although PBDOM is not an implementation of the World Wide Web Consortium (W3C) DOM API, it is very similar. The PBDOM PowerBuilder API can be used for reading, writing, and manipulating standard-format XML from within PowerScript code. PBDOM portrays an XML document as a collection of interconnected objects and provides intuitive methods indicating the use and functionality of each object.

PBDOM is also similar to JDOM, which is a Java-based document object model for XML files.

For more information about W3C DOM, go to the W3C Document Object Model website at http://www.w3.org/DOM/. For more information about JDOM, go to the JDOM website at http://www.jdom.org.

Node trees

PBDOM interacts with XML documents according to a tree-view model consisting of parent and child nodes. A document element represents the top-level node of a standalone XML document. This element has one or many child nodes that represent the branches of the tree. You access nodes in the node tree through the appropriate class methods.

XML parser

The PBDOM XML parser is used to load and parse an XML document, and also to generate XML based on user-specified DOM nodes.

PBDOM provides the methods you need to traverse the node tree, access the nodes and attribute values (if any), insert and delete nodes, and serialize the node tree back to XML.

Objects and methods

The PBDOM object hierarchy is described in PBDOM objects. The methods for each object are described in the following chapters. The chapters are arranged in alphabetical order for ease of reference.

PBDOM Summary provides quick reference tables showing the signatures of the methods defined in each PBDOM object. The tables are arranged in an order that reflects the object hierarchy shown in Object hierarchy.

PBDOM objects

PBDOM_OBJECT, the base class for PBDOM objects that represent XML nodes, inherits from the PowerBuilder NonVisualObject class. PBDOM represents node types by the following classes:

You use methods from these classes to access objects in a PBDOM node tree.

The PBDOM_BUILDER class does not represent DOM nodes but can be used to build a PBDOM object tree from XML. It inherits from the PowerBuilder NonVisualObject class.

The PBDOM_EXCEPTION class inherits from the PowerBuilder Exception class and provides a method that obtains error codes.

Each of these classes and their methods are described in the chapters that follow.

Comparing PBDOM objects with W3C DOM and JDOM objects

The following table shows the W3C DOM and JDOM objects that correspond to each PBDOM object that represents a node in the DOM tree. Note that although these W3C DOM and JDOM objects correspond to PBDOM objects, they are not equivalent to the PBDOM objects.

PBDOM

W3C DOM

JDOM

PBDOM_ATTRIBUTE

ATTRIBUTE_NODE

Attribute

PBDOM_BUILDER

None

DOMBuilder

PBDOM_CDATA

CDATA_SECTION_NODE

CDATA

PBDOM_CHARACTERDATA

CHARACTER_DATA_NODE

None

PBDOM_COMMENT

COMMENT_NODE

Comment

PBDOM_DOCUMENT

DOCUMENT_NODE

Document

PBDOM_DOCTYPE

DOCUMENT_TYPE_NODE

DocType

PBDOM_ELEMENT

ELEMENT_NODE

Element

PBDOM_ENTITYREFERENCE

ENTITY_REFERENCE_NODE

EntityRef

PBDOM_OBJECT

NODE

None

PBDOM_PROCESSINGINSTURCTION

PROCESSING_INSTRUCTION_NODE

Processinginstruction

PBDOM_TEXT

TEXT_NODE

Text


Object hierarchy

The W3C DOM and JDOM object hierarchies also differ from the PBDOM object hierarchy, which is shown in the following illustration.

Figure: The PBDOM object hierarchy

For more information about working with PBDOM, see the chapter on PowerBuilder XML services in Application Techniques.