org.apache.xml.dtm.ref
Class DTMNodeProxy

java.lang.Object
  extended byorg.apache.xml.dtm.ref.DTMNodeProxy
All Implemented Interfaces:
Attr, CharacterData, Comment, Document, DocumentFragment, Element, Node, ProcessingInstruction, Text

public class DTMNodeProxy
extends java.lang.Object
implements Node, Document, Text, Element, Attr, ProcessingInstruction, Comment, DocumentFragment

DTMNodeProxy presents a DOM Node API front-end to the DTM model.

It does _not_ attempt to address the "node identity" question; no effort is made to prevent the creation of multiple proxies referring to a single DTM node. Users can create a mechanism for managing this, or relinquish the use of "==" and use the .sameNodeAs() mechanism, which is under consideration for future versions of the DOM.

DTMNodeProxy may be subclassed further to present specific DOM node types.

See Also:
org.w3c.dom
Usage:
**For internal use only**

Field Summary
 DTM dtm
          The DTM for this node.
 
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
DTMNodeProxy(DTM dtm, int node)
          Create a DTMNodeProxy Node representing a specific Node in a DTM
 
Method Summary
 Node adoptNode(Node source)
          NEEDSDOC Method adoptNode NEEDSDOC @param source
 Node appendChild(Node newChild)
          Adds the node newChild to the end of the list of children of this node.
 void appendData(java.lang.String arg)
          Append the string to the end of the character data of the node.
 Node cloneNode(boolean deep)
          Returns a duplicate of this node, i.e., serves as a generic copy constructor for nodes.
 Attr createAttribute(java.lang.String name)
          Creates an Attr of the given name.
 Attr createAttributeNS(java.lang.String namespaceURI, java.lang.String qualifiedName)
          Creates an attribute of the given qualified name and namespace URI.
 CDATASection createCDATASection(java.lang.String data)
          Creates a CDATASection node whose value is the specified string.
 Comment createComment(java.lang.String data)
          Creates a Comment node given the specified string.
 DocumentFragment createDocumentFragment()
          Creates an empty DocumentFragment object.
 Element createElement(java.lang.String tagName)
          Creates an element of the type specified.
 Element createElementNS(java.lang.String namespaceURI, java.lang.String qualifiedName)
          Creates an element of the given qualified name and namespace URI.
 EntityReference createEntityReference(java.lang.String name)
          Creates an EntityReference object.
 ProcessingInstruction createProcessingInstruction(java.lang.String target, java.lang.String data)
          Creates a ProcessingInstruction node given the specified name and data strings.
 Text createTextNode(java.lang.String data)
          Creates a Text node given the specified string.
 void deleteData(int offset, int count)
          Remove a range of 16-bit units from the node.
 boolean equals(Node node)
          Test for equality based on node number.
 boolean equals(java.lang.Object node)
          Test for equality based on node number.
 java.lang.String getAttribute(java.lang.String name)
          Retrieves an attribute value by name.
 Attr getAttributeNode(java.lang.String name)
          Retrieves an attribute node by name.
 Attr getAttributeNodeNS(java.lang.String namespaceURI, java.lang.String localName)
          Retrieves an Attr node by local name and namespace URI.
 java.lang.String getAttributeNS(java.lang.String namespaceURI, java.lang.String localName)
          Retrieves an attribute value by local name and namespace URI.
 NamedNodeMap getAttributes()
          A NamedNodeMap containing the attributes of this node (if it is an Element) or null otherwise.
 NodeList getChildNodes()
          A NodeList that contains all children of this node.
 java.lang.String getData()
          The content of this processing instruction.
 DocumentType getDoctype()
          The Document Type Declaration (see DocumentType) associated with this document.
 Element getDocumentElement()
          This is a bit of a problem in DTM, since a DTM may be a Document Fragment and hence not have a clear-cut Document Element.
 DTM getDTM()
          NON-DOM: Return the DTM model
 int getDTMNodeNumber()
          NON-DOM: Return the DTM node number
 Element getElementById(java.lang.String elementId)
          Returns the Element whose ID is given by elementId.
 NodeList getElementsByTagName(java.lang.String tagname)
          Returns a NodeList of all the Elements with a given tag name in the order in which they are encountered in a preorder traversal of the Document tree.
 NodeList getElementsByTagNameNS(java.lang.String namespaceURI, java.lang.String localName)
          Returns a NodeList of all the Elements with a given local name and namespace URI in the order in which they are encountered in a preorder traversal of the Document tree.
 java.lang.String getEncoding()
          EXPERIMENTAL!
 Node getFirstChild()
          The first child of this node.
 DOMImplementation getImplementation()
          The DOMImplementation object that handles this document.
 Node getLastChild()
          The last child of this node.
 int getLength()
          The number of 16-bit units that are available through data and the substringData method below.
 java.lang.String getLocalName()
          Returns the local part of the qualified name of this node.
 java.lang.String getName()
          Returns the name of this attribute.
 java.lang.String getNamespaceURI()
          The namespace URI of this node, or null if it is unspecified.
 Node getNextSibling()
          The node immediately following this node.
 java.lang.String getNodeName()
          The name of this node, depending on its type; see the table above.
 short getNodeType()
          A code representing the type of the underlying object, as defined above.
 java.lang.String getNodeValue()
          The value of this node, depending on its type; see the table above.
 Document getOwnerDocument()
          The Document object associated with this node.
 Element getOwnerElement()
          Get the owner element of an attribute.
 Node getOwnerNode()
           
 Node getParentNode()
          The parent of this node.
 java.lang.String getPrefix()
          The namespace prefix of this node, or null if it is unspecified.
 Node getPreviousSibling()
          The node immediately preceding this node.
 boolean getSpecified()
          If this attribute was explicitly given a value in the original document, this is true; otherwise, it is false.
 boolean getStandalone()
          EXPERIMENTAL!
 boolean getStrictErrorChecking()
          EXPERIMENTAL!
 java.lang.String getStringValue()
           
 java.lang.String getTagName()
          The name of the element.
 java.lang.String getTarget()
          A PI's "target" states what processor channel the PI's data should be directed to.
 java.lang.String getValue()
          On retrieval, the value of the attribute is returned as a string.
 java.lang.String getVersion()
          EXPERIMENTAL!
 boolean hasAttribute(java.lang.String name)
          Method hasAttribute
 boolean hasAttributeNS(java.lang.String name, java.lang.String x)
          Method hasAttributeNS
 boolean hasAttributes()
          Introduced in DOM Level 2.
 boolean hasChildNodes()
          Returns whether this node has any children.
 Node importNode(Node importedNode, boolean deep)
          Imports a node from another document to this document.
 Node insertBefore(Node newChild, Node refChild)
          Inserts the node newChild before the existing child node refChild.
 void insertData(int offset, java.lang.String arg)
          Insert a string at the specified 16-bit unit offset.
 boolean isSupported(java.lang.String feature, java.lang.String version)
          Ask whether we support a given DOM feature.
 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.
 void removeAttribute(java.lang.String name)
          Removes an attribute by name.
 Attr removeAttributeNode(Attr oldAttr)
          Removes the specified attribute node.
 void removeAttributeNS(java.lang.String namespaceURI, java.lang.String localName)
          Removes an attribute by local name and namespace URI.
 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 replaceData(int offset, int count, java.lang.String arg)
          Replace the characters starting at the specified 16-bit unit offset with the specified string.
 boolean sameNodeAs(Node other)
          FUTURE DOM: Test node identity, in lieu of Node==Node
 void setAttribute(java.lang.String name, java.lang.String value)
          Adds a new attribute.
 Attr setAttributeNode(Attr newAttr)
          Adds a new attribute node.
 Attr setAttributeNodeNS(Attr newAttr)
          Adds a new attribute.
 void setAttributeNS(java.lang.String namespaceURI, java.lang.String qualifiedName, java.lang.String value)
          Adds a new attribute.
 void setData(java.lang.String data)
          The content of this processing instruction.
 void setEncoding(java.lang.String encoding)
          EXPERIMENTAL!
 void setNodeValue(java.lang.String nodeValue)
          The value of this node, depending on its type; see the table above.
 void setPrefix(java.lang.String prefix)
          The namespace prefix of this node, or null if it is unspecified.
 void setStandalone(boolean standalone)
          EXPERIMENTAL!
 void setStrictErrorChecking(boolean strictErrorChecking)
          EXPERIMENTAL!
 void setValue(java.lang.String value)
          On retrieval, the value of the attribute is returned as a string.
 void setVersion(java.lang.String version)
          EXPERIMENTAL!
 Text splitText(int offset)
          Breaks this node into two nodes at the specified offset, keeping both in the tree as siblings.
 java.lang.String substringData(int offset, int count)
          Extracts a range of data from the node.
 boolean supports(java.lang.String feature, java.lang.String version)
          Ask whether we support a given DOM feature.
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dtm

