Enhydra 5.1 API

org.enhydra.xml.lazydom
Class LazyDocument

java.lang.Object
  |
  +--org.apache.xerces.dom.NodeImpl
        |
        +--org.apache.xerces.dom.ChildNode
              |
              +--org.apache.xerces.dom.ParentNode
                    |
                    +--org.apache.xerces.dom.CoreDocumentImpl
                          |
                          +--org.apache.xerces.dom.DocumentImpl
                                |
                                +--org.enhydra.xml.lazydom.LazyDocument
All Implemented Interfaces:
java.lang.Cloneable, Document, DocumentEvent, DocumentRange, DocumentTraversal, EventTarget, LazyNode, LazyParent, Node, NodeList, PreFormattedTextDocument, java.io.Serializable, XMLObjectLink
Direct Known Subclasses:
LazyHTMLDocument

public class LazyDocument
extends DocumentImpl
implements LazyParent, PreFormattedTextDocument, XMLObjectLink

A DOM Document that supports lazy instantiation of a template DOM. Nodes in the instance DOM are created as accessed. This can be either by traversing the tree or by direct access to a node by id number. Instantiation of nodes in the middle of the virtual tree is support. Thus a node can exist without a parent being expanded. This is used by XMLC, were the dynamic nodes tend to be towards the leaves of the tree.

Instances contain a reference to a DOM that is a shared template for the document. Each node in the template is assigned an integer node id that be used to index tables to directly look up the template of a node created from the template.

This DOM also supports associating pre-formatted text with some nodes, which is used to avoid exprensive string scanning operations during the output of unmodified nodes.

When a child of a node is requested, all direct children are expanded. This eliminates a lot of difficult book keep. Attributes are treated as a separate set from children, only instantiated when an atttribute is accessed. Expansion of nodes accesed from an existing node works as follows:

This coarse-grained locking approach minimizes the number of locks * on the assumption that collisions do not occur frequently

To created an extended DOM, one must override both the factory methods that take strings and those that take node ids.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.apache.xerces.dom.DocumentImpl
eventListeners, iterators, mutationEvents, ranges, userData
 
Fields inherited from class org.apache.xerces.dom.CoreDocumentImpl
allowGrammarAccess, changes, docElement, docType, encoding, errorChecking, identifiers, kidOK, standalone, version
 
Fields inherited from class org.apache.xerces.dom.ParentNode
fCachedChild, fCachedChildIndex, fCachedLength, firstChild, ownerDocument
 
Fields inherited from class org.apache.xerces.dom.ChildNode
nextSibling, previousSibling
 
Fields inherited from class org.apache.xerces.dom.NodeImpl
ELEMENT_DEFINITION_NODE, FIRSTCHILD, flags, HASSTRING, IGNORABLEWS, OWNED, ownerNode, READONLY, SPECIFIED, SYNCCHILDREN, SYNCDATA, UNNORMALIZED
 
Fields inherited from interface org.enhydra.xml.lazydom.LazyNode
DOCUMENT_NODE_ID, NULL_NODE_ID
 
Fields inherited from interface org.w3c.dom.Node
ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE
 
Constructor Summary
LazyDocument()
          Constructor with no argument, for LazyHTMLDocument.
LazyDocument(DocumentType documentType, TemplateDOM templateDOM)
          Constructor.
 
