Top Description Fields Constructors Methods
com.sun.org.apache.xerces.internal.dom

public Class DocumentFragmentImpl

extends ParentNode
implements DocumentFragment
Class Inheritance
All Implemented Interfaces
org.w3c.dom.DocumentFragment, org.w3c.dom.Node
Imports
org.w3c.dom.DocumentFragment, .Node, .Text

DocumentFragment is a "lightweight" or "minimal" Document object. It is very common to want to be able to extract a portion of a document's tree or to create a new fragment of a document. Imagine implementing a user command like cut or rearranging a document by moving fragments around. It is desirable to have an object which can hold such fragments and it is quite natural to use a Node for this purpose. While it is true that a Document object could fulfil this role, a Document object can potentially be a heavyweight object, depending on the underlying implementation... and in DOM Level 1, nodes aren't allowed to cross Document boundaries anyway. What is really needed for this is a very lightweight object. DocumentFragment is such an object.

Furthermore, various operations -- such as inserting nodes as children of another Node -- may take DocumentFragment objects as arguments; this results in all the child nodes of the DocumentFragment being moved to the child list of this node.

The children of a DocumentFragment node are zero or more nodes representing the tops of any sub-trees defining the structure of the document. DocumentFragment do not need to be well-formed XML documents (although they do need to follow the rules imposed upon well-formed XML parsed entities, which can have multiple top nodes). For example, a DocumentFragment might have only one child and that child node could be a Text node. Such a structure model represents neither an HTML document nor a well-formed XML document.

When a DocumentFragment is inserted into a Document (or indeed any other Node that may take children) the children of the DocumentFragment and not the DocumentFragment itself are inserted into the Node. This makes the DocumentFragment very useful when the user wishes to create nodes that are siblings; the DocumentFragment acts as the parent of these nodes so that the user can use the standard methods from the Node interface, such as insertBefore() and appendChild().

Since
PR-DOM-Level-1-19980818.

Field Summary

Modifier and TypeField and Description
pack-priv static final long
Inherited from com.sun.org.apache.xerces.internal.dom.ParentNode:
firstChildfNodeListCacheownerDocument

Constructor Summary

AccessConstructor and Description
public
DocumentFragmentImpl(CoreDocumentImpl ownerDoc)

Factory constructor.

public
DocumentFragmentImpl()

Constructor for serialization.

Method Summary

Modifier and TypeMethod and Description
public String
public short
getNodeType()

Implements abstract com.sun.org.apache.xerces.internal.dom.NodeImpl.getNodeType.

Implements org.w3c.dom.Node.getNodeType.

A short integer indicating what type of node this is.

public void
normalize()

Overrides com.sun.org.apache.xerces.internal.dom.ParentNode.normalize.

Implements org.w3c.dom.Node.normalize.

Override default behavior to call normalize() on this Node's children.

Inherited from com.sun.org.apache.xerces.internal.dom.ParentNode:
checkNormalizationAfterInsertcheckNormalizationAfterRemovecloneNodegetChildNodesgetChildNodesUnoptimizedgetFirstChildgetLastChildgetLengthgetOwnerDocumentgetTextContentgetTextContenthasChildNodeshasTextContentinsertBeforeinternalInsertBeforeinternalRemoveChildisEqualNodeitemlastChildlastChildownerDocumentremoveChildreplaceChildsetOwnerDocumentsetReadOnlysetTextContentsynchronizeChildren

Field Detail

serialVersionUIDback to summary
pack-priv static final long serialVersionUID

Hides com.sun.org.apache.xerces.internal.dom.ParentNode.serialVersionUID.

Serialization version.

Constructor Detail

DocumentFragmentImplback to summary
public DocumentFragmentImpl(CoreDocumentImpl ownerDoc)

Factory constructor.

DocumentFragmentImplback to summary
public DocumentFragmentImpl()

Constructor for serialization.

Method Detail

getNodeNameback to summary
public String getNodeName()

Implements abstract com.sun.org.apache.xerces.internal.dom.NodeImpl.getNodeName.

Implements org.w3c.dom.Node.getNodeName.

Returns the node name.

getNodeTypeback to summary
public short getNodeType()

Implements abstract com.sun.org.apache.xerces.internal.dom.NodeImpl.getNodeType.

Implements org.w3c.dom.Node.getNodeType.

A short integer indicating what type of node this is. The named constants for this value are defined in the org.w3c.dom.Node interface.

normalizeback to summary
public void normalize()

Overrides com.sun.org.apache.xerces.internal.dom.ParentNode.normalize.

Implements org.w3c.dom.Node.normalize.

Override default behavior to call normalize() on this Node's children. It is up to implementors or Node to override normalize() to take action.