public DTM dtm
The DTM for this node.

Constructor Detail

DTMNodeProxy

public DTMNodeProxy(DTM dtm,
                    int node)
Create a DTMNodeProxy Node representing a specific Node in a DTM

Parameters:
dtm - The DTM Reference, must be non-null.
node - The DTM node handle.
Method Detail

getDTM

public final DTM getDTM()
NON-DOM: Return the DTM model

Returns:
The DTM that this proxy is a representative for.

getDTMNodeNumber

public final int getDTMNodeNumber()
NON-DOM: Return the DTM node number

Returns:
The DTM node handle.

equals

public final boolean equals(Node node)
Test for equality based on node number.

Parameters:
node - A DTM node proxy reference.
Returns:
true if the given node has the same handle as this node.

equals

public final boolean equals(java.lang.Object node)
Test for equality based on node number.

Parameters:
node - A DTM node proxy reference.
Returns:
true if the given node has the same handle as this node.

sameNodeAs

public final boolean sameNodeAs(Node other)
FUTURE DOM: Test node identity, in lieu of Node==Node

Parameters:
other -
Returns:
true if the given node has the same handle as this node.

getNodeName

public final java.lang.String getNodeName()
Description copied from interface: Node
The name of this node, depending on its type; see the table above.

Specified by:
getNodeName in interface Node
See Also:
Node

getTarget

public final java.lang.String getTarget()
A PI's "target" states what processor channel the PI's data should be directed to. It is defined differently in HTML and XML.

In XML, a PI's "target" is the first (whitespace-delimited) token following the " In HTML, target is always null.

Note that getNodeName is aliased to getTarget.

Specified by:
getTarget in interface ProcessingInstruction

getLocalName

public final java.lang.String getLocalName()
Description copied from interface: Node
Returns the local part of the qualified name of this node.
For nodes of any type other than ELEMENT_NODE and ATTRIBUTE_NODE and nodes created with a DOM Level 1 method, such as createElement from the Document interface, this is always null.