Method Summary
 Node appendChild(Node newChild)
          Adds the node newChild to the end of the list of children of this node.
 void appendChildWhileExpanding(Node child)
          Append a child during node expansion.
 boolean areChildrenExpanded()
          Are the children of this node expanded?
 Node cloneNode(boolean deep)
          Returns a duplicate of this node, i.e., serves as a generic copy constructor for nodes.
 LazyAttr createAttribute(int nodeId)
          Create an attribute from a template given its id.
 Attr createAttribute(java.lang.String name)
          Factory method; creates an Attribute having this Document as its OwnerDoc.
 Attr createAttributeNS(java.lang.String namespaceURI, java.lang.String qualifiedName)
          Introduced in DOM Level 2.
 LazyAttr createAttributeNS(java.lang.String namespaceURI, java.lang.String qualifiedName, int nodeId)
          Create a template Attr with namespace.
 LazyCDATASection createCDATASection(int nodeId)
          Create a CDATASection from a template given its id.
 CDATASection createCDATASection(java.lang.String data)
          Factory method; creates a CDATASection having this Document as its OwnerDoc.
 LazyComment createComment(int nodeId)
          Create a comment from a template given its id.
 Comment createComment(java.lang.String data)
          Factory method; creates a Comment having this Document as its OwnerDoc.
 LazyDocumentType createDocumentType(int nodeId)
          Create a new DocumentType object (Non-DOM).
 DocumentType createDocumentType(java.lang.String qualifiedName, java.lang.String publicID, java.lang.String systemID)
          Create a new DocumentType object (Non-DOM).
 DocumentType createDocumentType(java.lang.String qualifiedName, java.lang.String publicID, java.lang.String systemID, java.lang.String internalSubset)
          Create a new DocumentType object (Non-DOM).
 LazyElement createElement(int nodeId)
          Create a element from a template given its id.
 Element createElement(java.lang.String tagName)
          Factory method; creates an Element having this Document as its OwnerDoc.
 Element createElementNS(java.lang.String namespaceURI, java.lang.String qualifiedName)
          Introduced in DOM Level 2.
 LazyEntity createEntity(int nodeId)
          Create a new Entity object (Non-DOM).
 Entity createEntity(java.lang.String name)
          Create a new Entity object (Non-DOM).
 LazyEntityReference createEntityReference(int nodeId)
          Create a entity reference from a template given its id.
 EntityReference createEntityReference(java.lang.String name)
          Factory method; creates an EntityReference having this Document as its OwnerDoc.
 LazyNotation createNotation(int nodeId)
          Create a notation node from a template given its id.
 Notation createNotation(java.lang.String name)
          NON-DOM Factory method; creates a Notation having this Document as its OwnerDoc.
 LazyProcessingInstruction createProcessingInstruction(int nodeId)
          Create a process instruction node from a template given its id.
 ProcessingInstruction createProcessingInstruction(java.lang.String target, java.lang.String data)
          Factory method; creates a ProcessingInstruction having this Document as its OwnerDoc.
 LazyAttr createTemplateAttribute(java.lang.String name, int nodeId)
          Create a template Attr.
 LazyAttr createTemplateAttributeNS(java.lang.String namespaceURI, java.lang.String qualifiedName, int nodeId)
          Create a template Attr.
 LazyCDATASection createTemplateCDATASection(java.lang.String data, int nodeId)
          Create a template CDATASection.
 LazyComment createTemplateComment(java.lang.String data, int nodeId)
          Create a template comment.
 LazyDocumentType createTemplateDocumentType(java.lang.String qualifiedName, java.lang.String publicID, java.lang.String systemID, java.lang.String internalSubset, int nodeId)
          Create a template DocumentType.
 LazyElement createTemplateElement(java.lang.String tagName, int nodeId, java.lang.String preFormattedText)
          Create a template element.
 LazyElement createTemplateElementNS(java.lang.String namespaceURI, java.lang.String qualifiedName, int nodeId, java.lang.String preFormattedText)
          Create a template Element with namespace.
 LazyEntity createTemplateEntity(java.lang.String name, java.lang.String publicId, java.lang.String systemId, java.lang.String notationName, int nodeId)
          Create a template Entity.
 LazyEntityReference createTemplateEntityReference(java.lang.String name, int nodeId)
          Create a template EntityReference.
 LazyNotation createTemplateNotation(java.lang.String name, int nodeId)
          Create a template Notation.
 LazyProcessingInstruction createTemplateProcessingInstruction(java.lang.String target, java.lang.String data, int nodeId)
          Create a template ProcessingInstruction.
 LazyText createTemplateTextNode(java.lang.String data, int nodeId, java.lang.String preFormattedText)
          Create a template text node.
 LazyText createTextNode(int nodeId)
          Create a text node from a template given its id.
 Text createTextNode(java.lang.String data)
          Factory method; creates a Text node having this Document as its OwnerDoc.
protected  void doExpandChildren(LazyParent node)
          Do work of expanding the children of a node, if they are not already expanded.
protected  void doExpandParent(LazyParent node)
          Do work of expanding the parent of a node, if it is not already expanded.
protected  void enterExpansion()
          Flag that an expansion is in progress, which is used to detect recursion.
 NodeList getChildNodes()
          A NodeList that contains all children of this node.
 DocumentType getDoctype()
          For XML, this provides access to the Document Type Definition.
 Element getDocumentElement()
          Convenience method, allowing direct access to the child node which is considered the root of the actual document content.
 LazyNode getExpandedNode(int nodeId)
          Get a pointer to a node if its been expanded, otherwise return null.
 Node getFirstChild()
          The first child of this node.
 DOMImplementation getImplementation()
          Retrieve information describing the abilities of this particular DOM implementation.
 Node getLastChild()
          The last child of this node.
 LazyNode getNodeById(int nodeId)
          Get or create a lazy node, given its id.
 LazyNode getNodeFromTemplate(LazyNode template)
          Get or create a node given, the template node.
 int getNodeId()
          Get the node numeric id number.
 OutputOptions getPreFormatOutputOptions()
          Get the OutputOption that were used to format the document.
 LazyDocument getTemplateDocument()
          Get the template for this node.
 LazyNode getTemplateNode()
          Get the template node as a LazyNode.
 LazyNode getTemplateNode(int nodeId)
          Get a template node, given a node id.
 XMLObject getXMLObject()
          Get the XMLC XMLObject that contains this document, or null it it's not associated with a XMLObject.
 boolean hasChildNodes()
          Returns whether this node has any children.
 Node insertBefore(Node newChild, Node refChild)
          Inserts the node newChild before the existing child node refChild.
 boolean isDocTypeExpanded()
          Has the DocumentType been expanded?
 boolean isParentExpanded()
          Is the parent of this node expanded?
 boolean isTemplateNode()
          Check if this node is a template node.
