public class CoreDocumentImpl extends ParentNode implements org.w3c.dom.Document
Since elements, text nodes, comments, processing instructions, etc. cannot exist outside the context of a Document, the Document interface also contains the factory methods needed to create these objects. The Node objects created have a ownerDocument attribute which associates them with the Document within whose context they were created.
The CoreDocumentImpl class only implements the DOM Core. Additional modules are supported by the more complete DocumentImpl subclass.
Note: When any node in the document is serialized, the entire document is serialized along with it.
| Modifier and Type | Field and Description |
|---|---|
protected java.lang.String |
actualEncoding
Experimental DOM Level 3 feature: Document actualEncoding
|
protected boolean |
allowGrammarAccess
Allow grammar access.
|
protected int |
changes
Number of alterations made to this document since its creation.
|
protected ElementImpl |
docElement
Document element.
|
protected DocumentTypeImpl |
docType
Document type.
|
protected java.lang.String |
encoding
Experimental DOM Level 3 feature: Document encoding
|
protected boolean |
errorChecking
Bypass error checking.
|
protected java.lang.String |
fDocumentURI
Experimental DOM Level 3 feature: documentURI
|
protected java.util.Hashtable |
identifiers
Identifiers.
|
protected boolean |
standalone
Experimental DOM Level 3 feature: Document standalone
|
protected java.util.Map |
userData
Table for user data attached to this document nodes.
|
protected java.lang.String |
version
Experimental DOM Level 3 feature: Document version
|
protected boolean |
xmlVersionChanged |
firstChild, fNodeListCache, ownerDocumentnextSibling, previousSiblingDOCUMENT_POSITION_CONTAINS, DOCUMENT_POSITION_DISCONNECTED, DOCUMENT_POSITION_FOLLOWING, DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, DOCUMENT_POSITION_IS_CONTAINED, DOCUMENT_POSITION_PRECEDING, ELEMENT_DEFINITION_NODE, FIRSTCHILD, flags, HASSTRING, ID, IGNORABLEWS, NORMALIZED, OWNED, ownerNode, READONLY, SPECIFIED, SYNCCHILDREN, SYNCDATA, TREE_POSITION_ANCESTOR, TREE_POSITION_DESCENDANT, TREE_POSITION_DISCONNECTED, TREE_POSITION_EQUIVALENT, TREE_POSITION_FOLLOWING, TREE_POSITION_PRECEDING, TREE_POSITION_SAME_NODEATTRIBUTE_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 and Description |
|---|
CoreDocumentImpl()
NON-DOM: Actually creating a Document is outside the DOM's spec,
since it has to operate in terms of a particular implementation.
|
CoreDocumentImpl(boolean grammarAccess)
Constructor.
|
CoreDocumentImpl(org.w3c.dom.DocumentType doctype)
For DOM2 support.
|
CoreDocumentImpl(org.w3c.dom.DocumentType doctype,
boolean grammarAccess)
For DOM2 support.
|
| Modifier and Type | Method and Description |
|---|---|
void |
abort()
DOM Level 3 WD - Experimental.
|
protected void |
addEventListener(NodeImpl node,
java.lang.String type,
org.w3c.dom.events.EventListener listener,
boolean useCapture) |
org.w3c.dom.Node |
adoptNode(org.w3c.dom.Node source)
DOM Level 3 WD - Experimental
Change the node's ownerDocument, and its subtree, to this Document
|
protected void |
callUserDataHandlers(org.w3c.dom.Node n,
org.w3c.dom.Node c,
short operation)
Call user data handlers when a node is deleted (finalized)
|
protected boolean |
canRenameElements(java.lang.String newNamespaceURI,
java.lang.String newNodeName,
ElementImpl el) |
protected void |
changed()
Denotes that this node has changed.
|
protected int |
changes()
Returns the number of changes to this node.
|
protected void |
checkDOMNSErr(java.lang.String prefix,
java.lang.String namespace) |
protected void |
checkNamespaceWF(java.lang.String qname,
int colon1,
int colon2)
Call user data handlers to let them know the nodes they are related to
are being deleted.
|
protected void |
checkQName(java.lang.String prefix,
java.lang.String local)
Checks if the given qualified name is legal with respect
to the version of XML to which this document must conform.
|
protected void |
clearIdentifiers()
Remove all identifiers from the ID table
|
java.lang.Object |
clone()
Clone.
|
org.w3c.dom.Node |
cloneNode(boolean deep)
Deep-clone a document, including fixing ownerDoc for the cloned
children.
|
protected void |
cloneNode(CoreDocumentImpl newdoc,
boolean deep)
internal method to share code with subclass
|
protected void |
copyEventListeners(NodeImpl src,
NodeImpl tgt) |
org.w3c.dom.Attr |
createAttribute(java.lang.String name)
Factory method; creates an Attribute having this Document as its
OwnerDoc.
|
org.w3c.dom.Attr |
createAttributeNS(java.lang.String namespaceURI,
java.lang.String qualifiedName)
Introduced in DOM Level 2.
|
org.w3c.dom.Attr |
createAttributeNS(java.lang.String namespaceURI,
java.lang.String qualifiedName,
java.lang.String localpart)
NON-DOM: a factory method used by the Xerces DOM parser
to create an element.
|
org.w3c.dom.CDATASection |
createCDATASection(java.lang.String data)
Factory method; creates a CDATASection having this Document as
its OwnerDoc.
|
org.w3c.dom.Comment |
createComment(java.lang.String data)
Factory method; creates a Comment having this Document as its
OwnerDoc.
|
org.w3c.dom.DocumentFragment |
createDocumentFragment()
Factory method; creates a DocumentFragment having this Document
as its OwnerDoc.
|
org.w3c.dom.DocumentType |
createDocumentType(java.lang.String qualifiedName,
java.lang.String publicID,
java.lang.String systemID)
NON-DOM
Factory method; creates a DocumentType having this Document
as its OwnerDoc.
|
org.w3c.dom.Element |
createElement(java.lang.String tagName)
Factory method; creates an Element having this Document
as its OwnerDoc.
|
ElementDefinitionImpl |
createElementDefinition(java.lang.String name)
NON-DOM Factory method: creates an element definition.
|
org.w3c.dom.Element |
createElementNS(java.lang.String namespaceURI,
java.lang.String qualifiedName)
Introduced in DOM Level 2.
|
org.w3c.dom.Element |
createElementNS(java.lang.String namespaceURI,
java.lang.String qualifiedName,
java.lang.String localpart)
NON-DOM: a factory method used by the Xerces DOM parser
to create an element.
|
org.w3c.dom.Entity |
createEntity(java.lang.String name)
NON-DOM
Factory method; creates an Entity having this Document
as its OwnerDoc.
|
org.w3c.dom.EntityReference |
createEntityReference(java.lang.String name)
Factory method; creates an EntityReference having this Document
as its OwnerDoc.
|
org.w3c.dom.Notation |
createNotation(java.lang.String name)
NON-DOM
Factory method; creates a Notation having this Document
as its OwnerDoc.
|
org.w3c.dom.ProcessingInstruction |
createProcessingInstruction(java.lang.String target,
java.lang.String data)
Factory method; creates a ProcessingInstruction having this Document
as its OwnerDoc.
|
org.w3c.dom.Text |
createTextNode(java.lang.String data)
Factory method; creates a Text node having this Document as its
OwnerDoc.
|
protected boolean |
dispatchEvent(NodeImpl node,
org.w3c.dom.events.Event event) |
boolean |
getAsync()
DOM Level 3 WD - Experimental.
|
java.lang.String |
getBaseURI()
Returns the absolute base URI of this node or null if the implementation
wasn't able to obtain an absolute URI.
|
org.w3c.dom.DocumentType |
getDoctype()
For XML, this provides access to the Document Type Definition.
|
org.w3c.dom.Element |
getDocumentElement()
Convenience method, allowing direct access to the child node
which is considered the root of the actual document content.
|
java.lang.String |
getDocumentURI()
DOM Level 3 WD - Experimental.
|
org.w3c.dom.DOMConfiguration |
getDomConfig()
DOM Level 3 CR - Experimental
The configuration used when
Document.normalizeDocument is
invoked. |
org.w3c.dom.Element |
getElementById(java.lang.String elementId)
Introduced in DOM Level 2
Returns the Element whose ID is given by elementId.
|
org.w3c.dom.NodeList |
getElementsByTagName(java.lang.String tagname)
Return a live collection of all descendent Elements (not just
immediate children) having the specified tag name.
|
org.w3c.dom.NodeList |
getElementsByTagNameNS(java.lang.String namespaceURI,
java.lang.String localName)
Introduced in DOM Level 2.
|
java.lang.String |
getEncoding()
Deprecated.
This method is internal and only exists for
compatibility with older applications. New applications
should never call this method.
|
boolean |
getErrorChecking()
Returns true if the DOM implementation performs error checking.
|
java.lang.Object |
getFeature(java.lang.String feature,
java.lang.String version)
This method returns a specialized object which implements the
specialized APIs of the specified feature and version, as specified
in .
|
org.w3c.dom.Element |
getIdentifier(java.lang.String idName)
Returns a previously registered element with the specified
identifier name, or null if no element is registered.
|
java.util.Enumeration |
getIdentifiers()
Returns an enumeration registered of identifier names.
|
org.w3c.dom.DOMImplementation |
getImplementation()
Retrieve information describing the abilities of this particular
DOM implementation.
|
java.lang.String |
getInputEncoding()
DOM Level 3 CR - Experimental.
|
java.lang.String |
getNodeName()
Returns the node name.
|
protected int |
getNodeNumber()
NON-DOM: Get the number associated with this document.
|
protected int |
getNodeNumber(org.w3c.dom.Node node)
NON-DOM: Get a number associated with a node created with respect
to this document.
|
short |
getNodeType()
Returns the node type.
|
org.w3c.dom.Document |
getOwnerDocument()
Find the Document that this Node belongs to (the document in
whose context the Node was created).
|
boolean |
getStandalone()
Deprecated.
This method is internal and only exists for
compatibility with older applications. New applications
should never call this method.
|
boolean |
getStrictErrorChecking()
An attribute specifying whether error checking is enforced or not.
|
java.lang.String |
getTextContent()
This attribute returns the text content of this node and its
descendants.
|
protected java.lang.Object |
getUserData(NodeImpl n)
NON-DOM: kept for backward compatibility
Retreive user data related to a given node
|
java.lang.Object |
getUserData(org.w3c.dom.Node n,
java.lang.String key)
Retrieves the object associated to a key on a this node.
|
protected java.util.Hashtable |
getUserDataRecord(org.w3c.dom.Node n) |
java.lang.String |
getVersion()
Deprecated.
This method is internal and only exists for
compatibility with older applications. New applications
should never call this method.
|
java.lang.String |
getXmlEncoding()
DOM Level 3 WD - Experimental.
|
boolean |
getXmlStandalone()
DOM Level 3 WD - Experimental.
|
java.lang.String |
getXmlVersion()
DOM Level 3 WD - Experimental.
|
org.w3c.dom.Node |
importNode(org.w3c.dom.Node source,
boolean deep)
Copies a node from another document to this document.
|
org.w3c.dom.Node |
insertBefore(org.w3c.dom.Node newChild,
org.w3c.dom.Node refChild)
Since a Document may contain at most one top-level Element child,
and at most one DocumentType declaraction, we need to subclass our
add-children methods to implement this constraint.
|
protected boolean |
isKidOK(org.w3c.dom.Node parent,
org.w3c.dom.Node child)
Uses the kidOK lookup table to check whether the proposed
tree structure is legal.
|
static boolean |
isValidQName(java.lang.String prefix,
java.lang.String local,
boolean xml11Version)
Checks if the given qualified name is legal with respect
to the version of XML to which this document must conform.
|
static boolean |
isXMLName(java.lang.String s,
boolean xml11Version)
Check the string against XML's definition of acceptable names for
elements and attributes and so on using the XMLCharacterProperties
utility class
|
boolean |
load(java.lang.String uri)
DOM Level 3 WD - Experimental.
|
boolean |
loadXML(java.lang.String source)
DOM Level 3 WD - Experimental.
|
void |
normalizeDocument()
DOM Level 3 WD - Experimental
Normalize document.
|
void |
putIdentifier(java.lang.String idName,
org.w3c.dom.Element element)
Registers an identifier name with a specified element node.
|
org.w3c.dom.Node |
removeChild(org.w3c.dom.Node oldChild)
Since insertBefore caches the docElement (and, currently, docType),
removeChild has to know how to undo the cache
REVISIT: According to the spec it is not allowed to alter neither the
document element nor the document type in any way
|
protected void |
removeEventListener(NodeImpl node,
java.lang.String type,
org.w3c.dom.events.EventListener listener,
boolean useCapture) |
void |
removeIdentifier(java.lang.String idName)
Removes a previously registered element with the specified
identifier name.
|
org.w3c.dom.Node |
renameNode(org.w3c.dom.Node n,
java.lang.String namespaceURI,
java.lang.String name)
DOM Level 3 WD - Experimental.
|
org.w3c.dom.Node |
replaceChild(org.w3c.dom.Node newChild,
org.w3c.dom.Node oldChild)
Since we cache the docElement (and, currently, docType),
replaceChild has to update the cache
REVISIT: According to the spec it is not allowed to alter neither the
document element nor the document type in any way
|
java.lang.String |
saveXML(org.w3c.dom.Node node)
DOM Level 3 WD - Experimental.
|
void |
setAsync(boolean async)
DOM Level 3 WD - Experimental.
|
void |
setDocumentURI(java.lang.String documentURI)
DOM Level 3 WD - Experimental.
|
void |
setEncoding(java.lang.String value)
Deprecated.
This method is internal and only exists for
compatibility with older applications. New applications
should never call this method.
|
void |
setErrorChecking(boolean check)
Sets whether the DOM implementation performs error checking
upon operations.
|
void |
setInputEncoding(java.lang.String value)
DOM Internal
(Was a DOM L3 Core WD public interface method setActualEncoding )
An attribute specifying the actual encoding of this document.
|
void |
setStandalone(boolean value)
Deprecated.
This method is internal and only exists for
compatibility with older applications. New applications
should never call this method.
|
void |
setStrictErrorChecking(boolean check)
An attribute specifying whether error checking is enforced or not.
|
void |
setTextContent(java.lang.String textContent)
This attribute returns the text content of this node and its
descendants.
|
protected void |
setUserData(NodeImpl n,
java.lang.Object data)
NON-DOM: kept for backward compatibility
Store user data related to a given node
This is a place where we could use weak references! Indeed, the node
here won't be GC'ed as long as some user data is attached to it, since
the userData table will have a reference to the node.
|
java.lang.Object |
setUserData(org.w3c.dom.Node n,
java.lang.String key,
java.lang.Object data,
org.w3c.dom.UserDataHandler handler)
Associate an object to a key on this node.
|
void |
setVersion(java.lang.String value)
Deprecated.
This method is internal and only exists for
compatibility with older applications. New applications
should never call this method.
|
void |
setXmlEncoding(java.lang.String value)
DOM Internal
(Was a DOM L3 Core WD public interface method setXMLEncoding )
An attribute specifying, as part of the XML declaration,
the encoding of this document.
|
void |
setXmlStandalone(boolean value)
DOM Level 3 CR - Experimental.
|
void |
setXmlVersion(java.lang.String value)
DOM Level 3 CR - Experimental.
|
protected void |
undeferChildren(org.w3c.dom.Node node)
Traverses the DOM Tree and expands deferred nodes and their
children.
|
getChildNodes, getChildNodesUnoptimized, getFirstChild, getLastChild, getLength, hasChildNodes, isEqualNode, item, normalize, setOwnerDocument, setReadOnly, synchronizeChildrengetNextSibling, getParentNode, getPreviousSiblingaddEventListener, appendChild, compareDocumentPosition, compareTreePosition, dispatchEvent, getAttributes, getContainer, getLocalName, getNamespaceURI, getNodeValue, getPrefix, getReadOnly, getUserData, getUserData, getUserDataRecord, hasAttributes, isDefaultNamespace, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, needsSyncChildren, removeEventListener, setNodeValue, setPrefix, setUserData, setUserData, synchronizeData, toStringequals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitappendChild, compareDocumentPosition, getAttributes, getChildNodes, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNodeValue, getParentNode, getPrefix, getPreviousSibling, getUserData, hasAttributes, hasChildNodes, isDefaultNamespace, isEqualNode, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, normalize, setNodeValue, setPrefix, setUserDataprotected DocumentTypeImpl docType
protected ElementImpl docElement
protected java.lang.String encoding
protected java.lang.String actualEncoding
protected java.lang.String version
protected boolean standalone
protected java.lang.String fDocumentURI
protected java.util.Map userData
protected java.util.Hashtable identifiers
protected int changes
Any method that alters the tree structure MUST cause or be accompanied by a call to changed(), to inform it that any outstanding NodeLists may have to be updated.
(Required because NodeList is simultaneously "live" and integer- indexed -- a bad decision in the DOM's design.)
Note that changes which do not affect the tree's structure -- changing the node's name, for example -- do _not_ have to call changed().
Alternative implementation would be to use a cryptographic Digest value rather than a count. This would have the advantage that "harmless" changes (those producing equal() trees) would not force NodeList to resynchronize. Disadvantage is that it's slightly more prone to "false negatives", though that's the difference between "wildly unlikely" and "absurdly unlikely". IF we start maintaining digests, we should consider taking advantage of them. Note: This used to be done a node basis, so that we knew what subtree changed. But since only DeepNodeList really use this today, the gain appears to be really small compared to the cost of having an int on every (parent) node plus having to walk up the tree all the way to the root to mark the branch as changed everytime a node is changed. So we now have a single counter global to the document. It means that some objects may flush their cache more often than necessary, but this makes nodes smaller and only the document needs to be marked as changed.
protected boolean allowGrammarAccess
protected boolean errorChecking
protected boolean xmlVersionChanged
public CoreDocumentImpl()
public CoreDocumentImpl(boolean grammarAccess)
public CoreDocumentImpl(org.w3c.dom.DocumentType doctype)
public CoreDocumentImpl(org.w3c.dom.DocumentType doctype,
boolean grammarAccess)
public final org.w3c.dom.Document getOwnerDocument()
ParentNodegetOwnerDocument in interface org.w3c.dom.NodegetOwnerDocument in class ParentNodepublic short getNodeType()
getNodeType in interface org.w3c.dom.NodegetNodeType in class NodeImplpublic java.lang.String getNodeName()
getNodeName in interface org.w3c.dom.NodegetNodeName in class NodeImplpublic org.w3c.dom.Node cloneNode(boolean deep)
cloneNode in interface org.w3c.dom.NodecloneNode in class ParentNodedeep - boolean, iff true replicate children
Example: Cloning a Text node will copy both the node and the text it
contains.
Example: Cloning something that has children -- Element or Attr, for
example -- will _not_ clone those children unless a "deep clone"
has been requested. A shallow clone of an Attr node will yield an
empty Attr of the same name.
NOTE: Clones will always be read/write, even if the node being cloned
is read-only, to permit applications using only the DOM API to obtain
editable copies of locked portions of the tree.
protected void cloneNode(CoreDocumentImpl newdoc, boolean deep)
public org.w3c.dom.Node insertBefore(org.w3c.dom.Node newChild,
org.w3c.dom.Node refChild)
throws org.w3c.dom.DOMException
While I'm doing so, I've taken advantage of the opportunity to cache documentElement and docType so we don't have to search for them. REVISIT: According to the spec it is not allowed to alter neither the document element nor the document type in any way
insertBefore in interface org.w3c.dom.NodeinsertBefore in class ParentNodenewChild - The Node to be moved to our subtree. As a
convenience feature, inserting a DocumentNode will instead insert
all its children.refChild - Current child which newChild should be placed
immediately before. If refChild is null, the insertion occurs
after all existing Nodes, like appendChild().org.w3c.dom.DOMException - HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not
allow children of the type of the newChild node, or if
the node to insert is one of this node's ancestors or this node
itself, or if this node is of type Document and the
DOM application attempts to insert a second
DocumentType or Element node.
newChild was created
from a different document than the one that created this node.
refChild is not a child of
this node.
Document,
this exception might be raised if the DOM implementation doesn't
support the insertion of a DocumentType or
Element node.ParentNodepublic org.w3c.dom.Node removeChild(org.w3c.dom.Node oldChild)
throws org.w3c.dom.DOMException
removeChild in interface org.w3c.dom.NoderemoveChild in class ParentNodeoldChild - The node being removed.org.w3c.dom.DOMException - NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
oldChild is not a child of
this node.
Document,
this exception might be raised if the DOM implementation doesn't
support the removal of the DocumentType child or the
Element child.ParentNodepublic org.w3c.dom.Node replaceChild(org.w3c.dom.Node newChild,
org.w3c.dom.Node oldChild)
throws org.w3c.dom.DOMException
replaceChild in interface org.w3c.dom.NodereplaceChild in class ParentNodenewChild - The new node to put in the child list.oldChild - The node being replaced in the list.org.w3c.dom.DOMException - HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not
allow children of the type of the newChild node, or if
the node to put in is one of this node's ancestors or this node
itself, or if this node is of type Document and the
result of the replacement operation would add a second
DocumentType or Element on the
Document node.
newChild was created
from a different document than the one that created this node.
oldChild is not a child of
this node.
Document,
this exception might be raised if the DOM implementation doesn't
support the replacement of the DocumentType child or
Element child.ParentNodepublic java.lang.String getTextContent()
throws org.w3c.dom.DOMException
NodeImplText node 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.
| Node type | Content |
|---|
| Node type | Content |
|---|---|
| ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, DOCUMENT_FRAGMENT_NODE | concatenation of the textContent
attribute value of every child node, excluding COMMENT_NODE and
PROCESSING_INSTRUCTION_NODE nodes |
| ATTRIBUTE_NODE, TEXT_NODE, CDATA_SECTION_NODE, COMMENT_NODE, PROCESSING_INSTRUCTION_NODE |
nodeValue |
| DOCUMENT_NODE, DOCUMENT_TYPE_NODE, NOTATION_NODE | null |
getTextContent in interface org.w3c.dom.NodegetTextContent in class ParentNodeorg.w3c.dom.DOMException - NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.public void setTextContent(java.lang.String textContent)
throws org.w3c.dom.DOMException
NodeImplText node 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.
| Node type | Content |
|---|---|
| ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, DOCUMENT_FRAGMENT_NODE | concatenation of the textContent
attribute value of every child node, excluding COMMENT_NODE and
PROCESSING_INSTRUCTION_NODE nodes |
| ATTRIBUTE_NODE, TEXT_NODE, CDATA_SECTION_NODE, COMMENT_NODE, PROCESSING_INSTRUCTION_NODE |
nodeValue |
| DOCUMENT_NODE, DOCUMENT_TYPE_NODE, NOTATION_NODE | null |
setTextContent in interface org.w3c.dom.NodesetTextContent in class ParentNodeorg.w3c.dom.DOMException - NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.public java.lang.Object getFeature(java.lang.String feature,
java.lang.String version)
org.w3c.dom.NodeNode
interface.getFeature in interface org.w3c.dom.NodegetFeature in class NodeImplfeature - The name of the feature requested. Note that any plus
sign "+" prepended to the name of the feature will be ignored since
it is not significant in the context of this method.version - This is the version number of the feature to test.null if
there is no object which implements interfaces associated with that
feature. If the DOMObject returned by this method
implements the Node interface, it must delegate to the
primary core Node and not return results inconsistent
with the primary core Node such as attributes,
childNodes, etc.public org.w3c.dom.Attr createAttribute(java.lang.String name)
throws org.w3c.dom.DOMException
createAttribute in interface org.w3c.dom.Documentname - The name of the attribute. Note that the attribute's value is
_not_ established at the factory; remember to set it!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.DOMException(INVALID_NAME_ERR) - if the attribute name is not acceptable.org.w3c.dom.DOMException - INVALID_CHARACTER_ERR: Raised if the specified name is not an XML
name according to the XML version in use specified in the
Document.xmlVersion attribute.public org.w3c.dom.CDATASection createCDATASection(java.lang.String data)
throws org.w3c.dom.DOMException
createCDATASection in interface org.w3c.dom.Documentdata - The initial contents of the CDATACDATASection object.DOMException(NOT_SUPPORTED_ERR) - for HTML documents. (HTML
not yet implemented.)org.w3c.dom.DOMException - NOT_SUPPORTED_ERR: Raised if this document is an HTML document.public org.w3c.dom.Comment createComment(java.lang.String data)
createComment in interface org.w3c.dom.Documentdata - The initial contents of the Comment.Comment object.public org.w3c.dom.DocumentFragment createDocumentFragment()
createDocumentFragment in interface org.w3c.dom.DocumentDocumentFragment.public org.w3c.dom.Element createElement(java.lang.String tagName)
throws org.w3c.dom.DOMException
createElement in interface org.w3c.dom.DocumenttagName - The name of the element type to instantiate. For
XML, this is case-sensitive. For HTML, the tagName parameter may
be provided in any case, but it must be mapped to the canonical
uppercase form by the DOM implementation.Element object with the
nodeName attribute set to tagName, and
localName, prefix, and
namespaceURI set to null.DOMException(INVALID_NAME_ERR) - if the tag name is not
acceptable.org.w3c.dom.DOMException - INVALID_CHARACTER_ERR: Raised if the specified name is not an XML
name according to the XML version in use specified in the
Document.xmlVersion attribute.public org.w3c.dom.EntityReference createEntityReference(java.lang.String name)
throws org.w3c.dom.DOMException
createEntityReference in interface org.w3c.dom.Documentname - The name of the Entity we wish to refer toEntityReference object.DOMException(NOT_SUPPORTED_ERR) - for HTML documents, where
nonstandard entities are not permitted. (HTML not yet
implemented.)org.w3c.dom.DOMException - INVALID_CHARACTER_ERR: Raised if the specified name is not an XML
name according to the XML version in use specified in the
Document.xmlVersion attribute.
public org.w3c.dom.ProcessingInstruction createProcessingInstruction(java.lang.String target,
java.lang.String data)
throws org.w3c.dom.DOMException
createProcessingInstruction in interface org.w3c.dom.Documenttarget - The target "processor channel"data - Parameter string to be passed to the target.ProcessingInstruction object.DOMException(INVALID_NAME_ERR) - if the target name is not
acceptable.DOMException(NOT_SUPPORTED_ERR) - for HTML documents. (HTML
not yet implemented.)org.w3c.dom.DOMException - INVALID_CHARACTER_ERR: Raised if the specified target is not an XML
name according to the XML version in use specified in the
Document.xmlVersion attribute.
public org.w3c.dom.Text createTextNode(java.lang.String data)
createTextNode in interface org.w3c.dom.Documentdata - The initial contents of the Text.Text object.public org.w3c.dom.DocumentType getDoctype()
getDoctype in interface org.w3c.dom.Documentpublic org.w3c.dom.Element getDocumentElement()
getDocumentElement in interface org.w3c.dom.Documentpublic org.w3c.dom.NodeList getElementsByTagName(java.lang.String tagname)
getElementsByTagName in interface org.w3c.dom.Documenttagname - The type of Element we want to gather. "*" will be
taken as a wildcard, meaning "all elements in the document."NodeList object containing all the matched
Elements.DeepNodeListImplpublic org.w3c.dom.DOMImplementation getImplementation()
getImplementation in interface org.w3c.dom.Documentpublic void setErrorChecking(boolean check)
Turning off error checking does not turn off the following checks:
public void setStrictErrorChecking(boolean check)
org.w3c.dom.Documentfalse, the implementation is free to not test
every possible error case normally defined on DOM operations, and not
raise any DOMException on DOM operations or report
errors while using Document.normalizeDocument(). In case
of error, the behavior is undefined. This attribute is
true by default.setStrictErrorChecking in interface org.w3c.dom.Documentpublic boolean getErrorChecking()
public boolean getStrictErrorChecking()
org.w3c.dom.Documentfalse, the implementation is free to not test
every possible error case normally defined on DOM operations, and not
raise any DOMException on DOM operations or report
errors while using Document.normalizeDocument(). In case
of error, the behavior is undefined. This attribute is
true by default.getStrictErrorChecking in interface org.w3c.dom.Documentpublic java.lang.String getInputEncoding()
null when
it is not known, such as when the Document was
created in memory.getInputEncoding in interface org.w3c.dom.Documentpublic void setInputEncoding(java.lang.String value)
null otherwise.
public void setXmlEncoding(java.lang.String value)
public void setEncoding(java.lang.String value)
public java.lang.String getXmlEncoding()
getXmlEncoding in interface org.w3c.dom.Documentpublic java.lang.String getEncoding()
public void setXmlVersion(java.lang.String value)
setXmlVersion in interface org.w3c.dom.Documentpublic void setVersion(java.lang.String value)
public java.lang.String getXmlVersion()
getXmlVersion in interface org.w3c.dom.Documentpublic java.lang.String getVersion()
public void setXmlStandalone(boolean value)
throws org.w3c.dom.DOMException
setXmlStandalone in interface org.w3c.dom.Documentorg.w3c.dom.DOMException - NOT_SUPPORTED_ERR: Raised if this document does not support the
"XML" feature.public void setStandalone(boolean value)
public boolean getXmlStandalone()
getXmlStandalone in interface org.w3c.dom.Documentpublic boolean getStandalone()
public java.lang.String getDocumentURI()
null if undefined.
Document supports the feature
"HTML" , the href attribute of the HTML BASE element takes precedence
over this attribute.getDocumentURI in interface org.w3c.dom.Documentprotected boolean canRenameElements(java.lang.String newNamespaceURI,
java.lang.String newNodeName,
ElementImpl el)
public org.w3c.dom.Node renameNode(org.w3c.dom.Node n,
java.lang.String namespaceURI,
java.lang.String name)
throws org.w3c.dom.DOMException
renameNode in interface org.w3c.dom.Documentn - The node to rename.namespaceURI - The new namespace URI.name - The new qualified name.org.w3c.dom.DOMException - NOT_SUPPORTED_ERR: Raised when the type of the specified node is
neither ELEMENT_NODE nor ATTRIBUTE_NODE,
or if the implementation does not support the renaming of the
document element.
Document.xmlVersion attribute.
qualifiedName is a
malformed qualified name, if the qualifiedName has a
prefix and the namespaceURI is null, or
if the qualifiedName has a prefix that is "xml" and
the namespaceURI is different from "
http://www.w3.org/XML/1998/namespace" [XML Namespaces]
. Also raised, when the node being renamed is an attribute, if the
qualifiedName, or its prefix, is "xmlns" and the
namespaceURI is different from "http://www.w3.org/2000/xmlns/".public void normalizeDocument()
normalizeDocument in interface org.w3c.dom.Documentpublic org.w3c.dom.DOMConfiguration getDomConfig()
Document.normalizeDocument is
invoked.getDomConfig in interface org.w3c.dom.Documentpublic java.lang.String getBaseURI()
getBaseURI in interface org.w3c.dom.NodegetBaseURI in class NodeImplpublic void setDocumentURI(java.lang.String documentURI)
setDocumentURI in interface org.w3c.dom.Documentpublic boolean getAsync()
true
the load method returns control to the caller before the document has
completed loading. The default value of this property is
false.
false but we
need to check with Mozilla and IE.public void setAsync(boolean async)
true
the load method returns control to the caller before the document has
completed loading. The default value of this property is
false.
false but we
need to check with Mozilla and IE.public void abort()
load being invoked the loading and parsing is
immediately aborted. The possibly partial result of parsing the
document is discarded and the document is cleared.public boolean load(java.lang.String uri)
Event.targetNode will be the document,
not an element) will be dispatched on the document. If an error
occurs, an implementation dependent "error" event will be dispatched
on the document. If this method is called on a document that is
currently loading, the current load is interrupted and the new URI
load is initiated.
DOMParser interface are assumed to have their default
values with the exception that the parameters "entities"
, "normalize-characters",
"check-character-normalization" are set to
"false".
DOMParser.parseWithContext with an input stream
referencing the URI that was passed to this call, the document as the
context node, and the action ACTION_REPLACE_CHILDREN.uri - The URI reference for the XML file to be loaded. If this is
a relative URI, the base URI used by the implementation is
implementation dependent.true load returns
true if the document load was successfully initiated.
If an error occurred when initiating the document load,
load returns false.If async is set to
false load returns true if
the document was successfully loaded and parsed. If an error
occurred when either loading or parsing the URI, load
returns false.public boolean loadXML(java.lang.String source)
source - A string containing an XML document.true if parsing the input string succeeded
without errors, otherwise false.public java.lang.String saveXML(org.w3c.dom.Node node)
throws org.w3c.dom.DOMException
LSSerializer interface are
assumed to have their default values when invoking this method.
LSSerializer.writeToString with the document as
the node to write.node - Specifies what to serialize, if this parameter is
null the whole document is serialized, if it's
non-null the given node is serialized.null in case an error
occurred.org.w3c.dom.DOMException - WRONG_DOCUMENT_ERR: Raised if the node passed in as the node
parameter is from an other document.public org.w3c.dom.DocumentType createDocumentType(java.lang.String qualifiedName,
java.lang.String publicID,
java.lang.String systemID)
throws org.w3c.dom.DOMException
qualifiedName - publicID - systemID - DOMException(NOT_SUPPORTED_ERR) - for HTML documents, where
DTDs are not permitted. (HTML not yet implemented.)org.w3c.dom.DOMExceptionpublic org.w3c.dom.Entity createEntity(java.lang.String name)
throws org.w3c.dom.DOMException
name - The name of the Entity we wish to provide a value for.DOMException(NOT_SUPPORTED_ERR) - for HTML documents, where
nonstandard entities are not permitted. (HTML not yet
implemented.)org.w3c.dom.DOMExceptionpublic org.w3c.dom.Notation createNotation(java.lang.String name)
throws org.w3c.dom.DOMException
name - The name of the Notation we wish to describeDOMException(NOT_SUPPORTED_ERR) - for HTML documents, where
notations are not permitted. (HTML not yet
implemented.)org.w3c.dom.DOMExceptionpublic ElementDefinitionImpl createElementDefinition(java.lang.String name) throws org.w3c.dom.DOMException
org.w3c.dom.DOMExceptionprotected int getNodeNumber()
getNodeNumber in class NodeImplprotected int getNodeNumber(org.w3c.dom.Node node)
public org.w3c.dom.Node importNode(org.w3c.dom.Node source,
boolean deep)
throws org.w3c.dom.DOMException
According to the DOM specifications, document nodes cannot be imported and a NOT_SUPPORTED_ERR exception is thrown if attempted.
importNode in interface org.w3c.dom.Documentsource - The node to import.deep - If true, recursively import the subtree under
the specified node; if false, import only the node
itself, as explained above. This has no effect on nodes that cannot
have any children, and on Attr, and
EntityReference nodes.Document.org.w3c.dom.DOMException - NOT_SUPPORTED_ERR: Raised if the type of node being imported is not
supported.
Document.xmlVersion attribute. This may happen when
importing an XML 1.1 [XML 1.1] element
into an XML 1.0 document, for instance.public org.w3c.dom.Node adoptNode(org.w3c.dom.Node source)
adoptNode in interface org.w3c.dom.Documentsource - The node to adopt.null if this operation
fails, such as when the source node comes from a different
implementation.importNode(org.w3c.dom.Node, boolean)protected void undeferChildren(org.w3c.dom.Node node)
public org.w3c.dom.Element getElementById(java.lang.String elementId)
Note: 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.
getElementById in interface org.w3c.dom.DocumentelementId - The unique id value for an element.null if there is none.getIdentifier(java.lang.String)protected final void clearIdentifiers()
public void putIdentifier(java.lang.String idName,
org.w3c.dom.Element element)
public org.w3c.dom.Element getIdentifier(java.lang.String idName)
public void removeIdentifier(java.lang.String idName)
public java.util.Enumeration getIdentifiers()
public org.w3c.dom.Element createElementNS(java.lang.String namespaceURI,
java.lang.String qualifiedName)
throws org.w3c.dom.DOMException
Creates an element of the given qualified name and namespace URI. If the given namespaceURI is null or an empty string and the qualifiedName has a prefix that is "xml", the created element is bound to the predefined namespace "http://www.w3.org/XML/1998/namespace" [Namespaces].
createElementNS in interface org.w3c.dom.DocumentnamespaceURI - The namespace URI of the element to
create.qualifiedName - The qualified name of the element type to
instantiate.org.w3c.dom.DOMException - INVALID_CHARACTER_ERR: Raised if the specified
name contains an invalid character.org.w3c.dom.DOMException - NAMESPACE_ERR: Raised if the qualifiedName has a
prefix that is "xml" and the namespaceURI is
neither null nor an empty string nor
"http://www.w3.org/XML/1998/namespace", or
if the qualifiedName has a prefix different
from "xml" and the namespaceURI is null or an
empty string.public org.w3c.dom.Element createElementNS(java.lang.String namespaceURI,
java.lang.String qualifiedName,
java.lang.String localpart)
throws org.w3c.dom.DOMException
namespaceURI - The namespace URI of the element to
create.qualifiedName - The qualified name of the element type to
instantiate.localpart - The local name of the attribute to instantiate.org.w3c.dom.DOMException - INVALID_CHARACTER_ERR: Raised if the specified
name contains an invalid character.public org.w3c.dom.Attr createAttributeNS(java.lang.String namespaceURI,
java.lang.String qualifiedName)
throws org.w3c.dom.DOMException
Creates an attribute of the given qualified name and namespace URI. If the given namespaceURI is null or an empty string and the qualifiedName has a prefix that is "xml", the created element is bound to the predefined namespace "http://www.w3.org/XML/1998/namespace" [Namespaces].
createAttributeNS in interface org.w3c.dom.DocumentnamespaceURI - The namespace URI of the attribute to
create. When it is null or an empty string,
this method behaves like createAttribute.qualifiedName - The qualified name of the attribute to
instantiate.org.w3c.dom.DOMException - INVALID_CHARACTER_ERR: Raised if the specified
name contains an invalid character.public org.w3c.dom.Attr createAttributeNS(java.lang.String namespaceURI,
java.lang.String qualifiedName,
java.lang.String localpart)
throws org.w3c.dom.DOMException
namespaceURI - The namespace URI of the attribute to
create. When it is null or an empty string,
this method behaves like createAttribute.qualifiedName - The qualified name of the attribute to
instantiate.localpart - The local name of the attribute to instantiate.org.w3c.dom.DOMException - INVALID_CHARACTER_ERR: Raised if the specified
name contains an invalid character.public org.w3c.dom.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 would be encountered in a preorder traversal of the Document tree.
getElementsByTagNameNS in interface org.w3c.dom.DocumentnamespaceURI - The namespace URI of the elements to match
on. The special value "*" matches all
namespaces. When it is null or an empty
string, this method behaves like
getElementsByTagName.localName - The local name of the elements to match on.
The special value "*" matches all local names.public java.lang.Object clone()
throws java.lang.CloneNotSupportedException
clone in class java.lang.Objectjava.lang.CloneNotSupportedExceptionpublic static final boolean isXMLName(java.lang.String s,
boolean xml11Version)
public static final boolean isValidQName(java.lang.String prefix,
java.lang.String local,
boolean xml11Version)
prefix - prefix of qualified namelocal - local part of qualified nameprotected boolean isKidOK(org.w3c.dom.Node parent,
org.w3c.dom.Node child)
protected void changed()
protected int changes()
public java.lang.Object setUserData(org.w3c.dom.Node n,
java.lang.String key,
java.lang.Object data,
org.w3c.dom.UserDataHandler handler)
getUserData with the
same key.n - The node to associate the object to.key - The key to associate the object to.data - The object to associate to the given key, or
null to remove any existing association to that key.handler - The handler to associate to that key, or
null.DOMObject previously associated to
the given key on this node, or null if there was none.public java.lang.Object getUserData(org.w3c.dom.Node n,
java.lang.String key)
setUserData with the same key.n - The node the object is associated to.key - The key the object is associated to.DOMObject associated to the given key
on this node, or null if there was none.protected java.util.Hashtable getUserDataRecord(org.w3c.dom.Node n)
protected void callUserDataHandlers(org.w3c.dom.Node n,
org.w3c.dom.Node c,
short operation)
n - The node this operation applies to.c - The copy node or null.operation - The operation - import, clone, or delete.protected final void checkNamespaceWF(java.lang.String qname,
int colon1,
int colon2)
protected final void checkDOMNSErr(java.lang.String prefix,
java.lang.String namespace)
protected final void checkQName(java.lang.String prefix,
java.lang.String local)
prefix - prefix of qualified namelocal - local part of qualified nameprotected void setUserData(NodeImpl n, java.lang.Object data)
protected java.lang.Object getUserData(NodeImpl n)
protected void addEventListener(NodeImpl node, java.lang.String type, org.w3c.dom.events.EventListener listener, boolean useCapture)
protected void removeEventListener(NodeImpl node, java.lang.String type, org.w3c.dom.events.EventListener listener, boolean useCapture)
protected boolean dispatchEvent(NodeImpl node, org.w3c.dom.events.Event event)
Copyright © 1999-2022 The Apache Software Foundation. All Rights Reserved.