Specified by:
getLocalName in interface Node
See Also:
as of DOM Level 2

getPrefix

public final java.lang.String getPrefix()
Description copied from interface: Node
The namespace prefix of this node, or null if it is unspecified.
Note that setting this attribute, when permitted, changes the nodeName attribute, which holds the qualified name, as well as the tagName and name attributes of the Element and Attr interfaces, when applicable.
Note also that changing the prefix of an attribute that is known to have a default value, does not make a new attribute with the default value and the original prefix appear, since the namespaceURI and localName do not change.
For nodes of any type other than ELEMENT_NODE and ATTRIBUTE_NODE and nodes created with a DOM Level 1 method, such as createElement from the Document interface, this is always null.

Specified by:
getPrefix in interface Node
Returns:
The prefix for this node.
See Also:
as of DOM Level 2

setPrefix

public final void setPrefix(java.lang.String prefix)
                     throws DOMException
Description copied from interface: Node
The namespace prefix of this node, or null if it is unspecified.
Note that setting this attribute, when permitted, changes the nodeName attribute, which holds the qualified name, as well as the tagName and name attributes of the Element and Attr interfaces, when applicable.
Note also that changing the prefix of an attribute that is known to have a default value, does not make a new attribute with the default value and the original prefix appear, since the namespaceURI and localName do not change.
For nodes of any type other than ELEMENT_NODE and ATTRIBUTE_NODE and nodes created with a DOM Level 1 method, such as createElement from the Document interface, this is always null.

Specified by:
setPrefix in interface Node
Parameters:
prefix -
Throws:
DOMException
See Also:
as of DOM Level 2 -- DTMNodeProxy is read-only

getNamespaceURI

public final java.lang.String getNamespaceURI()
Description copied from interface: Node
The namespace URI of this node, or null if it is unspecified.
This is not a computed value that is the result of a namespace lookup based on an examination of the namespace declarations in scope. It is merely the namespace URI given at creation time.
For nodes of any type other than ELEMENT_NODE and ATTRIBUTE_NODE and nodes created with a DOM Level 1 method, such as createElement from the Document interface, this is always null.Per the Namespaces in XML Specification an attribute does not inherit its namespace from the element it is attached to. If an attribute is not explicitly given a namespace, it simply has no namespace.

Specified by:
getNamespaceURI in interface Node
See Also:
as of DOM Level 2

supports

public final boolean supports(java.lang.String feature,
                              java.lang.String version)
Ask whether we support a given DOM feature. In fact, we do not _fully_ support any DOM feature -- we're a read-only subset -- so arguably we should always return false. Or we could say that we support DOM Core Level 2 but all nodes are read-only. Unclear which answer is least misleading. NON-DOM method. This was present in early drafts of DOM Level 2, but was renamed isSupported. It's present here only because it's cheap, harmless, and might help some poor fool who is still trying to use an early Working Draft of the DOM.

Parameters:
feature -
version -
Returns:
false

isSupported

public final boolean isSupported(java.lang.String feature,
                                 java.lang.String version)
Ask whether we support a given DOM feature. In fact, we do not _fully_ support any DOM feature -- we're a read-only subset -- so arguably we should always return false.

Specified by:
isSupported in interface Node
Parameters:
feature -
version -
Returns:
false
See Also:
as of DOM Level 2

getNodeValue

public final java.lang.String getNodeValue()
                                    throws DOMException
Description copied from interface: Node
The value of this node, depending on its type; see the table above. When it is defined to be null, setting it has no effect.

Specified by:
getNodeValue in interface Node
Throws:
DOMException
See Also:
Node

getStringValue

public final java.lang.String getStringValue()
                                      throws DOMException
Returns:
The string value of the node
Throws:
DOMException

setNodeValue

public final void setNodeValue(java.lang.String nodeValue)
                        throws DOMException
Description copied from interface: Node
The value of this node, depending on its type; see the table above. When it is defined to be null, setting it has no effect.

Specified by:
setNodeValue in interface Node
Parameters:
nodeValue -
Throws:
DOMException
See Also:
-- DTMNodeProxy is read-only

getNodeType

public final short getNodeType()
Description copied from interface: Node
A code representing the type of the underlying object, as defined above.

Specified by:
getNodeType in interface Node
See Also:
Node

getParentNode

public final Node getParentNode()
Description copied from interface: Node
The parent of this node. All nodes, except Attr, Document, DocumentFragment, Entity, and Notation may have a parent. However, if a node has just been created and not yet added to the tree, or if it has been removed from the tree, this is null.

Specified by:
getParentNode in interface Node
See Also:
Node

getOwnerNode

public final Node getOwnerNode()
See Also:
Node

getChildNodes

public final 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
See Also:
Node

getFirstChild

public final 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
See Also:
Node

getLastChild

public final 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
See Also:
Node

getPreviousSibling

public final Node getPreviousSibling()
Description copied from interface: Node
The node immediately preceding this node. If there is no such node, this returns null.

Specified by:
getPreviousSibling in interface Node
See Also:
Node

getNextSibling

public final Node getNextSibling()
Description copied from interface: Node
The node immediately following this node. If there is no such node, this returns null.

Specified by:
getNextSibling in interface Node
See Also:
Node

getAttributes

public final NamedNodeMap getAttributes()
Description copied from interface: Node
A NamedNodeMap containing the attributes of this node (if it is an Element) or null otherwise.