protected  void leaveExpansion()
          Flag that an expansion is complete.
 void makeTemplateNode(int nodeId)
           
 void normalize()
          Puts all Text nodes in the full depth of the sub-tree underneath this Node, including attribute nodes, into a "normal" form where only structure (e.g., elements, comments, processing instructions, CDATA sections, and entity references) separates Text nodes, i.e., there are neither adjacent Text nodes nor empty Text nodes.
 Node removeChild(Node oldChild)
          Removes the child node indicated by oldChild from the list of children, and returns it.
 Node replaceChild(Node newChild, Node oldChild)
          Replaces the child node oldChild with newChild in the list of children, and returns the oldChild node.
 void setChildrenExpanded()
          Flag the children as being expanded.
 void setNodeValue(java.lang.String value)
          Set the node value, invalidating the id.
 void setParentExpanded()
          Flag the parent as being expanded.
 void setParentWhileExpanding(Node parent)
          Set the parent of this node during expansion.
 void setPreFormatOutputOptions(OutputOptions outputOptions)
          Set the output options that were used to preformat this document.
 void setXMLObject(XMLObject xmlObject)
          Set the XMLC XMLObject that contains this document.
 LazyNode templateClone(Document ownerDocument)
          Create a new node, using this node as the template.
 
Methods inherited from class org.apache.xerces.dom.DocumentImpl
addEventListener, createEvent, createNodeIterator, createNodeIterator, createRange, createTreeWalker, createTreeWalker, dispatchAggregateEvents, dispatchAggregateEvents, dispatchEvent, dispatchEventToSubtree, getEventListeners, getUserData, removeEventListener, saveEnclosingAttr, setEventListeners, setUserData
 
Methods inherited from class org.apache.xerces.dom.CoreDocumentImpl
adoptNode, changed, changes, clone, cloneNode, createDocumentFragment, createElementDefinition, getElementById, getElementsByTagName, getElementsByTagNameNS, getEncoding, getErrorChecking, getIdentifier, getIdentifiers, getNodeName, getNodeType, getOwnerDocument, getStandalone, getStrictErrorChecking, getVersion, importNode, isKidOK, isXMLName, putIdentifier, removeIdentifier, setEncoding, setErrorChecking, setStandalone, setStrictErrorChecking, setVersion
 
Methods inherited from class org.apache.xerces.dom.ParentNode
getChildNodesUnoptimized, getLength, item, setReadOnly, synchronizeChildren
 
Methods inherited from class org.apache.xerces.dom.ChildNode
getNextSibling, getParentNode, getPreviousSibling
 
Methods inherited from class org.apache.xerces.dom.NodeImpl
addEventListener, dispatchEvent, getAttributes, getLocalName, getNamespaceURI, getNodeValue, getPrefix, getReadOnly, getUserData, hasAttributes, isSupported, removeEventListener, setPrefix, setUserData, synchronizeData, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.w3c.dom.Node
getAttributes, getLocalName, getNamespaceURI, getNextSibling, getNodeName, getNodeType, getNodeValue, getOwnerDocument, getParentNode, getPrefix, getPreviousSibling, hasAttributes, isSupported, setPrefix
 

Constructor Detail

LazyDocument

public LazyDocument(DocumentType documentType,
                    TemplateDOM templateDOM)
Constructor.

Parameters:
documentType - Document type to associate with this document, or null if no doctype or should be obtained from template.
templateDOM - Template DOM, with each node cotaining a node id. Maybe null if no associated template.

LazyDocument

public LazyDocument()
Constructor with no argument, for LazyHTMLDocument.

Method Detail

getDocumentElement

public Element getDocumentElement()
Description copied from class: CoreDocumentImpl
Convenience method, allowing direct access to the child node which is considered the root of the actual document content. For HTML, where it is legal to have more than one Element at the top level of the document, we pick the one with the tagName "HTML". For XML there should be only one top-level (HTML not yet supported.)

Specified by:
getDocumentElement in interface Document
Overrides:
getDocumentElement in class CoreDocumentImpl
See Also:
Document.getDocumentElement()

getImplementation

public DOMImplementation getImplementation()
Description copied from class: DocumentImpl
Retrieve information describing the abilities of this particular DOM implementation. Intended to support applications that may be using DOMs retrieved from several different sources, potentially with different underlying representations.

Specified by:
getImplementation in interface Document
Overrides:
getImplementation in class DocumentImpl
See Also:
Document#DOMImplementation

enterExpansion

protected final void enterExpansion()
Flag that an expansion is in progress, which is used to detect recursion. MUST be synchronized on document.


leaveExpansion

protected final void leaveExpansion()
Flag that an expansion is complete. MUST be synchronized on document.


getNodeById

