Class DTMNodeProxy
- All Implemented Interfaces:
Attr,CharacterData,Comment,Document,DocumentFragment,Element,Node,ProcessingInstruction,Text
public class DTMNodeProxy extends 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
-
Field Summary
Fields Modifier and Type Field Description protected StringactualEncodingDOM Level 3 feature: Document actualEncodingDTMdtmThe DTM for this node.protected StringfDocumentURIDOM Level 3 feature: documentURIFields inherited from interface org.w3c.dom.Node
ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_POSITION_CONTAINED_BY, DOCUMENT_POSITION_CONTAINS, DOCUMENT_POSITION_DISCONNECTED, DOCUMENT_POSITION_FOLLOWING, DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, DOCUMENT_POSITION_PRECEDING, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE -
Constructor Summary
Constructors Constructor Description DTMNodeProxy(DTM dtm, int node)Create a DTMNodeProxy Node representing a specific Node in a DTM -
Method Summary
Modifier and Type Method Description NodeadoptNode(Node source)NEEDSDOC Method adoptNode NEEDSDOC @param sourceNodeappendChild(Node newChild)Adds the nodenewChildto the end of the list of children of this node.voidappendData(String arg)Append the string to the end of the character data of the node.NodecloneNode(boolean deep)Returns a duplicate of this node, i.e., serves as a generic copy constructor for nodes.shortcompareDocumentPosition(Node other)Compares a node with this node with regard to their position in the document.AttrcreateAttribute(String name)Creates anAttrof the given name.AttrcreateAttributeNS(String namespaceURI, String qualifiedName)Creates an attribute of the given qualified name and namespace URI.CDATASectioncreateCDATASection(String data)Creates aCDATASectionnode whose value is the specified string.CommentcreateComment(String data)Creates aCommentnode given the specified string.DocumentFragmentcreateDocumentFragment()Creates an emptyDocumentFragmentobject.ElementcreateElement(String tagName)Creates an element of the type specified.ElementcreateElementNS(String namespaceURI, String qualifiedName)Creates an element of the given qualified name and namespace URI.EntityReferencecreateEntityReference(String name)Creates anEntityReferenceobject.ProcessingInstructioncreateProcessingInstruction(String target, String data)Creates aProcessingInstructionnode given the specified name and data strings.TextcreateTextNode(String data)Creates aTextnode given the specified string.voiddeleteData(int offset, int count)Remove a range of 16-bit units from the node.booleanequals(Object node)Test for equality based on node number.booleanequals(Node node)Test for equality based on node number.StringgetActualEncoding()DOM Level 3 An attribute specifying the actual encoding of this document.StringgetAttribute(String name)Retrieves an attribute value by name.AttrgetAttributeNode(String name)Retrieves an attribute node by name.AttrgetAttributeNodeNS(String namespaceURI, String localName)Retrieves anAttrnode by local name and namespace URI.StringgetAttributeNS(String namespaceURI, String localName)Retrieves an attribute value by local name and namespace URI.NamedNodeMapgetAttributes()ANamedNodeMapcontaining the attributes of this node (if it is anElement) ornullotherwise.StringgetBaseURI()The absolute base URI of this node ornullif undefined.NodeListgetChildNodes()ANodeListthat contains all children of this node.StringgetData()The character data of the node that implements this interface.DocumentTypegetDoctype()The Document Type Declaration (seeDocumentType) associated with this document.ElementgetDocumentElement()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.StringgetDocumentURI()DOM Level 3 The location of the document ornullif undefined.DOMConfigurationgetDomConfig()The configuration used whenDocument.normalizeDocumentis invoked.DTMgetDTM()NON-DOM: Return the DTM modelintgetDTMNodeNumber()NON-DOM: Return the DTM node numberElementgetElementById(String elementId)Returns theElementthat has an ID attribute with the given value.NodeListgetElementsByTagName(String tagname)Returns aNodeListof all theElementsin document order with a given tag name and are contained in the document.NodeListgetElementsByTagNameNS(String namespaceURI, String localName)Returns aNodeListof all theElementswith a given local name and namespace URI in document order.ObjectgetFeature(String feature, String version)This method returns a specialized object which implements the specialized APIs of the specified feature and version.NodegetFirstChild()The first child of this node.DOMImplementationgetImplementation()TheDOMImplementationobject that handles this document.StringgetInputEncoding()NodegetLastChild()The last child of this node.intgetLength()The number of 16-bit units that are available throughdataand thesubstringDatamethod below.StringgetLocalName()Returns the local part of the qualified name of this node.StringgetName()Returns the name of this attribute.StringgetNamespaceURI()The namespace URI of this node, ornullif it is unspecified (see ).NodegetNextSibling()The node immediately following this node.StringgetNodeName()The name of this node, depending on its type; see the table above.shortgetNodeType()A code representing the type of the underlying object, as defined above.StringgetNodeValue()The value of this node, depending on its type; see the table above.DocumentgetOwnerDocument()TheDocumentobject associated with this node.ElementgetOwnerElement()Get the owner element of an attribute.NodegetOwnerNode()NodegetParentNode()The parent of this node.StringgetPrefix()The namespace prefix of this node, ornullif it is unspecified.NodegetPreviousSibling()The node immediately preceding this node.TypeInfogetSchemaTypeInfo()The type information associated with this element.booleangetSpecified()Trueif this attribute was explicitly given a value in the instance document,falseotherwise.booleangetStrictErrorChecking()StringgetStringValue()StringgetTagName()The name of the element.StringgetTarget()A PI's "target" states what processor channel the PI's data should be directed to.StringgetTextContent()This attribute returns the text content of this node and its descendants.ObjectgetUserData(String key)Retrieves the object associated to a key on a this node.StringgetValue()On retrieval, the value of the attribute is returned as a string.StringgetWholeText()DOM Level 3 Returns all text ofTextnodes logically-adjacent text nodes to this node, concatenated in document order.StringgetXmlEncoding()An attribute specifying, as part of the XML declaration, the encoding of this document.booleangetXmlStandalone()An attribute specifying, as part of the XML declaration, whether this document is standalone.StringgetXmlVersion()An attribute specifying, as part of the XML declaration, the version number of this document.booleanhasAttribute(String name)Method hasAttributebooleanhasAttributeNS(String namespaceURI, String localName)Method hasAttributeNSbooleanhasAttributes()Introduced in DOM Level 2.booleanhasChildNodes()Returns whether this node has any children.NodeimportNode(Node importedNode, boolean deep)Imports a node from another document to this document, without altering or removing the source node from the original document; this method creates a new copy of the source node.NodeinsertBefore(Node newChild, Node refChild)Inserts the nodenewChildbefore the existing child noderefChild.voidinsertData(int offset, String arg)Insert a string at the specified 16-bit unit offset.booleanisDefaultNamespace(String namespaceURI)DOM Level 3: This method checks if the specifiednamespaceURIis the default namespace or not.booleanisElementContentWhitespace()DOM Level 3 Returns whether this text node contains whitespace in element content, often abusively called "ignorable whitespace".booleanisEqualNode(Node arg)Tests whether two nodes are equal.booleanisId()Returns whether this attribute is known to be of type ID (i.e.booleanisSameNode(Node other)Returns whether this node is the same node as the given one.booleanisSupported(String feature, String version)Ask whether we support a given DOM feature.StringlookupNamespaceURI(String specifiedPrefix)DOM Level 3: Look up the namespace URI associated to the given prefix, starting from this node.StringlookupPrefix(String namespaceURI)DOM Level 3: Look up the prefix associated to the given namespace URI, starting from this node.voidnormalize()Puts allTextnodes in the full depth of the sub-tree underneath thisNode, including attribute nodes, into a "normal" form where only structure (e.g., elements, comments, processing instructions, CDATA sections, and entity references) separatesTextnodes, i.e., there are neither adjacentTextnodes nor emptyTextnodes.voidnormalizeDocument()DOM Level 3 Normalize document.voidremoveAttribute(String name)Removes an attribute by name.AttrremoveAttributeNode(Attr oldAttr)Removes the specified attribute node.voidremoveAttributeNS(String namespaceURI, String localName)Removes an attribute by local name and namespace URI.NoderemoveChild(Node oldChild)Removes the child node indicated byoldChildfrom the list of children, and returns it.NoderenameNode(Node n, String namespaceURI, String name)DOM Level 3 Renaming nodeNodereplaceChild(Node newChild, Node oldChild)Replaces the child nodeoldChildwithnewChildin the list of children, and returns theoldChildnode.voidreplaceData(int offset, int count, String arg)Replace the characters starting at the specified 16-bit unit offset with the specified string.TextreplaceWholeText(String content)DOM Level 3booleansameNodeAs(Node other)FUTURE DOM: Test node identity, in lieu of Node==NodevoidsetActualEncoding(String value)DOM Level 3 An attribute specifying the actual encoding of this document.voidsetAttribute(String name, String value)Adds a new attribute.AttrsetAttributeNode(Attr newAttr)Adds a new attribute node.AttrsetAttributeNodeNS(Attr newAttr)Adds a new attribute.voidsetAttributeNS(String namespaceURI, String qualifiedName, String value)Adds a new attribute.voidsetData(String data)The character data of the node that implements this interface.voidsetDocumentURI(String documentURI)DOM Level 3voidsetIdAttribute(boolean id)NON-DOM: set the type of this attribute to be ID type.voidsetIdAttribute(String name, boolean makeId)DOM Level 3: register the given attribute node as an ID attributevoidsetIdAttributeNode(Attr at, boolean makeId)DOM Level 3: register the given attribute node as an ID attributevoidsetIdAttributeNS(String namespaceURI, String localName, boolean makeId)DOM Level 3: register the given attribute node as an ID attributevoidsetNodeValue(String nodeValue)The value of this node, depending on its type; see the table above.voidsetPrefix(String prefix)The namespace prefix of this node, ornullif it is unspecified.voidsetStrictErrorChecking(boolean strictErrorChecking)voidsetTextContent(String textContent)This attribute returns the text content of this node and its descendants.ObjectsetUserData(String key, Object data, UserDataHandler handler)Associate an object to a key on this node.voidsetValue(String value)On retrieval, the value of the attribute is returned as a string.voidsetXmlEncoding(String xmlEncoding)voidsetXmlStandalone(boolean xmlStandalone)An attribute specifying, as part of the XML declaration, whether this document is standalone.voidsetXmlVersion(String xmlVersion)An attribute specifying, as part of the XML declaration, the version number of this document.TextsplitText(int offset)Breaks this node into two nodes at the specifiedoffset, keeping both in the tree as siblings.StringsubstringData(int offset, int count)Extracts a range of data from the node.booleansupports(String feature, String version)Ask whether we support a given DOM feature.
-
Field Details
-
dtm
The DTM for this node. -
fDocumentURI
DOM Level 3 feature: documentURI -
actualEncoding
DOM Level 3 feature: Document actualEncoding
-
-
Constructor Details
-
DTMNodeProxy
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 Details
-
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
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
Test for equality based on node number.- Overrides:
equalsin classObject- Parameters:
node- A DTM node proxy reference.- Returns:
- true if the given node has the same handle as this node.
- See Also:
Object.hashCode()
-
sameNodeAs
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
Description copied from interface:NodeThe name of this node, depending on its type; see the table above.- Specified by:
getNodeNamein interfaceNode- See Also:
Node
-
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 "" token that begins the PI.
In HTML, target is always null.
Note that getNodeName is aliased to getTarget.
- Specified by:
getTargetin interfaceProcessingInstruction
-
getLocalName
Description copied from interface:NodeReturns the local part of the qualified name of this node.
For nodes of any type other thanELEMENT_NODEandATTRIBUTE_NODEand nodes created with a DOM Level 1 method, such asDocument.createElement(), this is alwaysnull.- Specified by:
getLocalNamein interfaceNode- See Also:
as of DOM Level 2
-
getPrefix
Description copied from interface:NodeThe namespace prefix of this node, ornullif it is unspecified. When it is defined to benull, setting it has no effect, including if the node is read-only.
Note that setting this attribute, when permitted, changes thenodeNameattribute, which holds the qualified name, as well as thetagNameandnameattributes of theElementandAttrinterfaces, when applicable.
Setting the prefix tonullmakes it unspecified, setting it to an empty string is implementation dependent.
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 thenamespaceURIandlocalNamedo not change.
For nodes of any type other thanELEMENT_NODEandATTRIBUTE_NODEand nodes created with a DOM Level 1 method, such ascreateElementfrom theDocumentinterface, this is alwaysnull.- Specified by:
getPrefixin interfaceNode- Returns:
- The prefix for this node.
- See Also:
as of DOM Level 2
-
setPrefix
Description copied from interface:NodeThe namespace prefix of this node, ornullif it is unspecified. When it is defined to benull, setting it has no effect, including if the node is read-only.
Note that setting this attribute, when permitted, changes thenodeNameattribute, which holds the qualified name, as well as thetagNameandnameattributes of theElementandAttrinterfaces, when applicable.
Setting the prefix tonullmakes it unspecified, setting it to an empty string is implementation dependent.
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 thenamespaceURIandlocalNamedo not change.
For nodes of any type other thanELEMENT_NODEandATTRIBUTE_NODEand nodes created with a DOM Level 1 method, such ascreateElementfrom theDocumentinterface, this is alwaysnull.- Specified by:
setPrefixin interfaceNode- Parameters:
prefix-- Throws:
DOMException- See Also:
as of DOM Level 2 -- DTMNodeProxy is read-only
-
getNamespaceURI
Description copied from interface:NodeThe namespace URI of this node, ornullif it is unspecified (see ).
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 thanELEMENT_NODEandATTRIBUTE_NODEand nodes created with a DOM Level 1 method, such asDocument.createElement(), this is alwaysnull.Note: Per the Namespaces in XML Specification [XML Namespaces] 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:
getNamespaceURIin interfaceNode- See Also:
as of DOM Level 2
-
supports
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
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:
isSupportedin interfaceNode- Parameters:
feature-version-- Returns:
- false
- See Also:
as of DOM Level 2
-
getNodeValue
Description copied from interface:NodeThe value of this node, depending on its type; see the table above. When it is defined to benull, setting it has no effect, including if the node is read-only.- Specified by:
getNodeValuein interfaceNode- Throws:
DOMException- See Also:
Node
-
getStringValue
- Returns:
- The string value of the node
- Throws:
DOMException
-
setNodeValue
Description copied from interface:NodeThe value of this node, depending on its type; see the table above. When it is defined to benull, setting it has no effect, including if the node is read-only.- Specified by:
setNodeValuein interfaceNode- Parameters:
nodeValue-- Throws:
DOMException- See Also:
-- DTMNodeProxy is read-only
-
getNodeType
public final short getNodeType()Description copied from interface:NodeA code representing the type of the underlying object, as defined above.- Specified by:
getNodeTypein interfaceNode- See Also:
Node
-
getParentNode
Description copied from interface:NodeThe parent of this node. All nodes, exceptAttr,Document,DocumentFragment,Entity, andNotationmay 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 isnull.- Specified by:
getParentNodein interfaceNode- See Also:
Node
-
getOwnerNode
- See Also:
Node
-
getChildNodes
Description copied from interface:NodeANodeListthat contains all children of this node. If there are no children, this is aNodeListcontaining no nodes.- Specified by:
getChildNodesin interfaceNode- See Also:
Node
-
getFirstChild
Description copied from interface:NodeThe first child of this node. If there is no such node, this returnsnull.- Specified by:
getFirstChildin interfaceNode- See Also:
Node
-
getLastChild
Description copied from interface:NodeThe last child of this node. If there is no such node, this returnsnull.- Specified by:
getLastChildin interfaceNode- See Also:
Node
-
getPreviousSibling
Description copied from interface:NodeThe node immediately preceding this node. If there is no such node, this returnsnull.- Specified by:
getPreviousSiblingin interfaceNode- See Also:
Node
-
getNextSibling
Description copied from interface:NodeThe node immediately following this node. If there is no such node, this returnsnull.- Specified by:
getNextSiblingin interfaceNode- See Also:
Node
-
getAttributes
Description copied from interface:NodeANamedNodeMapcontaining the attributes of this node (if it is anElement) ornullotherwise.- Specified by:
getAttributesin interfaceNode- See Also:
Node
-
hasAttribute
Method hasAttribute- Specified by:
hasAttributein interfaceElement- Parameters:
name-- Returns:
trueif an attribute with the given name is specified on this element or has a default value,falseotherwise.
-
hasAttributeNS
Method hasAttributeNS- Specified by:
hasAttributeNSin interfaceElement- Parameters:
namespaceURI-localName-- Returns:
trueif an attribute with the given local name and namespace URI is specified or has a default value on this element,falseotherwise.
-
getOwnerDocument
Description copied from interface:NodeTheDocumentobject associated with this node. This is also theDocumentobject used to create new nodes. When this node is aDocumentor aDocumentTypewhich is not used with anyDocumentyet, this isnull.- Specified by:
getOwnerDocumentin interfaceNode- See Also:
Node
-
insertBefore
Description copied from interface:NodeInserts the nodenewChildbefore the existing child noderefChild. IfrefChildisnull, insertnewChildat the end of the list of children.
IfnewChildis aDocumentFragmentobject, all of its children are inserted, in the same order, beforerefChild. If thenewChildis already in the tree, it is first removed.Note: Inserting a node before itself is implementation dependent.
- Specified by:
insertBeforein interfaceNode- Parameters:
newChild-refChild-- Returns:
- The node being inserted.
- Throws:
DOMException- See Also:
-- DTMNodeProxy is read-only
-
replaceChild
Description copied from interface:NodeReplaces the child nodeoldChildwithnewChildin the list of children, and returns theoldChildnode.
IfnewChildis aDocumentFragmentobject,oldChildis replaced by all of theDocumentFragmentchildren, which are inserted in the same order. If thenewChildis already in the tree, it is first removed.Note: Replacing a node with itself is implementation dependent.
- Specified by:
replaceChildin interfaceNode- Parameters:
newChild-oldChild-- Returns:
- The node replaced.
- Throws:
DOMException- See Also:
-- DTMNodeProxy is read-only
-
removeChild
Description copied from interface:NodeRemoves the child node indicated byoldChildfrom the list of children, and returns it.- Specified by:
removeChildin interfaceNode- Parameters:
oldChild-- Returns:
- The node removed.
- Throws:
DOMException- See Also:
-- DTMNodeProxy is read-only
-
appendChild
Description copied from interface:NodeAdds the nodenewChildto the end of the list of children of this node. If thenewChildis already in the tree, it is first removed.- Specified by:
appendChildin interfaceNode- Parameters:
newChild-- Returns:
- The node added.
- Throws:
DOMException- See Also:
-- DTMNodeProxy is read-only
-
hasChildNodes
public final boolean hasChildNodes()Description copied from interface:NodeReturns whether this node has any children.- Specified by:
hasChildNodesin interfaceNode- Returns:
- Returns
trueif this node has any children,falseotherwise. - See Also:
Node
-
cloneNode
Description copied from interface:NodeReturns a duplicate of this node, i.e., serves as a generic copy constructor for nodes. The duplicate node has no parent (parentNodeisnull) and no user data. User data associated to the imported node is not carried over. However, if anyUserDataHandlershas been specified along with the associated data these handlers will be called with the appropriate parameters before this method returns.
Cloning anElementcopies all attributes and their values, including those generated by the XML processor to represent defaulted attributes, but this method does not copy any children it contains unless it is a deep clone. This includes text contained in an theElementsince the text is contained in a childTextnode. Cloning anAttrdirectly, as opposed to be cloned as part of anElementcloning operation, returns a specified attribute (specifiedistrue). Cloning anAttralways clones its children, since they represent its value, no matter whether this is a deep clone or not. Cloning anEntityReferenceautomatically constructs its subtree if a correspondingEntityis available, no matter whether this is a deep clone or not. 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 anEntityReferenceclone are readonly . In addition, clones of unspecifiedAttrnodes are specified. And, cloningDocument,DocumentType,Entity, andNotationnodes is implementation dependent.- Specified by:
cloneNodein interfaceNode- Parameters:
deep-- Returns:
- The duplicate node.
- See Also:
-- DTMNodeProxy is read-only
-
getDoctype
Description copied from interface:DocumentThe Document Type Declaration (seeDocumentType) associated with this document. For XML documents without a document type declaration this returnsnull. For HTML documents, aDocumentTypeobject may be returned, independently of the presence or absence of document type declaration in the HTML document.
This provides direct access to theDocumentTypenode, child node of thisDocument. This node can be set at document creation time and later changed through the use of child nodes manipulation methods, such asNode.insertBefore, orNode.replaceChild. Note, however, that while some implementations may instantiate different types ofDocumentobjects supporting additional features than the "Core", such as "HTML" [DOM Level 2 HTML] , based on theDocumentTypespecified at creation time, changing it afterwards is very unlikely to result in a change of the features supported.- Specified by:
getDoctypein interfaceDocument- See Also:
Document
-
getImplementation
Description copied from interface:DocumentTheDOMImplementationobject that handles this document. A DOM application may use objects from multiple implementations.- Specified by:
getImplementationin interfaceDocument- See Also:
Document
-
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:
getDocumentElementin interfaceDocument- See Also:
Document
-
createElement
Description copied from interface:DocumentCreates an element of the type specified. Note that the instance returned implements theElementinterface, so attributes can be specified directly on the returned object.
In addition, if there are known attributes with default values,Attrnodes representing them are automatically created and attached to the element.
To create an element with a qualified name and namespace URI, use thecreateElementNSmethod.- Specified by:
createElementin interfaceDocument- Parameters:
tagName-- Returns:
- A new
Elementobject with thenodeNameattribute set totagName, andlocalName,prefix, andnamespaceURIset tonull. - Throws:
DOMException- See Also:
Document
-
createDocumentFragment
Description copied from interface:DocumentCreates an emptyDocumentFragmentobject.- Specified by:
createDocumentFragmentin interfaceDocument- Returns:
- A new
DocumentFragment. - See Also:
Document
-
createTextNode
Description copied from interface:DocumentCreates aTextnode given the specified string.- Specified by:
createTextNodein interfaceDocument- Parameters:
data-- Returns:
- The new
Textobject. - See Also:
Document
-
createComment
Description copied from interface:DocumentCreates aCommentnode given the specified string.- Specified by:
createCommentin interfaceDocument- Parameters:
data-- Returns:
- The new
Commentobject. - See Also:
Document
-
createCDATASection
Description copied from interface:DocumentCreates aCDATASectionnode whose value is the specified string.- Specified by:
createCDATASectionin interfaceDocument- Parameters:
data-- Returns:
- The new
CDATASectionobject. - Throws:
DOMException- See Also:
Document
-
createProcessingInstruction
public final ProcessingInstruction createProcessingInstruction(String target, String data) throws DOMExceptionDescription copied from interface:DocumentCreates aProcessingInstructionnode given the specified name and data strings.- Specified by:
createProcessingInstructionin interfaceDocument- Parameters:
target-data-- Returns:
- The new
ProcessingInstructionobject. - Throws:
DOMException- See Also:
Document
-
createAttribute
Description copied from interface:DocumentCreates anAttrof the given name. Note that theAttrinstance can then be set on anElementusing thesetAttributeNodemethod.
To create an attribute with a qualified name and namespace URI, use thecreateAttributeNSmethod.- Specified by:
createAttributein interfaceDocument- Parameters:
name-- Returns:
- A new
Attrobject with thenodeNameattribute set toname, andlocalName,prefix, andnamespaceURIset tonull. The value of the attribute is the empty string. - Throws:
DOMException- See Also:
Document
-
createEntityReference
Description copied from interface:DocumentCreates anEntityReferenceobject. In addition, if the referenced entity is known, the child list of theEntityReferencenode is made the same as that of the correspondingEntitynode.Note: If any descendant of the
Entitynode has an unbound namespace prefix, the corresponding descendant of the createdEntityReferencenode is also unbound; (itsnamespaceURIisnull). The DOM Level 2 and 3 do not support any mechanism to resolve namespace prefixes in this case.- Specified by:
createEntityReferencein interfaceDocument- Parameters:
name-- Returns:
- The new
EntityReferenceobject. - Throws:
DOMException- See Also:
Document
-
getElementsByTagName
Description copied from interface:DocumentReturns aNodeListof all theElementsin document order with a given tag name and are contained in the document.- Specified by:
getElementsByTagNamein interfaceDocument- Specified by:
getElementsByTagNamein interfaceElement- Parameters:
tagname-- Returns:
- A new
NodeListobject containing all the matchedElements. - See Also:
Document
-
importNode
Description copied from interface:DocumentImports a node from another document to this document, without altering or removing the source node from the original document; this method creates a new copy of the source node. The returned node has no parent; (parentNodeisnull).
For all nodes, importing a node creates a node object owned by the importing document, with attribute values identical to the source node'snodeNameandnodeType, plus the attributes related to namespaces (prefix,localName, andnamespaceURI). As in thecloneNodeoperation, the source node is not altered. User data associated to the imported node is not carried over. However, if anyUserDataHandlershas been specified along with the associated data these handlers will be called with the appropriate parameters before this method returns.
Additional information is copied as appropriate to thenodeType, 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
ownerElementattribute is set tonulland thespecifiedflag is set totrueon the generatedAttr. The descendants of the sourceAttrare recursively imported and the resulting nodes reassembled to form the corresponding subtree. Note that thedeepparameter has no effect onAttrnodes; they always carry their children with them when imported. - DOCUMENT_FRAGMENT_NODE
- If the
deepoption was set totrue, the descendants of the sourceDocumentFragmentare recursively imported and the resulting nodes reassembled under the importedDocumentFragmentto form the corresponding subtree. Otherwise, this simply generates an emptyDocumentFragment. - DOCUMENT_NODE
Documentnodes cannot be imported.- DOCUMENT_TYPE_NODE
DocumentTypenodes cannot be imported.- ELEMENT_NODE
- Specified attribute nodes of the source element are imported, and the generated
Attrnodes are attached to the generatedElement. Default attributes are not copied, though if the document being imported into defines default attributes for this element name, those are assigned. If theimportNodedeepparameter was set totrue, the descendants of the source element are recursively imported and the resulting nodes reassembled to form the corresponding subtree. - ENTITY_NODE
Entitynodes can be imported, however in the current release of the DOM theDocumentTypeis readonly. Ability to add these imported nodes to aDocumentTypewill be considered for addition to a future release of the DOM.On import, thepublicId,systemId, andnotationNameattributes are copied. If adeepimport is requested, the descendants of the the sourceEntityare recursively imported and the resulting nodes reassembled to form the corresponding subtree.- ENTITY_REFERENCE_NODE
- Only the
EntityReferenceitself is copied, even if adeepimport 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
-
Notationnodes can be imported, however in the current release of the DOM theDocumentTypeis readonly. Ability to add these imported nodes to aDocumentTypewill be considered for addition to a future release of the DOM.On import, thepublicIdandsystemIdattributes are copied. Note that thedeepparameter has no effect on this type of nodes since they cannot have any children. - PROCESSING_INSTRUCTION_NODE
- The imported node copies its
targetanddatavalues from those of the source node.Note that thedeepparameter has no effect on this type of nodes since they cannot have any children. - TEXT_NODE, CDATA_SECTION_NODE, COMMENT_NODE
- These three types of nodes inheriting
from
CharacterDatacopy theirdataandlengthattributes from those of the source node.Note that thedeepparameter has no effect on these types of nodes since they cannot have any children.
- Specified by:
importNodein interfaceDocument- 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(String namespaceURI, String qualifiedName) throws DOMExceptionDescription copied from interface:DocumentCreates an element of the given qualified name and namespace URI.
Per [XML Namespaces] , applications must use the valuenullas the namespaceURI parameter for methods if they wish to have no namespace.- Specified by:
createElementNSin interfaceDocument- Parameters:
namespaceURI-qualifiedName-- Returns:
- A new
Elementobject with the following attributes:Attribute Value Node.nodeNamequalifiedNameNode.namespaceURInamespaceURINode.prefixprefix, extracted from qualifiedName, ornullif there is no prefixNode.localNamelocal name, extracted from qualifiedNameElement.tagNamequalifiedName - Throws:
DOMException- See Also:
as of DOM Level 2
-
createAttributeNS
Description copied from interface:DocumentCreates an attribute of the given qualified name and namespace URI.
Per [XML Namespaces] , applications must use the valuenullas thenamespaceURIparameter for methods if they wish to have no namespace.- Specified by:
createAttributeNSin interfaceDocument- Parameters:
namespaceURI-qualifiedName-- Returns:
- A new
Attrobject with the following attributes:Attribute Value Node.nodeNamequalifiedName Node.namespaceURInamespaceURINode.prefixprefix, extracted from qualifiedName, ornullif there is no prefixNode.localNamelocal name, extracted from qualifiedNameAttr.namequalifiedNameNode.nodeValuethe empty string - Throws:
DOMException- See Also:
as of DOM Level 2
-
getElementsByTagNameNS
Description copied from interface:DocumentReturns aNodeListof all theElementswith a given local name and namespace URI in document order.- Specified by:
getElementsByTagNameNSin interfaceDocument- Specified by:
getElementsByTagNameNSin interfaceElement- Parameters:
namespaceURI-localName-- Returns:
- A new
NodeListobject containing all the matchedElements. - See Also:
as of DOM Level 2
-
getElementById
Description copied from interface:DocumentReturns theElementthat has an ID attribute with the given value. If no such element exists, this returnsnull. If more than one element has an ID attribute with that value, what is returned is undefined.
The DOM implementation is expected to use the attributeAttr.isIdto determine if an attribute is of type ID.Note: Attributes with the name "ID" or "id" are not of type ID unless so defined.
- Specified by:
getElementByIdin interfaceDocument- Parameters:
elementId-- Returns:
- The matching element or
nullif there is none. - See Also:
as of DOM Level 2
-
splitText
Description copied from interface:TextBreaks this node into two nodes at the specifiedoffset, keeping both in the tree as siblings. After being split, this node will contain all the content up to theoffsetpoint. A new node of the same type, which contains all the content at and after theoffsetpoint, is returned. If the original node had a parent node, the new node is inserted as the next sibling of the original node. When theoffsetis equal to the length of this node, the new node has no data.- Specified by:
splitTextin interfaceText- Parameters:
offset-- Returns:
- The new node, of the same type as this node.
- Throws:
DOMException- See Also:
Text
-
getData
Description copied from interface:CharacterDataThe character data of the node that implements this interface. The DOM implementation may not put arbitrary limits on the amount of data that may be stored in aCharacterDatanode. However, implementation limits may mean that the entirety of a node's data may not fit into a singleDOMString. In such cases, the user may callsubstringDatato retrieve the data in appropriately sized pieces.- Specified by:
getDatain interfaceCharacterData- Specified by:
getDatain interfaceProcessingInstruction- Throws:
DOMException- See Also:
CharacterData
-
setData
Description copied from interface:CharacterDataThe character data of the node that implements this interface. The DOM implementation may not put arbitrary limits on the amount of data that may be stored in aCharacterDatanode. However, implementation limits may mean that the entirety of a node's data may not fit into a singleDOMString. In such cases, the user may callsubstringDatato retrieve the data in appropriately sized pieces.- Specified by:
setDatain interfaceCharacterData- Specified by:
setDatain interfaceProcessingInstruction- Parameters:
data-- Throws:
DOMException- See Also:
CharacterData
-
getLength
public final int getLength()Description copied from interface:CharacterDataThe number of 16-bit units that are available throughdataand thesubstringDatamethod below. This may have the value zero, i.e.,CharacterDatanodes may be empty.- Specified by:
getLengthin interfaceCharacterData- See Also:
CharacterData
-
substringData
Description copied from interface:CharacterDataExtracts a range of data from the node.- Specified by:
substringDatain interfaceCharacterData- Parameters:
offset-count-- Returns:
- The specified substring. If the sum of
offsetandcountexceeds thelength, then all 16-bit units to the end of the data are returned. - Throws:
DOMException- See Also:
CharacterData
-
appendData
Description copied from interface:CharacterDataAppend the string to the end of the character data of the node. Upon success,dataprovides access to the concatenation ofdataand theDOMStringspecified.- Specified by:
appendDatain interfaceCharacterData- Parameters:
arg-- Throws:
DOMException- See Also:
CharacterData
-
insertData
Description copied from interface:CharacterDataInsert a string at the specified 16-bit unit offset.- Specified by:
insertDatain interfaceCharacterData- Parameters:
offset-arg-- Throws:
DOMException- See Also:
CharacterData
-
deleteData
Description copied from interface:CharacterDataRemove a range of 16-bit units from the node. Upon success,dataandlengthreflect the change.- Specified by:
deleteDatain interfaceCharacterData- Parameters:
offset-count-- Throws:
DOMException- See Also:
CharacterData
-
replaceData
Description copied from interface:CharacterDataReplace the characters starting at the specified 16-bit unit offset with the specified string.- Specified by:
replaceDatain interfaceCharacterData- Parameters:
offset-count-arg-- Throws:
DOMException- See Also:
CharacterData
-
getTagName
Description copied from interface:ElementThe name of the element. IfNode.localNameis different fromnull, this attribute is a qualified name. For example, in:<elementExample id="demo"> ... </elementExample> ,
tagNamehas the value"elementExample". Note that this is case-preserving in XML, as are all of the operations of the DOM. The HTML DOM returns thetagNameof an HTML element in the canonical uppercase form, regardless of the case in the source HTML document.- Specified by:
getTagNamein interfaceElement- See Also:
Element
-
getAttribute
Description copied from interface:ElementRetrieves an attribute value by name.- Specified by:
getAttributein interfaceElement- Parameters:
name-- Returns:
- The
Attrvalue as a string, or the empty string if that attribute does not have a specified or default value. - See Also:
Element
-
setAttribute
Description copied from interface:ElementAdds 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 anAttrnode plus anyTextandEntityReferencenodes, build the appropriate subtree, and usesetAttributeNodeto assign it as the value of an attribute.
To set an attribute with a qualified name and namespace URI, use thesetAttributeNSmethod.- Specified by:
setAttributein interfaceElement- Parameters:
name-value-- Throws:
DOMException- See Also:
Element
-
removeAttribute
Description copied from interface:ElementRemoves an attribute by name. If a default value for the removed attribute is defined in the DTD, a new attribute immediately appears with the default value as well as the corresponding namespace URI, local name, and prefix when applicable. The implementation may handle default values from other schemas similarly but applications should useDocument.normalizeDocument()to guarantee this information is up-to-date.
If no attribute with this name is found, this method has no effect.
To remove an attribute by local name and namespace URI, use theremoveAttributeNSmethod.- Specified by:
removeAttributein interfaceElement- Parameters:
name-- Throws:
DOMException- See Also:
Element
-
getAttributeNode
Description copied from interface:ElementRetrieves an attribute node by name.
To retrieve an attribute node by qualified name and namespace URI, use thegetAttributeNodeNSmethod.- Specified by:
getAttributeNodein interfaceElement- Parameters:
name-- Returns:
- The
Attrnode with the specified name (nodeName) ornullif there is no such attribute. - See Also:
Element
-
setAttributeNode
Description copied from interface:ElementAdds a new attribute node. If an attribute with that name (nodeName) is already present in the element, it is replaced by the new one. Replacing an attribute node by itself has no effect.
To add a new attribute node with a qualified name and namespace URI, use thesetAttributeNodeNSmethod.- Specified by:
setAttributeNodein interfaceElement- Parameters:
newAttr-- Returns:
- If the
newAttrattribute replaces an existing attribute, the replacedAttrnode is returned, otherwisenullis returned. - Throws:
DOMException- See Also:
Element
-
removeAttributeNode
Description copied from interface:ElementRemoves the specified attribute node. If a default value for the removedAttrnode is defined in the DTD, a new node immediately appears with the default value as well as the corresponding namespace URI, local name, and prefix when applicable. The implementation may handle default values from other schemas similarly but applications should useDocument.normalizeDocument()to guarantee this information is up-to-date.- Specified by:
removeAttributeNodein interfaceElement- Parameters:
oldAttr-- Returns:
- The
Attrnode that was removed. - Throws:
DOMException- See Also:
Element
-
hasAttributes
public boolean hasAttributes()Introduced in DOM Level 2.- Specified by:
hasAttributesin interfaceNode- Returns:
- Returns
trueif this node has any attributes,falseotherwise.
-
normalize
public final void normalize()Description copied from interface:NodePuts allTextnodes in the full depth of the sub-tree underneath thisNode, including attribute nodes, into a "normal" form where only structure (e.g., elements, comments, processing instructions, CDATA sections, and entity references) separatesTextnodes, i.e., there are neither adjacentTextnodes nor emptyTextnodes. 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 [XPointer] lookups) that depend on a particular document tree structure are to be used. If the parameter "normalize-characters" of theDOMConfigurationobject attached to theNode.ownerDocumentistrue, this method will also fully normalize the characters of theTextnodes.Note: In cases where the document contains
CDATASections, the normalize operation alone may not be sufficient, since XPointers do not differentiate betweenTextnodes andCDATASectionnodes. -
getAttributeNS
Description copied from interface:ElementRetrieves an attribute value by local name and namespace URI.
Per [XML Namespaces] , applications must use the valuenullas thenamespaceURIparameter for methods if they wish to have no namespace.- Specified by:
getAttributeNSin interfaceElement- Parameters:
namespaceURI-localName-- Returns:
- The
Attrvalue 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(String namespaceURI, String qualifiedName, String value) throws DOMExceptionDescription copied from interface:ElementAdds 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 thequalifiedName, and its value is changed to be thevalueparameter. 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 anAttrnode plus anyTextandEntityReferencenodes, build the appropriate subtree, and usesetAttributeNodeNSorsetAttributeNodeto assign it as the value of an attribute.
Per [XML Namespaces] , applications must use the valuenullas thenamespaceURIparameter for methods if they wish to have no namespace.- Specified by:
setAttributeNSin interfaceElement- Parameters:
namespaceURI-qualifiedName-value-- Throws:
DOMException- See Also:
Element
-
removeAttributeNS
Description copied from interface:ElementRemoves an attribute by local name and namespace URI. If a default value for the removed attribute is defined in the DTD, a new attribute immediately appears with the default value as well as the corresponding namespace URI, local name, and prefix when applicable. The implementation may handle default values from other schemas similarly but applications should useDocument.normalizeDocument()to guarantee this information is up-to-date.
If no attribute with this local name and namespace URI is found, this method has no effect.
Per [XML Namespaces] , applications must use the valuenullas thenamespaceURIparameter for methods if they wish to have no namespace.- Specified by:
removeAttributeNSin interfaceElement- Parameters:
namespaceURI-localName-- Throws:
DOMException- See Also:
Element
-
getAttributeNodeNS
Description copied from interface:ElementRetrieves anAttrnode by local name and namespace URI.
Per [XML Namespaces] , applications must use the valuenullas thenamespaceURIparameter for methods if they wish to have no namespace.- Specified by:
getAttributeNodeNSin interfaceElement- Parameters:
namespaceURI-localName-- Returns:
- The
Attrnode with the specified attribute local name and namespace URI ornullif there is no such attribute. - See Also:
Element
-
setAttributeNodeNS
Description copied from interface:ElementAdds 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. Replacing an attribute node by itself has no effect.
Per [XML Namespaces] , applications must use the valuenullas thenamespaceURIparameter for methods if they wish to have no namespace.- Specified by:
setAttributeNodeNSin interfaceElement- Parameters:
newAttr-- Returns:
- If the
newAttrattribute replaces an existing attribute with the same local name and namespace URI, the replacedAttrnode is returned, otherwisenullis returned. - Throws:
DOMException- See Also:
Element
-
getName
Description copied from interface:AttrReturns the name of this attribute. IfNode.localNameis different fromnull, this attribute is a qualified name. -
getSpecified
public final boolean getSpecified()Description copied from interface:AttrTrueif this attribute was explicitly given a value in the instance document,falseotherwise. If the application changed the value of this attribute node (even if it ends up having the same value as the default value) then it is set totrue. The implementation may handle attributes with default values from other schemas similarly but applications should useDocument.normalizeDocument()to guarantee this information is up-to-date.- Specified by:
getSpecifiedin interfaceAttr- See Also:
Attr
-
getValue
Description copied from interface:AttrOn retrieval, the value of the attribute is returned as a string. Character and general entity references are replaced with their values. See also the methodgetAttributeon theElementinterface.
On setting, this creates aTextnode 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 methodElement.setAttribute().
Some specialized implementations, such as some [SVG 1.1] implementations, may do normalization automatically, even after mutation; in such case, the value on retrieval may differ from the value on setting. -
setValue
Description copied from interface:AttrOn retrieval, the value of the attribute is returned as a string. Character and general entity references are replaced with their values. See also the methodgetAttributeon theElementinterface.
On setting, this creates aTextnode 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 methodElement.setAttribute().
Some specialized implementations, such as some [SVG 1.1] implementations, may do normalization automatically, even after mutation; in such case, the value on retrieval may differ from the value on setting. -
getOwnerElement
Get the owner element of an attribute.- Specified by:
getOwnerElementin interfaceAttr- See Also:
as of DOM Level 2
-
adoptNode
NEEDSDOC Method adoptNode NEEDSDOC @param source- Specified by:
adoptNodein interfaceDocument- Parameters:
source- The node to move into this document.- Returns:
- The adopted node, or
nullif this operation fails, such as when the source node comes from a different implementation. - Throws:
DOMException
-
getInputEncoding
Based on the Document Object Model (DOM) Level 3 Core Specification of 07 April 2004..
An attribute specifying, as part of the XML declaration, the encoding of this document. This is
nullwhen unspecified.- Specified by:
getInputEncodingin interfaceDocument- Since:
- DOM Level 3
-
getStrictErrorChecking
public boolean getStrictErrorChecking()Based on the Document Object Model (DOM) Level 3 Core Specification of 07 April 2004..
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 anyDOMException. In case of error, the behavior is undefined. This attribute istrueby defaults.- Specified by:
getStrictErrorCheckingin interfaceDocument- Since:
- DOM Level 3
-
setStrictErrorChecking
public void setStrictErrorChecking(boolean strictErrorChecking)Based on the Document Object Model (DOM) Level 3 Core Specification of 07 April 2004..
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 anyDOMException. In case of error, the behavior is undefined. This attribute istrueby defaults.- Specified by:
setStrictErrorCheckingin interfaceDocument- Since:
- DOM Level 3 NEEDSDOC @param strictErrorChecking
-
setUserData
Description copied from interface:NodeAssociate an object to a key on this node. The object can later be retrieved from this node by callinggetUserDatawith the same key.- Specified by:
setUserDatain interfaceNode- Parameters:
key- The key to associate the object to.data- The object to associate to the given key, ornullto remove any existing association to that key.handler- The handler to associate to that key, ornull.- Returns:
- Returns the
DOMUserDatapreviously associated to the given key on this node, ornullif there was none.
-
getUserData
Retrieves the object associated to a key on a this node. The object must first have been set to this node by callingsetUserDatawith the same key.- Specified by:
getUserDatain interfaceNode- Parameters:
key- The key the object is associated to.- Returns:
- Returns the
DOMObjectassociated to the given key on this node, ornullif there was none. - Since:
- DOM Level 3
-
getFeature
This method returns a specialized object which implements the specialized APIs of the specified feature and version. The specialized object may also be obtained by using binding-specific casting methods but is not necessarily expected to, as discussed in Mixed DOM implementations.- Specified by:
getFeaturein interfaceNode- Parameters:
feature- The name of the feature requested (case-insensitive).version- This is the version number of the feature to test. If the version isnullor the empty string, supporting any version of the feature will cause the method to return an object that supports at least one version of the feature.- Returns:
- Returns an object which implements the specialized APIs of
the specified feature and version, if any, or
nullif there is no object which implements interfaces associated with that feature. If theDOMObjectreturned by this method implements theNodeinterface, it must delegate to the primary coreNodeand not return results inconsistent with the primary coreNodesuch as attributes, childNodes, etc. - Since:
- DOM Level 3
-
isEqualNode
Tests whether two nodes are equal.
This method tests for equality of nodes, not sameness (i.e., whether the two nodes are references to the same object) which can be tested withNode.isSameNode. All nodes that are the same will also be equal, though the reverse may not be true.
Two nodes are equal if and only if the following conditions are satisfied: The two nodes are of the same type.The following string attributes are equal:nodeName,localName,namespaceURI,prefix,nodeValue,baseURI. This is: they are bothnull, or they have the same length and are character for character identical. TheattributesNamedNodeMapsare equal. This is: they are bothnull, or they have the same length and for each node that exists in one map there is a node that exists in the other map and is equal, although not necessarily at the same index.ThechildNodesNodeListsare equal. This is: they are bothnull, or they have the same length and contain equal nodes at the same index. This is true forAttrnodes as for any other type of node. Note that normalization can affect equality; to avoid this, nodes should be normalized before being compared.
For twoDocumentTypenodes to be equal, the following conditions must also be satisfied: The following string attributes are equal:publicId,systemId,internalSubset.TheentitiesNamedNodeMapsare equal.ThenotationsNamedNodeMapsare equal.
On the other hand, the following do not affect equality: theownerDocumentattribute, thespecifiedattribute forAttrnodes, theisWhitespaceInElementContentattribute forTextnodes, as well as any user data or event listeners registered on the nodes.- Specified by:
isEqualNodein interfaceNode- Parameters:
arg- The node to compare equality with.deep- Iftrue, recursively compare the subtrees; iffalse, compare only the nodes themselves (and its attributes, if it is anElement).- Returns:
- If the nodes, and possibly subtrees are equal,
trueotherwisefalse. - Since:
- DOM Level 3
-
lookupNamespaceURI
DOM Level 3: Look up the namespace URI associated to the given prefix, starting from this node. Use lookupNamespaceURI(null) to lookup the default namespace- Specified by:
lookupNamespaceURIin interfaceNode- Parameters:
namespaceURI-- Returns:
- th URI for the namespace
- Since:
- DOM Level 3
-
isDefaultNamespace
DOM Level 3: This method checks if the specifiednamespaceURIis the default namespace or not.- Specified by:
isDefaultNamespacein interfaceNode- Parameters:
namespaceURI- The namespace URI to look for.- Returns:
trueif the specifiednamespaceURIis the default namespace,falseotherwise.- Since:
- DOM Level 3
-
lookupPrefix
DOM Level 3: Look up the prefix associated to the given namespace URI, starting from this node.- Specified by:
lookupPrefixin interfaceNode- Parameters:
namespaceURI-- Returns:
- the prefix for the namespace
-
isSameNode
Returns whether this node is the same node as the given one.
This method provides a way to determine whether twoNodereferences returned by the implementation reference the same object. When twoNodereferences are references to the same object, even if through a proxy, the references may be used completely interchangably, such that all attributes have the same values and calling the same DOM method on either reference always has exactly the same effect.- Specified by:
isSameNodein interfaceNode- Parameters:
other- The node to test against.- Returns:
- Returns
trueif the nodes are the same,falseotherwise. - Since:
- DOM Level 3
-
setTextContent
This attribute returns the text content of this node and its descendants. When it is defined to be null, setting it has no effect. When set, any possible children this node may have are removed and replaced by a singleTextnode containing the string this attribute is set to. On getting, no serialization is performed, the returned string does not contain any markup. No whitespace normalization is performed, the returned string does not contain the element content whitespaces . Similarly, on setting, no parsing is performed either, the input string is taken as pure textual content.
The string returned is made of the text content of this node depending on its type, as defined below:Node type Content ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, DOCUMENT_FRAGMENT_NODE concatenation of the textContentattribute value of every child node, excluding COMMENT_NODE and PROCESSING_INSTRUCTION_NODE nodesATTRIBUTE_NODE, TEXT_NODE, CDATA_SECTION_NODE, COMMENT_NODE, PROCESSING_INSTRUCTION_NODE nodeValueDOCUMENT_NODE, DOCUMENT_TYPE_NODE, NOTATION_NODE null - Specified by:
setTextContentin interfaceNode- Throws:
DOMException- NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.DOMException- DOMSTRING_SIZE_ERR: Raised when it would return more characters than fit in aDOMStringvariable on the implementation platform.- Since:
- DOM Level 3
-
getTextContent
This attribute returns the text content of this node and its descendants. When it is defined to be null, setting it has no effect. When set, any possible children this node may have are removed and replaced by a singleTextnode containing the string this attribute is set to. On getting, no serialization is performed, the returned string does not contain any markup. No whitespace normalization is performed, the returned string does not contain the element content whitespaces . Similarly, on setting, no parsing is performed either, the input string is taken as pure textual content.
The string returned is made of the text content of this node depending on its type, as defined below:Node type Content ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, DOCUMENT_FRAGMENT_NODE concatenation of the textContentattribute value of every child node, excluding COMMENT_NODE and PROCESSING_INSTRUCTION_NODE nodesATTRIBUTE_NODE, TEXT_NODE, CDATA_SECTION_NODE, COMMENT_NODE, PROCESSING_INSTRUCTION_NODE nodeValueDOCUMENT_NODE, DOCUMENT_TYPE_NODE, NOTATION_NODE null - Specified by:
getTextContentin interfaceNode- Throws:
DOMException- NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.DOMException- DOMSTRING_SIZE_ERR: Raised when it would return more characters than fit in aDOMStringvariable on the implementation platform.- Since:
- DOM Level 3
-
compareDocumentPosition
Compares a node with this node with regard to their position in the document.- Specified by:
compareDocumentPositionin interfaceNode- Parameters:
other- The node to compare against this node.- Returns:
- Returns how the given node is positioned relatively to this node.
- Throws:
DOMException- NOT_SUPPORTED_ERR: when the compared nodes are from different DOM implementations that do not coordinate to return consistent implementation-specific results.- Since:
- DOM Level 3
-
getBaseURI
The absolute base URI of this node ornullif undefined. This value is computed according to . However, when theDocumentsupports the feature "HTML" , the base URI is computed using first the value of the href attribute of the HTML BASE element if any, and the value of thedocumentURIattribute from theDocumentinterface otherwise.
When the node is anElement, aDocumentor a aProcessingInstruction, this attribute represents the properties [base URI] defined in . When the node is aNotation, anEntity, or anEntityReference, this attribute represents the properties [declaration base URI] in the . How will this be affected by resolution of relative namespace URIs issue?It's not.Should this only be on Document, Element, ProcessingInstruction, Entity, and Notation nodes, according to the infoset? If not, what is it equal to on other nodes? Null? An empty string? I think it should be the parent's.No.Should this be read-only and computed or and actual read-write attribute?Read-only and computed (F2F 19 Jun 2000 and teleconference 30 May 2001).If the base HTML element is not yet attached to a document, does the insert change the Document.baseURI? Yes. (F2F 26 Sep 2001)- Specified by:
getBaseURIin interfaceNode- Since:
- DOM Level 3
-
renameNode
DOM Level 3 Renaming node- Specified by:
renameNodein interfaceDocument- Parameters:
n- The node to rename.namespaceURI- The new namespace URI.name- The new qualified name.- Returns:
- The renamed node. This is either the specified node or the new node that was created to replace the specified node.
- Throws:
DOMException- NOT_SUPPORTED_ERR: Raised when the type of the specified node is neitherELEMENT_NODEnorATTRIBUTE_NODE, or if the implementation does not support the renaming of the document element.
INVALID_CHARACTER_ERR: Raised if the new qualified name is not an XML name according to the XML version in use specified in theDocument.xmlVersionattribute.
WRONG_DOCUMENT_ERR: Raised when the specified node was created from a different document than this document.
NAMESPACE_ERR: Raised if thequalifiedNameis a malformed qualified name, if thequalifiedNamehas a prefix and thenamespaceURIisnull, or if thequalifiedNamehas a prefix that is "xml" and thenamespaceURIis different from " http://www.w3.org/XML/1998/namespace" [XML Namespaces] . Also raised, when the node being renamed is an attribute, if thequalifiedName, or its prefix, is "xmlns" and thenamespaceURIis different from "http://www.w3.org/2000/xmlns/".
-
normalizeDocument
public void normalizeDocument()DOM Level 3 Normalize document.- Specified by:
normalizeDocumentin interfaceDocument
-
getDomConfig
The configuration used whenDocument.normalizeDocumentis invoked.- Specified by:
getDomConfigin interfaceDocument- Since:
- DOM Level 3
-
setDocumentURI
DOM Level 3- Specified by:
setDocumentURIin interfaceDocument
-
getDocumentURI
DOM Level 3 The location of the document ornullif undefined.
Beware that when theDocumentsupports the feature "HTML" , the href attribute of the HTML BASE element takes precedence over this attribute.- Specified by:
getDocumentURIin interfaceDocument- Since:
- DOM Level 3
-
getActualEncoding
DOM Level 3 An attribute specifying the actual encoding of this document. This isnullotherwise.
This attribute represents the property [character encoding scheme] defined in .- Since:
- DOM Level 3
-
setActualEncoding
DOM Level 3 An attribute specifying the actual encoding of this document. This isnullotherwise.
This attribute represents the property [character encoding scheme] defined in .- Since:
- DOM Level 3
-
replaceWholeText
DOM Level 3- Specified by:
replaceWholeTextin interfaceText- Parameters:
content- The content of the replacingTextnode.- Returns:
- The
Textnode created with the specified content. - Throws:
DOMException- NO_MODIFICATION_ALLOWED_ERR: Raised if one of theTextnodes being replaced is readonly.
-
getWholeText
DOM Level 3 Returns all text ofTextnodes logically-adjacent text nodes to this node, concatenated in document order.- Specified by:
getWholeTextin interfaceText- Since:
- DOM Level 3
-
isElementContentWhitespace
public boolean isElementContentWhitespace()DOM Level 3 Returns whether this text node contains whitespace in element content, often abusively called "ignorable whitespace".- Specified by:
isElementContentWhitespacein interfaceText
-
setIdAttribute
public void setIdAttribute(boolean id)NON-DOM: set the type of this attribute to be ID type.- Parameters:
id-
-
setIdAttribute
DOM Level 3: register the given attribute node as an ID attribute- Specified by:
setIdAttributein interfaceElement- Parameters:
name- The name of the attribute.makeId- Whether the attribute is a of type ID.
-
setIdAttributeNode
DOM Level 3: register the given attribute node as an ID attribute- Specified by:
setIdAttributeNodein interfaceElement- Parameters:
at- The attribute node.makeId- Whether the attribute is a of type ID.
-
setIdAttributeNS
DOM Level 3: register the given attribute node as an ID attribute- Specified by:
setIdAttributeNSin interfaceElement- Parameters:
namespaceURI- The namespace URI of the attribute.localName- The local name of the attribute.makeId- Whether the attribute is a of type ID.
-
getSchemaTypeInfo
Description copied from interface:ElementThe type information associated with this element.- Specified by:
getSchemaTypeInfoin interfaceAttr- Specified by:
getSchemaTypeInfoin interfaceElement
-
isId
public boolean isId()Description copied from interface:AttrReturns whether this attribute is known to be of type ID (i.e. to contain an identifier for its owner element) or not. When it is and its value is unique, theownerElementof this attribute can be retrieved using the methodDocument.getElementById. The implementation could use several ways to determine if an attribute node is known to contain an identifier:- If validation
occurred using an XML Schema [XML Schema Part 1]
while loading the document or while invoking
Document.normalizeDocument(), the post-schema-validation infoset contributions (PSVI contributions) values are used to determine if this attribute is a schema-determined ID attribute using the schema-determined ID definition in [XPointer] . - If validation occurred using a DTD while loading the document or
while invoking
Document.normalizeDocument(), the infoset [type definition] value is used to determine if this attribute is a DTD-determined ID attribute using the DTD-determined ID definition in [XPointer] . - from the use of the methods
Element.setIdAttribute(),Element.setIdAttributeNS(), orElement.setIdAttributeNode(), i.e. it is an user-determined ID attribute;Note: XPointer framework (see section 3.2 in [XPointer] ) consider the DOM user-determined ID attribute as being part of the XPointer externally-determined ID definition.
- using mechanisms that are outside the scope of this specification, it is then an externally-determined ID attribute. This includes using schema languages different from XML schema and DTD.
If validation occurred while invokingDocument.normalizeDocument(), all user-determined ID attributes are reset and all attribute nodes ID information are then reevaluated in accordance to the schema used. As a consequence, if theAttr.schemaTypeInfoattribute contains an ID type,isIdwill always return true. - If validation
occurred using an XML Schema [XML Schema Part 1]
while loading the document or while invoking
-
getXmlEncoding
Description copied from interface:DocumentAn attribute specifying, as part of the XML declaration, the encoding of this document. This isnullwhen unspecified or when it is not known, such as when theDocumentwas created in memory.- Specified by:
getXmlEncodingin interfaceDocument
-
setXmlEncoding
-
getXmlStandalone
public boolean getXmlStandalone()Description copied from interface:DocumentAn attribute specifying, as part of the XML declaration, whether this document is standalone. This isfalsewhen unspecified.Note: No verification is done on the value when setting this attribute. Applications should use
Document.normalizeDocument()with the "validate" parameter to verify if the value matches the validity constraint for standalone document declaration as defined in [XML 1.0].- Specified by:
getXmlStandalonein interfaceDocument
-
setXmlStandalone
Description copied from interface:DocumentAn attribute specifying, as part of the XML declaration, whether this document is standalone. This isfalsewhen unspecified.Note: No verification is done on the value when setting this attribute. Applications should use
Document.normalizeDocument()with the "validate" parameter to verify if the value matches the validity constraint for standalone document declaration as defined in [XML 1.0].- Specified by:
setXmlStandalonein interfaceDocument- Throws:
DOMException- NOT_SUPPORTED_ERR: Raised if this document does not support the "XML" feature.
-
getXmlVersion
Description copied from interface:DocumentAn attribute specifying, as part of the XML declaration, the version number of this document. If there is no declaration and if this document supports the "XML" feature, the value is"1.0". If this document does not support the "XML" feature, the value is alwaysnull. Changing this attribute will affect methods that check for invalid characters in XML names. Application should invokeDocument.normalizeDocument()in order to check for invalid characters in theNodes that are already part of thisDocument.
DOM applications may use theDOMImplementation.hasFeature(feature, version)method with parameter values "XMLVersion" and "1.0" (respectively) to determine if an implementation supports [XML 1.0]. DOM applications may use the same method with parameter values "XMLVersion" and "1.1" (respectively) to determine if an implementation supports [XML 1.1]. In both cases, in order to support XML, an implementation must also support the "XML" feature defined in this specification.Documentobjects supporting a version of the "XMLVersion" feature must not raise aNOT_SUPPORTED_ERRexception for the same version number when usingDocument.xmlVersion.- Specified by:
getXmlVersionin interfaceDocument
-
setXmlVersion
Description copied from interface:DocumentAn attribute specifying, as part of the XML declaration, the version number of this document. If there is no declaration and if this document supports the "XML" feature, the value is"1.0". If this document does not support the "XML" feature, the value is alwaysnull. Changing this attribute will affect methods that check for invalid characters in XML names. Application should invokeDocument.normalizeDocument()in order to check for invalid characters in theNodes that are already part of thisDocument.
DOM applications may use theDOMImplementation.hasFeature(feature, version)method with parameter values "XMLVersion" and "1.0" (respectively) to determine if an implementation supports [XML 1.0]. DOM applications may use the same method with parameter values "XMLVersion" and "1.1" (respectively) to determine if an implementation supports [XML 1.1]. In both cases, in order to support XML, an implementation must also support the "XML" feature defined in this specification.Documentobjects supporting a version of the "XMLVersion" feature must not raise aNOT_SUPPORTED_ERRexception for the same version number when usingDocument.xmlVersion.- Specified by:
setXmlVersionin interfaceDocument- Throws:
DOMException- NOT_SUPPORTED_ERR: Raised if the version is set to a value that is not supported by thisDocumentor if this document does not support the "XML" feature.
-