Specified by:
getAttributes in interface Node
See Also:
Node

hasAttribute

public boolean hasAttribute(java.lang.String name)
Method hasAttribute

Specified by:
hasAttribute in interface Element
Parameters:
name -
Returns:
true if an attribute with the given name is specified on this element or has a default value, false otherwise.

hasAttributeNS

public boolean hasAttributeNS(java.lang.String name,
                              java.lang.String x)
Method hasAttributeNS

Specified by:
hasAttributeNS in interface Element
Parameters:
name -
x -
Returns:
true if an attribute with the given local name and namespace URI is specified or has a default value on this element, false otherwise.

getOwnerDocument

public final Document getOwnerDocument()
Description copied from interface: Node
The Document object associated with this node. This is also the Document object used to create new nodes. When this node is a Document or a DocumentType which is not used with any Document yet, this is null.

Specified by:
getOwnerDocument in interface Node
See Also:
Node

insertBefore

public final 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
Parameters:
newChild -
refChild -
Returns:
The node being inserted.
Throws:
DOMException
See Also:
-- DTMNodeProxy is read-only

replaceChild

public final 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
Parameters:
newChild -
oldChild -
Returns:
The node replaced.
Throws:
DOMException
See Also:
-- DTMNodeProxy is read-only

removeChild

public final 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
Parameters:
oldChild -
Returns:
The node removed.
Throws:
DOMException
See Also:
-- DTMNodeProxy is read-only

appendChild

public final 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
Parameters:
newChild -
Returns:
The node added.
Throws:
DOMException
See Also:
-- DTMNodeProxy is read-only

hasChildNodes

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

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

cloneNode

public final 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
Parameters:
deep -
Returns:
The duplicate node.
See Also:
-- DTMNodeProxy is read-only

getDoctype

public final DocumentType getDoctype()
Description copied from interface: Document
The Document Type Declaration (see DocumentType) associated with this document. For HTML documents as well as XML documents without a document type declaration this returns null. The DOM Level 2 does not support editing the Document Type Declaration. docType cannot be altered in any way, including through the use of methods inherited from the Node interface, such as insertNode or removeNode.

Specified by:
getDoctype in interface Document
See Also:
Document

getImplementation

public final DOMImplementation getImplementation()
Description copied from interface: Document
The DOMImplementation object that handles this document. A DOM application may use objects from multiple implementations.

Specified by:
getImplementation in interface Document
See Also:
Document

getDocumentElement

public final Element getDocumentElement()
This is a bit of a problem in DTM, since a DTM may be a Document Fragment and hence not have a clear-cut Document Element. We can make it work in the well-formed cases but would that be confusing for others?

Specified by:
getDocumentElement in interface Document
See Also:
Document

createElement

public final Element createElement(java.lang.String tagName)
                            throws DOMException
Description copied from interface: Document
Creates an element of the type specified. Note that the instance returned implements the Element interface, so attributes can be specified directly on the returned object.
In addition, if there are known attributes with default values, Attr nodes representing them are automatically created and attached to the element.
To create an element with a qualified name and namespace URI, use the createElementNS method.

Specified by:
createElement in interface Document
Parameters:
tagName -
Returns:
A new Element object with the nodeName attribute set to tagName, and localName, prefix, and namespaceURI set to null.
Throws:
DOMException
See Also:
Document

createDocumentFragment

public final DocumentFragment createDocumentFragment()
Description copied from interface: Document
Creates an empty DocumentFragment object.

Specified by:
createDocumentFragment in interface Document
Returns:
A new DocumentFragment.
See Also:
Document

createTextNode

public final Text createTextNode(java.lang.String data)
Description copied from interface: Document
Creates a Text node given the specified string.

Specified by:
createTextNode in interface Document
Parameters:
data -
Returns:
The new Text object.
See Also:
Document

createComment

public final Comment createComment(java.lang.String data)
Description copied from interface: Document
Creates a Comment node given the specified string.

Specified by:
createComment in interface Document
Parameters:
data -
Returns:
The new Comment object.
See Also:
Document

createCDATASection

public final CDATASection createCDATASection(java.lang.String data)
                                      throws DOMException
Description copied from interface: Document
Creates a CDATASection node whose value is the specified string.

Specified by:
createCDATASection in interface Document
Parameters:
data -
Returns:
The new CDATASection object.
Throws:
DOMException
See Also:
Document

createProcessingInstruction

public final ProcessingInstruction createProcessingInstruction(java.lang.String target,
                                                               java.lang.String data)
                                                        throws DOMException
Description copied from interface: Document
Creates a ProcessingInstruction node given the specified name and data strings.

Specified by:
createProcessingInstruction in interface Document
Parameters:
target -
data -
Returns:
The new ProcessingInstruction object.
Throws:
DOMException
See Also:
Document

createAttribute

public final Attr createAttribute(java.lang.String name)
                           throws DOMException
Description copied from interface: Document
Creates an Attr of the given name. Note that the Attr instance can then be set on an Element using the setAttributeNode method.
To create an attribute with a qualified name and namespace URI, use the createAttributeNS method.

Specified by:
createAttribute in interface Document
Parameters:
name -
Returns:
A new Attr object with the nodeName attribute set to name, and localName, prefix, and namespaceURI set to null. The value of the attribute is the empty string.
Throws:
DOMException
See Also:
Document

createEntityReference

public final EntityReference createEntityReference(java.lang.String name)
                                            throws DOMException