public final LazyNode getNodeById(int nodeId)
Get or create a lazy node, given its id. Expanding if it doesn't exist. All node creation must go through here so that a derived document create factory is used.


getNodeFromTemplate

public final LazyNode getNodeFromTemplate(LazyNode template)
Get or create a node given, the template node.

See Also:
getNodeById

doExpandParent

protected void doExpandParent(LazyParent node)
Do work of expanding the parent of a node, if it is not already expanded. This also expands the children, as this keeps the expansion bookkeeping simple and getting a parent not a common operation except to access a sibling or add a new sibling Only used internally to this package.


doExpandChildren

protected void doExpandChildren(LazyParent node)
Do work of expanding the children of a node, if they are not already expanded. Only lazy parent's have a flag for siblings, as data nodes can never be accessed without going through the parent and expanding the children. Only used internally to this package.


getExpandedNode

public final LazyNode getExpandedNode(int nodeId)
Get a pointer to a node if its been expanded, otherwise return null.


getTemplateNode

public final LazyNode getTemplateNode(int nodeId)
Get a template node, given a node id.


isDocTypeExpanded

public boolean isDocTypeExpanded()
Has the DocumentType been expanded?


getTemplateDocument

public LazyDocument getTemplateDocument()
Get the template for this node.

See Also:
LazyNode.getTemplateNode()

cloneNode

public Node cloneNode(boolean deep)
Description copied from interface: Node
Returns a duplicate of this node, i.e., serves as a generic copy constructor for nodes. The duplicate node has no parent; ( parentNode is null.).
Cloning an Element copies all attributes and their values, including those generated by the XML processor to represent defaulted attributes, but this method does not copy any text it contains unless it is a deep clone, since the text is contained in a child Text node. Cloning an Attribute directly, as opposed to be cloned as part of an Element cloning operation, returns a specified attribute ( specified is true). Cloning any other type of node simply returns a copy of this node.
Note that cloning an immutable subtree results in a mutable copy, but the children of an EntityReference clone are readonly . In addition, clones of unspecified Attr nodes are specified. And, cloning Document, DocumentType, Entity, and Notation nodes is implementation dependent.

Specified by:
cloneNode in interface Node
Overrides:
cloneNode in class DocumentImpl
Returns:
The duplicate node.
See Also:
Node.cloneNode(boolean)

makeTemplateNode

public void makeTemplateNode(int nodeId)
Specified by:
makeTemplateNode in interface LazyNode

getNodeId

public int getNodeId()
Description copied from interface: LazyNode
Get the node numeric id number.

Specified by:
getNodeId in interface LazyNode
See Also:
LazyNode.getNodeId()

isTemplateNode

public boolean isTemplateNode()
Description copied from interface: LazyNode
Check if this node is a template node.

Specified by:
isTemplateNode in interface LazyNode
See Also:
LazyNode.isTemplateNode()

getTemplateNode

public LazyNode getTemplateNode()
Description copied from interface: LazyNode
Get the template node as a LazyNode.

Specified by:
getTemplateNode in interface LazyNode
See Also:
LazyNode.getTemplateNode()

templateClone

public LazyNode templateClone(Document ownerDocument)
Description copied from interface: LazyNode
Create a new node, using this node as the template.

Specified by:
templateClone in interface LazyNode
See Also:
LazyNode.templateClone(org.w3c.dom.Document)

setNodeValue

public void setNodeValue(java.lang.String value)
Set the node value, invalidating the id. All node data is modified by this routine.

Specified by:
setNodeValue in interface Node
Overrides:
setNodeValue in class NodeImpl
See Also:
org.w3c.dom.Node.setNodeValue

isParentExpanded

public boolean isParentExpanded()
Description copied from interface: LazyParent
Is the parent of this node expanded?

Specified by:
isParentExpanded in interface LazyParent
See Also:
LazyParent.isParentExpanded()

setParentExpanded

public void setParentExpanded()
Description copied from interface: LazyParent
Flag the parent as being expanded.

Specified by:
setParentExpanded in interface LazyParent
See Also:
LazyParent.setParentExpanded()

setParentWhileExpanding

public void setParentWhileExpanding(Node parent)
Description copied from interface: LazyParent
Set the parent of this node during expansion. This should also flag the parent as being expanded.

Specified by:
setParentWhileExpanding in interface LazyParent
See Also:
LazyParent.setParentWhileExpanding(org.w3c.dom.Node)

areChildrenExpanded

public boolean areChildrenExpanded()
Description copied from interface: LazyParent
Are the children of this node expanded?

Specified by:
areChildrenExpanded in interface LazyParent
See Also:
LazyParent.areChildrenExpanded()

setChildrenExpanded

public void setChildrenExpanded()
Description copied from interface: LazyParent
Flag the children as being expanded.

Specified by:
setChildrenExpanded in interface LazyParent
See Also:
LazyParent.setChildrenExpanded()

appendChildWhileExpanding

public void appendChildWhileExpanding(Node child)
Description copied from interface: LazyParent
Append a child during node expansion. This should only add the child, not trigger any other expansion.

