LDOM Package

##

The LDOM package allows to write and read XML files. It constitutes an integral part of XML OCAF persistence, which is the optional component provided on top of Open CASCADE.

The Light DOM (LDOM) package contains classes maintaining a data structure whose main principles conform to W3C DOM Level 1 Recommendations. The purpose of these classes as required by XML OCAF persistence schema is to:

- Maintain a tree structure of objects in memory representing the XML document. The root of the structure is an object of the LDOM_Document type. This object contains all the data corresponding to a given XML document and contains one object of the LDOM_Element type named "document element". The document element contains other LDOM_Element objects forming a tree. Other types of nodes (LDOM_Attr, LDOM_Text, LDOM_Comment, LDOM_CDATASection) represent the corresponding XML types and serve as branches of the tree of elements.

- Provide a class LDOM_Parser to read XML files and convert them to LDOM_Document objects.

- Provide a class LDOM_XmlWriter to convert LDOM_Document to a character stream in XML format and store it in file.

This package covers the functionality provided by numerous products known as "DOM parsers". Unlike most of them, LDOM was specifically developed to meet the following requirements:

- To minimize the virtual memory allocated by DOM data structures. In average, the amount of memory of LDOM is the same as the XML file size (UTF-8).

- To minimize the time required for parsing and formatting XML, as well as for access to DOM data structures.

Both these requirements are important when XML files are processed by applications since these files are relatively large (occupying megabytes and even hundreds of megabytes). To meet the requirements, some limitations were imposed on the DOM Level 1 specification; these limitations are insignificant in applications like OCAF. Some of these limitations can be overridden in the course of future developments. The main limitations are:

1. No Unicode support as well as various other encodings; only ASCII strings are used in DOM/XML. Note: There is a data type TCollection_ExtendedString for wide character data. This type is supported by LDOM_String as a sequence of numbers.

2. Some superfluous methods are deleted: getPreviousSibling, getParentNode, etc.

3. No resolution of XML Entities of any kind

4. No support for DTD: the parser just checks for observance of general XML rules and never validates documents.

5. Only 5 available types of DOM nodes: LDOM_Element, LDOM_Attr, LDOM_Text, LDOM_Comment, LDOM_CDATASection.

6. No support of Namespaces; prefixed names are used instead of qualified names.

7. No support of the interface DOMException (no exception when attempting to remove a non-existing node).

LDOM is dependent on Kernel Open Cascade classes only. Therefore, it can be used outside OCAF persistence in various algorithms where DOM/XML support may be required.

See also:

Document Drivers

Attribute Drivers

XML Document Structure

XML Schema