Description copied from interface: Document
Creates an EntityReference object. In addition, if the referenced entity is known, the child list of the EntityReference node is made the same as that of the corresponding Entity node.If any descendant of the Entity node has an unbound namespace prefix, the corresponding descendant of the created EntityReference node is also unbound; (its namespaceURI is null). The DOM Level 2 does not support any mechanism to resolve namespace prefixes.

Specified by:
createEntityReference in interface Document
Parameters:
name -
Returns:
The new EntityReference object.
Throws:
DOMException
See Also:
Document

getElementsByTagName

public final NodeList getElementsByTagName(java.lang.String tagname)
Description copied from interface: Document
Returns a NodeList of all the Elements with a given tag name in the order in which they are encountered in a preorder traversal of the Document tree.

Specified by:
getElementsByTagName in interface Document
Parameters:
tagname -
Returns:
A new NodeList object containing all the matched Elements.
See Also:
Document

importNode

public final Node importNode(Node importedNode,
                             boolean deep)
                      throws DOMException
Description copied from interface: Document
Imports a node from another document to this document. The returned node has no parent; (parentNode is null). The source node is not altered or removed from the original document; this method creates a new copy of the source node.
For all nodes, importing a node creates a node object owned by the importing document, with attribute values identical to the source node's nodeName and nodeType, plus the attributes related to namespaces (prefix, localName, and namespaceURI). As in the cloneNode operation on a Node, the source node is not altered.
Additional information is copied as appropriate to the nodeType, attempting to mirror the behavior expected if a fragment of XML or HTML source was copied from one document to another, recognizing that the two documents may have different DTDs in the XML case. The following list describes the specifics for each type of node.
ATTRIBUTE_NODE
The ownerElement attribute is set to null and the specified flag is set to true on the generated Attr. The descendants of the source Attr are recursively imported and the resulting nodes reassembled to form the corresponding subtree. Note that the deep parameter has no effect on Attr nodes; they always carry their children with them when imported.
DOCUMENT_FRAGMENT_NODE
If the deep option was set to true, the descendants of the source element are recursively imported and the resulting nodes reassembled to form the corresponding subtree. Otherwise, this simply generates an empty DocumentFragment.
DOCUMENT_NODE
Document nodes cannot be imported.
DOCUMENT_TYPE_NODE
DocumentType nodes cannot be imported.
ELEMENT_NODE
Specified attribute nodes of the source element are imported, and the generated Attr nodes are attached to the generated Element. Default attributes are not copied, though if the document being imported into defines default attributes for this element name, those are assigned. If the importNode deep parameter was set to true, the descendants of the source element are recursively imported and the resulting nodes reassembled to form the corresponding subtree.
ENTITY_NODE
Entity nodes can be imported, however in the current release of the DOM the DocumentType is readonly. Ability to add these imported nodes to a DocumentType will be considered for addition to a future release of the DOM.On import, the publicId, systemId, and notationName attributes are copied. If a deep import is requested, the descendants of the the source Entity are recursively imported and the resulting nodes reassembled to form the corresponding subtree.
ENTITY_REFERENCE_NODE
Only the EntityReference itself is copied, even if a deep import is requested, since the source and destination documents might have defined the entity differently. If the document being imported into provides a definition for this entity name, its value is assigned.
NOTATION_NODE
Notation nodes can be imported, however in the current release of the DOM the DocumentType is readonly. Ability to add these imported nodes to a DocumentType will be considered for addition to a future release of the DOM.On import, the publicId and systemId attributes are copied. Note that the deep parameter has no effect on Notation nodes since they never have any children.
PROCESSING_INSTRUCTION_NODE
The imported node copies its target and data values from those of the source node.
TEXT_NODE, CDATA_SECTION_NODE, COMMENT_NODE
These three types of nodes inheriting from CharacterData copy their data and length attributes from those of the source node.

Specified by:
importNode in interface Document
Parameters:
importedNode -
deep -
Returns:
The imported node that belongs to this Document.
Throws:
DOMException
See Also:
as of DOM Level 2 -- DTMNodeProxy is read-only

createElementNS

public final Element createElementNS(java.lang.String namespaceURI,
                                     java.lang.String qualifiedName)
                              throws DOMException
Description copied from interface: Document
Creates an element of the given qualified name and namespace URI.

Specified by:
createElementNS in interface Document
Parameters:
namespaceURI -
qualifiedName -
Returns:
A new Element object with the following attributes:
Attribute Value
Node.nodeName qualifiedName
Node.namespaceURI namespaceURI
Node.prefix prefix, extracted from qualifiedName, or null if there is no prefix
Node.localName local name, extracted from qualifiedName
Element.tagName qualifiedName
Throws:
DOMException
See Also:
as of DOM Level 2

createAttributeNS

public final Attr createAttributeNS(java.lang.String namespaceURI,
                                    java.lang.String qualifiedName)
                             throws DOMException
Description copied from interface: Document
Creates an attribute of the given qualified name and namespace URI.

Specified by:
createAttributeNS in interface Document
Parameters:
namespaceURI -
qualifiedName -
Returns:
A new Attr object with the following attributes:
Attribute Value
Node.nodeName qualifiedName
Node.namespaceURI namespaceURI
Node.prefix prefix, extracted from qualifiedName, or null if there is no prefix
Node.localName local name, extracted from qualifiedName
Attr.name qualifiedName
Node.nodeValue the empty string
Throws:
DOMException
See Also:
as of DOM Level 2

getElementsByTagNameNS