Specified by:
appendChildWhileExpanding in interface LazyParent
See Also:
LazyParent.appendChildWhileExpanding(org.w3c.dom.Node)

getChildNodes

public NodeList getChildNodes()
Description copied from interface: Node
A NodeList that contains all children of this node. If there are no children, this is a NodeList containing no nodes.

Specified by:
getChildNodes in interface Node
Overrides:
getChildNodes in class ParentNode
See Also:
Node.getChildNodes()

getFirstChild

public Node getFirstChild()
Description copied from interface: Node
The first child of this node. If there is no such node, this returns null.

Specified by:
getFirstChild in interface Node
Overrides:
getFirstChild in class ParentNode
See Also:
Node.getFirstChild()

getLastChild

public Node getLastChild()
Description copied from interface: Node
The last child of this node. If there is no such node, this returns null.

Specified by:
getLastChild in interface Node
Overrides:
getLastChild in class ParentNode
See Also:
Node.getLastChild()

insertBefore

public Node insertBefore(Node newChild,
                         Node refChild)
                  throws DOMException
Description copied from interface: Node
Inserts the node newChild before the existing child node refChild. If refChild is null, insert newChild at the end of the list of children.
If newChild is a DocumentFragment object, all of its children are inserted, in the same order, before refChild. If the newChild is already in the tree, it is first removed.

Specified by:
insertBefore in interface Node
Overrides:
insertBefore in class CoreDocumentImpl
Returns:
The node being inserted.
Throws:
DOMException - HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not allow children of the type of the newChild node, or if the node to insert is one of this node's ancestors.
WRONG_DOCUMENT_ERR: Raised if newChild was created from a different document than the one that created this node.
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly or if the parent of the node being inserted is readonly.
NOT_FOUND_ERR: Raised if refChild is not a child of this node.
See Also:
Node.insertBefore(org.w3c.dom.Node, org.w3c.dom.Node)

replaceChild

public Node replaceChild(Node newChild,
                         Node oldChild)
                  throws DOMException
Description copied from interface: Node
Replaces the child node oldChild with newChild in the list of children, and returns the oldChild node.
If newChild is a DocumentFragment object, oldChild is replaced by all of the DocumentFragment children, which are inserted in the same order. If the newChild is already in the tree, it is first removed.

Specified by:
replaceChild in interface Node
Overrides:
replaceChild in class CoreDocumentImpl
Returns:
The node replaced.
Throws:
DOMException - HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not allow children of the type of the newChild node, or if the node to put in is one of this node's ancestors.
WRONG_DOCUMENT_ERR: Raised if newChild was created from a different document than the one that created this node.
NO_MODIFICATION_ALLOWED_ERR: Raised if this node or the parent of the new node is readonly.
NOT_FOUND_ERR: Raised if oldChild is not a child of this node.
See Also:
Node.replaceChild(org.w3c.dom.Node, org.w3c.dom.Node)

removeChild

public Node removeChild(Node oldChild)
                 throws DOMException
Description copied from interface: Node
Removes the child node indicated by oldChild from the list of children, and returns it.

Specified by:
removeChild in interface Node
Overrides:
removeChild in class CoreDocumentImpl
Returns:
The node removed.
Throws:
DOMException - NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
NOT_FOUND_ERR: Raised if oldChild is not a child of this node.
See Also:
Node.removeChild(org.w3c.dom.Node)

appendChild

public Node appendChild(Node newChild)
                 throws DOMException
Description copied from interface: Node
Adds the node newChild to the end of the list of children of this node. If the newChild is already in the tree, it is first removed.

Specified by:
appendChild in interface Node
Overrides:
appendChild in class NodeImpl
Returns:
The node added.
Throws:
DOMException - HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not allow children of the type of the newChild node, or if the node to append is one of this node's ancestors.
WRONG_DOCUMENT_ERR: Raised if newChild was created from a different document than the one that created this node.
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
See Also:
Node.appendChild(org.w3c.dom.Node)

hasChildNodes

public boolean hasChildNodes()
Description copied from interface: Node
Returns whether this node has any children.

Specified by:
hasChildNodes in interface Node
Overrides:
hasChildNodes in class ParentNode
Returns:
true if this node has any children, false otherwise.
See Also:
Node.hasChildNodes()

normalize

public void normalize()
Description copied from interface: Node
Puts all Text nodes in the full depth of the sub-tree underneath this Node, including attribute nodes, into a "normal" form where only structure (e.g., elements, comments, processing instructions, CDATA sections, and entity references) separates Text nodes, i.e., there are neither adjacent Text nodes nor empty Text nodes. This can be used to ensure that the DOM view of a document is the same as if it were saved and re-loaded, and is useful when operations (such as XPointer lookups) that depend on a particular document tree structure are to be used.In cases where the document contains CDATASections, the normalize operation alone may not be sufficient, since XPointers do not differentiate between Text nodes and CDATASection nodes.

