Package org.enhydra.xml.lazydom

org.enhydra.xml.lazydom implements a DOM used for templates that is expanded in a lazy manner.

See:
          Description

Interface Summary
LazyAttr Interface implemented by both LazyAttrNS and LazyAttrNoNS.
LazyElement Interface implemented by both LazyElementNS and LazyElementNoNS.
LazyNode Interface use to define Lazy DOM methods that apply to every node.
LazyParent Interface use to define LazyDOM methods that apply to every node that can contain other nodes.
 

Class Summary
LazyAttrNoNS Implementation of the DOM Attr that supports lazy instantiation of a template DOM.
LazyAttrNS Implementation of the DOM Attr that supports lazy instantiation of a template DOM.
LazyCDATASection Lazy CDATASection node.
LazyComment Lazy comment node.
LazyDocument A DOM Document that supports lazy instantiation of a template DOM.
LazyDocumentType Implementation of the DOM Attr that supports lazy instantiation of a template DOM.
LazyDOMImplementation DOMImplementation method for the LazyDOM.
LazyDOMInfoPrinter LazyDOM DOMInfo traversal handler.
LazyDOMSimpleTraversal Simple DOM traverser that calls a handler for every node in the DOM tree.
LazyDOMTraversal Lazy DOM traversal class, calling handler methods for each node based on if they are expanded or template nodes.
LazyElementNoNS Implementation of the DOM Element without namespaces that supports lazy instantiation of a template DOM.
LazyElementNS Implementation of the DOM Element with namespaces that supports lazy instantiation of a template DOM.
LazyEntity Implementation of the DOM Entity that supports lazy instantiation of a template DOM.
LazyEntityReference Lazy text node.
LazyNotation Lazy notation node.
LazyProcessingInstruction Lazy text node.
LazyText Lazy text node.
NodeIdMap Class to assign and map node ids to a node.
TemplateDOM Class used to contain hold a Template DOM that is shared by all instance of the document.
 

Exception Summary
LazyDOMException LazyDOM runtime exception.
 

Error Summary
LazyDOMError Fatal error detected by LazyDOM.
 

Package org.enhydra.xml.lazydom Description

org.enhydra.xml.lazydom implements a DOM used for templates that is expanded in a lazy manner. It is developed for XMLC, where the majority of the DOM is never modified.

The are really two DOMs for a given document instance: the template representation, which is shared by all instances and the expanded representation, which contains DOM Node objects that have been accessed via the standard DOM API. Untouched nodes are left unexpanded (virtual). This maps nicely to the standard XMLC usage of directly accessing inner subtrees of the DOM via access methods. A subtree can be expanded without expanding its parent, so this usage is very efficient. A lazy-DOM aware formatter traverses the document without expanding nodes.

Each node in the template is assigned a unique numeric node id, which is carried over to the instance DOM node when instantiated. The node id is used to index a table pointing into the template DOM and table of instanced nodes in the instance-DOM.

The Lazy DOM is implemented as DOM Node objects derived from a the Xerces DOM implementation. Each derived node implements LazyNode and overrides the methods that access or modify the DOM tree links. These methods will cause the linked nodes to be expanded on first access. The parent, children, and attributes can be expanded independently. To keep things simple, all of the children of a node will be expanded when one is accessed. The attributes of an element are also expanded as a group. However, this expansion is not recursive, only the immediate linked nodes are expanded. Only Element nodes can be expanded without their parent being expanded.

This DOM also stores pre-formatted text for nodes. The pre-formatted text is either CharacterData text with entity references expanded or the opening tags of an Element, including attributes. The use of pre-formatted text avoids expensive character-level operations when outputing a DOM.

Constructing derived DOMs based on the Lazy DOM is straight-forward. A document class should extend LazyDocument and override

LazyElement createElement(int nodeId) throws DOMException;
The derived Element classes should extend LazyElement and provide a constructor that passes through a template. All Lazy DOM nodes have a single constructor that takes both a a template of the same type and the parameters needed to construct the node without a template. Either the template or the other arguments should be null. This approached is used to make it easier to build derived nodes.



Copyright © 1999-2002 enhydra.org (Mark Diekhans, David Li, Richard Kunze). All Rights reserved.