public final NodeList getElementsByTagNameNS(java.lang.String namespaceURI,
                                             java.lang.String localName)
Description copied from interface: Document
Returns a NodeList of all the Elements with a given local name and namespace URI in the order in which they are encountered in a preorder traversal of the Document tree.

Specified by:
getElementsByTagNameNS in interface Document
Parameters:
namespaceURI -
localName -
Returns:
A new NodeList object containing all the matched Elements.
See Also:
as of DOM Level 2

getElementById

public final Element getElementById(java.lang.String elementId)
Description copied from interface: Document
Returns the Element whose ID is given by elementId. If no such element exists, returns null. Behavior is not defined if more than one element has this ID. The DOM implementation must have information that says which attributes are of type ID. Attributes with the name "ID" are not of type ID unless so defined. Implementations that do not know whether attributes are of type ID or not are expected to return null.

Specified by:
getElementById in interface Document
Parameters:
elementId -
Returns:
The matching element.
See Also:
as of DOM Level 2

splitText

public final Text splitText(int offset)
                     throws DOMException
Description copied from interface: Text
Breaks this node into two nodes at the specified offset, keeping both in the tree as siblings. After being split, this node will contain all the content up to the offset point. A new node of the same type, which contains all the content at and after the offset point, is returned. If the original node had a parent node, the new node is inserted as the next sibling of the original node. When the offset is equal to the length of this node, the new node has no data.

Specified by:
splitText in interface Text
Parameters:
offset -
Returns:
The new node, of the same type as this node.
Throws:
DOMException
See Also:
Text

getData

public final java.lang.String getData()
                               throws DOMException
Description copied from interface: ProcessingInstruction
The content of this processing instruction. This is from the first non white space character after the target to the character immediately preceding the ?>.

Specified by:
getData in interface CharacterData
Throws:
DOMException
See Also:
CharacterData

setData

public final void setData(java.lang.String data)
                   throws DOMException
Description copied from interface: ProcessingInstruction
The content of this processing instruction. This is from the first non white space character after the target to the character immediately preceding the ?>.

Specified by:
setData in interface CharacterData
Parameters:
data -
Throws:
DOMException
See Also:
CharacterData

getLength

public final int getLength()
Description copied from interface: CharacterData
The number of 16-bit units that are available through data and the substringData method below. This may have the value zero, i.e., CharacterData nodes may be empty.

Specified by:
getLength in interface CharacterData
See Also:
CharacterData

substringData

public final java.lang.String substringData(int offset,
                                            int count)
                                     throws DOMException
Description copied from interface: CharacterData
Extracts a range of data from the node.

Specified by:
substringData in interface CharacterData
Parameters:
offset -
count -
Returns:
The specified substring. If the sum of offset and count exceeds the length, then all 16-bit units to the end of the data are returned.
Throws:
DOMException
See Also:
CharacterData

appendData

public final void appendData(java.lang.String arg)
                      throws DOMException
Description copied from interface: CharacterData
Append the string to the end of the character data of the node. Upon success, data provides access to the concatenation of data and the DOMString specified.

Specified by:
appendData in interface CharacterData
Parameters:
arg -
Throws:
DOMException
See Also:
CharacterData

insertData

public final void insertData(int offset,
                             java.lang.String arg)
                      throws DOMException
Description copied from interface: CharacterData
Insert a string at the specified 16-bit unit offset.

Specified by:
insertData in interface CharacterData
Parameters:
offset -
arg -
Throws:
DOMException
See Also:
CharacterData

deleteData

public final void deleteData(int offset,
                             int count)
                      throws DOMException
Description copied from interface: CharacterData
Remove a range of 16-bit units from the node. Upon success, data and length reflect the change.

Specified by:
deleteData in interface CharacterData
Parameters:
offset -
count -
Throws:
DOMException
See Also:
CharacterData

replaceData

public final void replaceData(int offset,
                              int count,
                              java.lang.String arg)
                       throws DOMException
Description copied from interface: CharacterData
Replace the characters starting at the specified 16-bit unit offset with the specified string.

Specified by:
replaceData in interface CharacterData
Parameters:
offset -
count -
arg -
Throws:
DOMException
See Also:
CharacterData

getTagName

public final java.lang.String getTagName()
Description copied from interface: Element
The name of the element. For example, in:
 <elementExample 
 id="demo"> ... </elementExample> , 
tagName has the value "elementExample". Note that this is case-preserving in XML, as are all of the operations of the DOM. The HTML DOM returns the tagName of an HTML element in the canonical uppercase form, regardless of the case in the source HTML document.

Specified by:
getTagName in interface Element
See Also:
Element

getAttribute

public final java.lang.String getAttribute(java.lang.String name)
Description copied from interface: Element
Retrieves an attribute value by name.

Specified by:
getAttribute in interface Element
Parameters:
name -
Returns:
The Attr value as a string, or the empty string if that attribute does not have a specified or default value.
See Also:
Element

setAttribute

public final void setAttribute(java.lang.String name,
                               java.lang.String value)
                        throws DOMException
Description copied from interface: Element
Adds a new attribute. If an attribute with that name is already present in the element, its value is changed to be that of the value parameter. This value is a simple string; it is not parsed as it is being set. So any markup (such as syntax to be recognized as an entity reference) is treated as literal text, and needs to be appropriately escaped by the implementation when it is written out. In order to assign an attribute value that contains entity references, the user must create an Attr node plus any Text and EntityReference nodes, build the appropriate subtree, and use setAttributeNode to assign it as the value of an attribute.
To set an attribute with a qualified name and namespace URI, use the setAttributeNS method.