Specified by:
normalize in interface Node
Overrides:
normalize in class ParentNode
See Also:
Node.normalize()

getDoctype

public DocumentType getDoctype()
Description copied from class: CoreDocumentImpl
For XML, this provides access to the Document Type Definition. For HTML documents, and XML documents which don't specify a DTD, it will be null.

Specified by:
getDoctype in interface Document
Overrides:
getDoctype in class CoreDocumentImpl
See Also:
Document.getDoctype()

createElement

public Element createElement(java.lang.String tagName)
                      throws DOMException
Description copied from class: CoreDocumentImpl
Factory method; creates an Element having this Document as its OwnerDoc.

Specified by:
createElement in interface Document
Overrides:
createElement in class CoreDocumentImpl
Parameters:
tagName - The name of the element type to instantiate. For XML, this is case-sensitive. For HTML, the tagName parameter may be provided in any case, but it must be mapped to the canonical uppercase form by the DOM implementation.
DOMException
See Also:
Document.createElement(java.lang.String)

createTextNode

public Text createTextNode(java.lang.String data)
Description copied from class: CoreDocumentImpl
Factory method; creates a Text node having this Document as its OwnerDoc.

Specified by:
createTextNode in interface Document
Overrides:
createTextNode in class CoreDocumentImpl
Parameters:
data - The initial contents of the Text.
See Also:
Document.createTextNode(java.lang.String)

createComment

public Comment createComment(java.lang.String data)
Description copied from class: CoreDocumentImpl
Factory method; creates a Comment having this Document as its OwnerDoc.

Specified by:
createComment in interface Document
Overrides:
createComment in class CoreDocumentImpl
Parameters:
data - The initial contents of the Comment.
See Also:
Document.createComment(java.lang.String)

createCDATASection

public CDATASection createCDATASection(java.lang.String data)
                                throws DOMException
Description copied from class: CoreDocumentImpl
Factory method; creates a CDATASection having this Document as its OwnerDoc.

Specified by:
createCDATASection in interface Document
Overrides:
createCDATASection in class CoreDocumentImpl
Parameters:
data - The initial contents of the CDATA
DOMException
See Also:
Document.createCDATASection(java.lang.String)

createProcessingInstruction

public ProcessingInstruction createProcessingInstruction(java.lang.String target,
                                                         java.lang.String data)
Description copied from class: CoreDocumentImpl
Factory method; creates a ProcessingInstruction having this Document as its OwnerDoc.

Specified by:
createProcessingInstruction in interface Document
Overrides:
createProcessingInstruction in class CoreDocumentImpl
Parameters:
target - The target "processor channel"
data - Parameter string to be passed to the target.
See Also:
Document.createProcessingInstruction(java.lang.String, java.lang.String)

createAttribute

public Attr createAttribute(java.lang.String name)
                     throws DOMException
Description copied from class: CoreDocumentImpl
Factory method; creates an Attribute having this Document as its OwnerDoc.

Specified by:
createAttribute in interface Document
Overrides:
createAttribute in class CoreDocumentImpl
Parameters:
name - The name of the attribute. Note that the attribute's value is _not_ established at the factory; remember to set it!
DOMException
See Also:
Document.createAttribute(java.lang.String)

createNotation

public Notation createNotation(java.lang.String name)
                        throws DOMException
Description copied from class: CoreDocumentImpl
NON-DOM Factory method; creates a Notation having this Document as its OwnerDoc. (REC-DOM-Level-1-19981001 left the process of building DTD information unspecified.)

Overrides:
createNotation in class CoreDocumentImpl
Parameters:
name - The name of the Notation we wish to describe
DOMException
See Also:
org.w3c.dom.Document#createNotation

createEntityReference

public EntityReference createEntityReference(java.lang.String name)
                                      throws DOMException
Description copied from class: CoreDocumentImpl
Factory method; creates an EntityReference having this Document as its OwnerDoc.

Specified by:
createEntityReference in interface Document
Overrides:
createEntityReference in class CoreDocumentImpl
Parameters:
name - The name of the Entity we wish to refer to
DOMException
See Also:
Document.createEntityReference(java.lang.String)

createElementNS

public Element createElementNS(java.lang.String namespaceURI,
                               java.lang.String qualifiedName)
                        throws DOMException
Description copied from class: CoreDocumentImpl
Introduced in DOM Level 2.

Creates an element of the given qualified name and namespace URI. If the given namespaceURI is null or an empty string and the qualifiedName has a prefix that is "xml", the created element is bound to the predefined namespace "http://www.w3.org/XML/1998/namespace" [Namespaces].

Specified by:
createElementNS in interface Document
Overrides:
createElementNS in class CoreDocumentImpl
Parameters:
namespaceURI - The namespace URI of the element to create.
qualifiedName - The qualified name of the element type to instantiate.
Returns:
Element A new Element object with the following attributes:
Throws:
DOMException - NAMESPACE_ERR: Raised if the qualifiedName has a prefix that is "xml" and the namespaceURI is neither null nor an empty string nor "http://www.w3.org/XML/1998/namespace", or if the qualifiedName has a prefix different from "xml" and the namespaceURI is null or an empty string.
See Also:
Document.createElementNS(java.lang.String, java.lang.String)