Specified by:
setAttribute in interface Element
Parameters:
name -
value -
Throws:
DOMException
See Also:
Element

removeAttribute

public final void removeAttribute(java.lang.String name)
                           throws DOMException
Description copied from interface: Element
Removes an attribute by name. If the removed attribute is known to have a default value, an attribute immediately appears containing the default value as well as the corresponding namespace URI, local name, and prefix when applicable.
To remove an attribute by local name and namespace URI, use the removeAttributeNS method.

Specified by:
removeAttribute in interface Element
Parameters:
name -
Throws:
DOMException
See Also:
Element

getAttributeNode

public final Attr getAttributeNode(java.lang.String name)
Description copied from interface: Element
Retrieves an attribute node by name.
To retrieve an attribute node by qualified name and namespace URI, use the getAttributeNodeNS method.

Specified by:
getAttributeNode in interface Element
Parameters:
name -
Returns:
The Attr node with the specified name ( nodeName) or null if there is no such attribute.
See Also:
Element

setAttributeNode

public final Attr setAttributeNode(Attr newAttr)
                            throws DOMException
Description copied from interface: Element
Adds a new attribute node. If an attribute with that name ( nodeName) is already present in the element, it is replaced by the new one.
To add a new attribute node with a qualified name and namespace URI, use the setAttributeNodeNS method.

Specified by:
setAttributeNode in interface Element
Parameters:
newAttr -
Returns:
If the newAttr attribute replaces an existing attribute, the replaced Attr node is returned, otherwise null is returned.
Throws:
DOMException
See Also:
Element

removeAttributeNode

public final Attr removeAttributeNode(Attr oldAttr)
                               throws DOMException
Description copied from interface: Element
Removes the specified attribute node. If the removed Attr has a default value it is immediately replaced. The replacing attribute has the same namespace URI and local name, as well as the original prefix, when applicable.

Specified by:
removeAttributeNode in interface Element
Parameters:
oldAttr -
Returns:
The Attr node that was removed.
Throws:
DOMException
See Also:
Element

hasAttributes

public boolean hasAttributes()
Introduced in DOM Level 2.

Specified by:
hasAttributes in interface Node
Returns:
true if this node has any attributes, false otherwise.

normalize

public final 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
See Also:
Element

getAttributeNS

public final java.lang.String getAttributeNS(java.lang.String namespaceURI,
                                             java.lang.String localName)
Description copied from interface: Element
Retrieves an attribute value by local name and namespace URI.
Documents which do not support the "XML" feature will permit only the DOM Level 1 calls for creating/setting elements and attributes. Hence, if you specify a non-null namespace URI, these DOMs will never find a matching node.

Specified by:
getAttributeNS in interface Element
Parameters:
namespaceURI -
localName -
Returns:
The Attr value as a string, or the empty string if that attribute does not have a specified or default value.
See Also:
Element

setAttributeNS

public final void setAttributeNS(java.lang.String namespaceURI,
                                 java.lang.String qualifiedName,
                                 java.lang.String value)
                          throws DOMException
Description copied from interface: Element
Adds a new attribute. If an attribute with the same local name and namespace URI is already present on the element, its prefix is changed to be the prefix part of the qualifiedName, and its value is changed to be the value parameter. This value is a simple string; it is not parsed as it is being set. So any markup (such as syntax to be recognized as an entity reference) is treated as literal text, and needs to be appropriately escaped by the implementation when it is written out. In order to assign an attribute value that contains entity references, the user must create an Attr node plus any Text and EntityReference nodes, build the appropriate subtree, and use setAttributeNodeNS or setAttributeNode to assign it as the value of an attribute.

Specified by:
setAttributeNS in interface Element
Parameters:
namespaceURI -
qualifiedName -
value -
Throws:
DOMException
See Also:
Element

removeAttributeNS

public final void removeAttributeNS(java.lang.String namespaceURI,
                                    java.lang.String localName)
                             throws DOMException
Description copied from interface: Element
Removes an attribute by local name and namespace URI. If the removed attribute has a default value it is immediately replaced. The replacing attribute has the same namespace URI and local name, as well as the original prefix.
Documents which do not support the "XML" feature will permit only the DOM Level 1 calls for creating/setting elements and attributes. Hence, if you specify a non-null namespace URI, these DOMs will never find a matching node.

Specified by:
removeAttributeNS in interface Element
Parameters:
namespaceURI -
localName -
Throws:
DOMException
See Also:
Element

getAttributeNodeNS

public final Attr getAttributeNodeNS(java.lang.String namespaceURI,
                                     java.lang.String localName)
Description copied from interface: Element
Retrieves an Attr node by local name and namespace URI.
Documents which do not support the "XML" feature will permit only the DOM Level 1 calls for creating/setting elements and attributes. Hence, if you specify a non-null namespace URI, these DOMs will never find a matching node.

Specified by:
getAttributeNodeNS in interface Element
Parameters:
namespaceURI -
localName -
Returns:
The Attr node with the specified attribute local name and namespace URI or null if there is no such attribute.
See Also:
Element

setAttributeNodeNS

public final Attr setAttributeNodeNS(Attr newAttr)
                              throws DOMException
Description copied from interface: Element
Adds a new attribute. If an attribute with that local name and that namespace URI is already present in the element, it is replaced by the new one.