createAttributeNS

public Attr createAttributeNS(java.lang.String namespaceURI,
                              java.lang.String qualifiedName)
                       throws DOMException
Description copied from class: CoreDocumentImpl
Introduced in DOM Level 2.

Creates an attribute of the given qualified name and namespace URI. If the given namespaceURI is null or an empty string and the qualifiedName has a prefix that is "xml", the created element is bound to the predefined namespace "http://www.w3.org/XML/1998/namespace" [Namespaces].

Specified by:
createAttributeNS in interface Document
Overrides:
createAttributeNS in class CoreDocumentImpl
Parameters:
namespaceURI - The namespace URI of the attribute to create. When it is null or an empty string, this method behaves like createAttribute.
qualifiedName - The qualified name of the attribute to instantiate.
Returns:
Attr A new Attr object.
Throws:
DOMException - INVALID_CHARACTER_ERR: Raised if the specified name contains an invalid character.
See Also:
Document.createAttributeNS(java.lang.String, java.lang.String)

createDocumentType

public DocumentType createDocumentType(java.lang.String qualifiedName,
                                       java.lang.String publicID,
                                       java.lang.String systemID,
                                       java.lang.String internalSubset)
                                throws DOMException
Create a new DocumentType object (Non-DOM).

DOMException
See Also:
CoreDocumentImpl.createDocumentType(java.lang.String, java.lang.String, java.lang.String)

createDocumentType

public DocumentType createDocumentType(java.lang.String qualifiedName,
                                       java.lang.String publicID,
                                       java.lang.String systemID)
                                throws DOMException
Create a new DocumentType object (Non-DOM). This overrides the method in the Xerces DOM used by importNode().

Overrides:
createDocumentType in class CoreDocumentImpl
DOMException
See Also:
CoreDocumentImpl.createDocumentType(java.lang.String, java.lang.String, java.lang.String)

createEntity

public Entity createEntity(java.lang.String name)
                    throws DOMException
Create a new Entity object (Non-DOM).

Overrides:
createEntity in class CoreDocumentImpl
Parameters:
name - The name of the Entity we wish to provide a value for.
DOMException
See Also:
CoreDocumentImpl.createEntity(java.lang.String)

createElement

public LazyElement createElement(int nodeId)
                          throws DOMException
Create a element from a template given its id.

DOMException
See Also:
Document.createElement(java.lang.String)

createTextNode

public LazyText createTextNode(int nodeId)
Create a text node from a template given its id.

See Also:
Document.createTextNode(java.lang.String)

createComment

public LazyComment createComment(int nodeId)
Create a comment from a template given its id.

See Also:
Document.createComment(java.lang.String)

createCDATASection

public LazyCDATASection createCDATASection(int nodeId)
                                    throws DOMException
Create a CDATASection from a template given its id.

DOMException
See Also:
Document.createCDATASection(java.lang.String)

createProcessingInstruction

public LazyProcessingInstruction createProcessingInstruction(int nodeId)
Create a process instruction node from a template given its id.

See Also:
Document.createProcessingInstruction(java.lang.String, java.lang.String)

createAttribute

public LazyAttr createAttribute(int nodeId)
                         throws DOMException
Create an attribute from a template given its id.

DOMException
See Also:
Document.createAttribute(java.lang.String)

createNotation

public LazyNotation createNotation(int nodeId)
                            throws DOMException
Create a notation node from a template given its id.

DOMException
See Also:
org.w3c.dom.Document#createNotation

createEntityReference

public LazyEntityReference createEntityReference(int nodeId)
                                          throws DOMException
Create a entity reference from a template given its id.

DOMException
See Also:
Document.createEntityReference(java.lang.String)

createDocumentType

public LazyDocumentType createDocumentType(int nodeId)
                                    throws DOMException
Create a new DocumentType object (Non-DOM).

DOMException
See Also:
CoreDocumentImpl.createDocumentType(java.lang.String, java.lang.String, java.lang.String)

createEntity

public LazyEntity createEntity(int nodeId)
                        throws DOMException
Create a new Entity object (Non-DOM).

DOMException
See Also:
CoreDocumentImpl.createEntity(java.lang.String)

createTemplateElement

public LazyElement createTemplateElement(java.lang.String tagName,
                                         int nodeId,
                                         java.lang.String preFormattedText)
                                  throws DOMException
Create a template element. This will call the derived document create method.

DOMException
See Also:
createElement(String), Document.createElement(java.lang.String)

createTemplateTextNode

public LazyText createTemplateTextNode(java.lang.String data,
                                       int nodeId,
                                       java.lang.String preFormattedText)
Create a template text node. This will call the derived document create method.

See Also:
createTextNode(String), Document.createTextNode(java.lang.String)

createTemplateComment