Specified by:
setAttributeNodeNS in interface Element
Parameters:
newAttr -
Returns:
If the newAttr attribute replaces an existing attribute with the same local name and namespace URI, the replaced Attr node is returned, otherwise null is returned.
Throws:
DOMException
See Also:
Element

getName

public final java.lang.String getName()
Description copied from interface: Attr
Returns the name of this attribute.

Specified by:
getName in interface Attr
See Also:
Attr

getSpecified

public final boolean getSpecified()
Description copied from interface: Attr
If this attribute was explicitly given a value in the original document, this is true; otherwise, it is false. Note that the implementation is in charge of this attribute, not the user. If the user changes the value of the attribute (even if it ends up having the same value as the default value) then the specified flag is automatically flipped to true. To re-specify the attribute as the default value from the DTD, the user must delete the attribute. The implementation will then make a new attribute available with specified set to false and the default value (if one exists).
In summary: If the attribute has an assigned value in the document then specified is true, and the value is the assigned value.If the attribute has no assigned value in the document and has a default value in the DTD, then specified is false, and the value is the default value in the DTD.If the attribute has no assigned value in the document and has a value of #IMPLIED in the DTD, then the attribute does not appear in the structure model of the document.If the ownerElement attribute is null (i.e. because it was just created or was set to null by the various removal and cloning operations) specified is true.

Specified by:
getSpecified in interface Attr
See Also:
Attr

getValue

public final java.lang.String getValue()
Description copied from interface: Attr
On retrieval, the value of the attribute is returned as a string. Character and general entity references are replaced with their values. See also the method getAttribute on the Element interface.
On setting, this creates a Text node with the unparsed contents of the string. I.e. any characters that an XML processor would recognize as markup are instead treated as literal text. See also the method setAttribute on the Element interface.

Specified by:
getValue in interface Attr
See Also:
Attr

setValue

public final void setValue(java.lang.String value)
Description copied from interface: Attr
On retrieval, the value of the attribute is returned as a string. Character and general entity references are replaced with their values. See also the method getAttribute on the Element interface.
On setting, this creates a Text node with the unparsed contents of the string. I.e. any characters that an XML processor would recognize as markup are instead treated as literal text. See also the method setAttribute on the Element interface.

Specified by:
setValue in interface Attr
Parameters:
value -
See Also:
Attr

getOwnerElement

public final Element getOwnerElement()
Get the owner element of an attribute.

Specified by:
getOwnerElement in interface Attr
See Also:
as of DOM Level 2

adoptNode

public Node adoptNode(Node source)
               throws DOMException
NEEDSDOC Method adoptNode NEEDSDOC @param source

Throws:
DOMException

getEncoding

public java.lang.String getEncoding()

EXPERIMENTAL! Based on the Document Object Model (DOM) Level 3 Core Working Draft of 5 June 2001..

An attribute specifying, as part of the XML declaration, the encoding of this document. This is null when unspecified.

Since:
DOM Level 3

setEncoding

public void setEncoding(java.lang.String encoding)

EXPERIMENTAL! Based on the Document Object Model (DOM) Level 3 Core Working Draft of 5 June 2001..

An attribute specifying, as part of the XML declaration, the encoding of this document. This is null when unspecified.

Since:
DOM Level 3 NEEDSDOC @param encoding

getStandalone

public boolean getStandalone()

EXPERIMENTAL! Based on the Document Object Model (DOM) Level 3 Core Working Draft of 5 June 2001..

An attribute specifying, as part of the XML declaration, whether this document is standalone.

Since:
DOM Level 3

setStandalone

public void setStandalone(boolean standalone)

EXPERIMENTAL! Based on the Document Object Model (DOM) Level 3 Core Working Draft of 5 June 2001..

An attribute specifying, as part of the XML declaration, whether this document is standalone.

Since:
DOM Level 3 NEEDSDOC @param standalone

getStrictErrorChecking

public boolean getStrictErrorChecking()

EXPERIMENTAL! Based on the Document Object Model (DOM) Level 3 Core Working Draft of 5 June 2001..

An attribute specifying whether errors checking is enforced or not. When set to false, the implementation is free to not test every possible error case normally defined on DOM operations, and not raise any DOMException. In case of error, the behavior is undefined. This attribute is true by defaults.

Since:
DOM Level 3

setStrictErrorChecking

public void setStrictErrorChecking(boolean strictErrorChecking)

EXPERIMENTAL! Based on the Document Object Model (DOM) Level 3 Core Working Draft of 5 June 2001..

An attribute specifying whether errors checking is enforced or not. When set to false, the implementation is free to not test every possible error case normally defined on DOM operations, and not raise any DOMException. In case of error, the behavior is undefined. This attribute is true by defaults.

Since:
DOM Level 3 NEEDSDOC @param strictErrorChecking

getVersion

public java.lang.String getVersion()

EXPERIMENTAL! Based on the Document Object Model (DOM) Level 3 Core Working Draft of 5 June 2001..

An attribute specifying, as part of the XML declaration, the version number of this document. This is null when unspecified.

Since:
DOM Level 3

setVersion

public void setVersion(java.lang.String version)

EXPERIMENTAL! Based on the Document Object Model (DOM) Level 3 Core Working Draft of 5 June 2001..

An attribute specifying, as part of the XML declaration, the version number of this document. This is null when unspecified.

Since:
DOM Level 3 NEEDSDOC @param version


Copyright © 2004 Apache XML Project. All Rights Reserved.