public LazyComment createTemplateComment(java.lang.String data,
                                         int nodeId)
Create a template comment. This will call the derived document create method.

See Also:
createComment(String), Document.createComment(java.lang.String)

createTemplateCDATASection

public LazyCDATASection createTemplateCDATASection(java.lang.String data,
                                                   int nodeId)
                                            throws DOMException
Create a template CDATASection. This will call the derived document create method.

DOMException
See Also:
#createCDataSection(String), Document.createCDATASection(java.lang.String)

createTemplateProcessingInstruction

public LazyProcessingInstruction createTemplateProcessingInstruction(java.lang.String target,
                                                                     java.lang.String data,
                                                                     int nodeId)
Create a template ProcessingInstruction. This will call the derived document create method.

See Also:
createProcessingInstruction(String,String), Document.createProcessingInstruction(java.lang.String, java.lang.String)

createTemplateAttribute

public LazyAttr createTemplateAttribute(java.lang.String name,
                                        int nodeId)
                                 throws DOMException
Create a template Attr. This will call the derived document create method.

DOMException
See Also:
createAttribute(String), Document.createAttribute(java.lang.String)

createTemplateAttributeNS

public LazyAttr createTemplateAttributeNS(java.lang.String namespaceURI,
                                          java.lang.String qualifiedName,
                                          int nodeId)
                                   throws DOMException
Create a template Attr. This will call the derived document create method.

DOMException
See Also:
createAttributeNS(String,String), Document.createAttributeNS(java.lang.String, java.lang.String)

createTemplateNotation

public LazyNotation createTemplateNotation(java.lang.String name,
                                           int nodeId)
                                    throws DOMException
Create a template Notation. This will call the derived document create method.

DOMException
See Also:
createNotation(String), org.w3c.dom.Document#createNotation

createTemplateEntityReference

public LazyEntityReference createTemplateEntityReference(java.lang.String name,
                                                         int nodeId)
                                                  throws DOMException
Create a template EntityReference. This will call the derived document create method.

DOMException
See Also:
createEntityReference(String), Document.createEntityReference(java.lang.String)

createTemplateElementNS

public LazyElement createTemplateElementNS(java.lang.String namespaceURI,
                                           java.lang.String qualifiedName,
                                           int nodeId,
                                           java.lang.String preFormattedText)
                                    throws DOMException
Create a template Element with namespace. This will call the derived document create method.

DOMException
See Also:
createElementNS(String,String), Document.createElementNS(java.lang.String, java.lang.String)

createAttributeNS

public LazyAttr createAttributeNS(java.lang.String namespaceURI,
                                  java.lang.String qualifiedName,
                                  int nodeId)
                           throws DOMException
Create a template Attr with namespace. This will call the derived document create method.

DOMException
See Also:
createAttributeNS(String,String), Document.createAttributeNS(java.lang.String, java.lang.String)

createTemplateDocumentType

public LazyDocumentType createTemplateDocumentType(java.lang.String qualifiedName,
                                                   java.lang.String publicID,
                                                   java.lang.String systemID,
                                                   java.lang.String internalSubset,
                                                   int nodeId)
                                            throws DOMException
Create a template DocumentType.

DOMException
See Also:
createDocumentType(String,String,String,String), CoreDocumentImpl.createDocumentType(java.lang.String, java.lang.String, java.lang.String)

createTemplateEntity

public LazyEntity createTemplateEntity(java.lang.String name,
                                       java.lang.String publicId,
                                       java.lang.String systemId,
                                       java.lang.String notationName,
                                       int nodeId)
                                throws DOMException
Create a template Entity.

DOMException
See Also:
createEntity(String), CoreDocumentImpl.createEntity(java.lang.String)

setPreFormatOutputOptions

public void setPreFormatOutputOptions(OutputOptions outputOptions)
Set the output options that were used to preformat this document.

Parameters:
outputOptions - The output options; should be read-only.

getPreFormatOutputOptions

public OutputOptions getPreFormatOutputOptions()
Description copied from interface: PreFormattedTextDocument
Get the OutputOption that were used to format the document.

Specified by:
getPreFormatOutputOptions in interface PreFormattedTextDocument
Returns:
An OutputOptions object, which can be read-only and shared by all instances of the document.
See Also:
PreFormattedTextDocument.getPreFormatOutputOptions()

setXMLObject

public void setXMLObject(XMLObject xmlObject)
Description copied from interface: XMLObjectLink
Set the XMLC XMLObject that contains this document.

Specified by:
setXMLObject in interface XMLObjectLink
See Also:
XMLObjectLink.setXMLObject(org.enhydra.xml.xmlc.XMLObject)

getXMLObject

public XMLObject getXMLObject()
Description copied from interface: XMLObjectLink
Get the XMLC XMLObject that contains this document, or null it it's not associated with a XMLObject.

Specified by:
getXMLObject in interface XMLObjectLink
See Also:
XMLObjectLink.getXMLObject()

Enhydra 5.1 API