public class CoreDocumentImpl extends ParentNode implements 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.
| Modifier and Type | Field and Description |
|---|---|
protected 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 String |
encoding
Experimental DOM Level 3 feature: Document encoding
|
protected boolean |
errorChecking
Bypass error checking.
|
protected String |
fDocumentURI
Experimental DOM Level 3 feature: documentURI
|
protected net.sourceforge.htmlunit.xerces.dom.NodeListCache |
fFreeNLCache
NodeListCache free list
|
protected Hashtable<String,Element> |
identifiers
Identifiers.
|
protected boolean |
standalone
Experimental DOM Level 3 feature: Document standalone
|
protected Map<Node,Hashtable<String,net.sourceforge.htmlunit.xerces.dom.ParentNode.UserDataRecord>> |
userData
Table for user data attached to this document nodes.
|
protected 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, SYNCDATAATTRIBUTE_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(DocumentType doctype)
For DOM2 support.
|
CoreDocumentImpl(DocumentType doctype,
boolean grammarAccess)
For DOM2 support.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
addEventListener(NodeImpl node,
String type,
EventListener listener,
boolean useCapture) |
Node |
adoptNode(Node source)
DOM Level 3 WD - Experimental
Change the node's ownerDocument, and its subtree, to this Document
|
protected void |
callUserDataHandlers(Node n,
Node c,
short operation)
Call user data handlers when a node is deleted (finalized)
|
protected boolean |
canRenameElements(String newNamespaceURI,
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(String prefix,
String namespace) |
protected void |
checkNamespaceWF(String qname,
int colon1,
int colon2) |
protected void |
checkQName(String prefix,
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
|
Object |
clone()
Clone.
|
Node |
cloneNode(boolean deep)
Deep-clone a document, including fixing ownerDoc for the cloned
children.
|
protected void |
cloneNode(CoreDocumentImpl newdoc,
boolean deep) |
protected void |
copyEventListeners(NodeImpl src,
NodeImpl tgt) |
Attr |
createAttribute(String name)
Factory method; creates an Attribute having this Document as its
OwnerDoc.
|
Attr |
createAttributeNS(String namespaceURI,
String qualifiedName)
Introduced in DOM Level 2.
|
Attr |
createAttributeNS(String namespaceURI,
String qualifiedName,
String localpart)
NON-DOM: a factory method used by the Xerces DOM parser
to create an element.
|
CDATASection |
createCDATASection(String data)
Factory method; creates a CDATASection having this Document as
its OwnerDoc.
|
Comment |
createComment(String data)
Factory method; creates a Comment having this Document as its
OwnerDoc.
|
DocumentFragment |
createDocumentFragment()
Factory method; creates a DocumentFragment having this Document
as its OwnerDoc.
|
DocumentType |
createDocumentType(String qualifiedName,
String publicID,
String systemID)
NON-DOM
Factory method; creates a DocumentType having this Document
as its OwnerDoc.
|
Element |
createElement(String tagName)
Factory method; creates an Element having this Document
as its OwnerDoc.
|
ElementDefinitionImpl |
createElementDefinition(String name) |
Element |
createElementNS(String namespaceURI,
String qualifiedName)
Introduced in DOM Level 2.
|
Element |
createElementNS(String namespaceURI,
String qualifiedName,
String localpart)
NON-DOM: a factory method used by the Xerces DOM parser
to create an element.
|
Entity |
createEntity(String name)
NON-DOM
Factory method; creates an Entity having this Document
as its OwnerDoc.
|
EntityReference |
createEntityReference(String name)
Factory method; creates an EntityReference having this Document
as its OwnerDoc.
|
ProcessingInstruction |
createProcessingInstruction(String target,
String data)
Factory method; creates a ProcessingInstruction having this Document
as its OwnerDoc.
|
Text |
createTextNode(String data)
Factory method; creates a Text node having this Document as its
OwnerDoc.
|
String |
getBaseURI()
Returns the absolute base URI of this node or null if the implementation
wasn't able to obtain an absolute URI.
|
DocumentType |
getDoctype()
For XML, this provides access to the Document Type Definition.
|
Element |
getDocumentElement()
Convenience method, allowing direct access to the child node
which is considered the root of the actual document content.
|
String |
getDocumentURI()
DOM Level 3 WD - Experimental.
|
DOMConfiguration |
getDomConfig()
DOM Level 3 CR - Experimental
|
Element |
getElementById(String elementId)
Introduced in DOM Level 2
Returns the Element whose ID is given by elementId.
|
NodeList |
getElementsByTagName(String tagname)
Return a live collection of all descendant Elements (not just
immediate children) having the specified tag name.
|
NodeList |
getElementsByTagNameNS(String namespaceURI,
String localName)
Introduced in DOM Level 2.
|
boolean |
getErrorChecking() |
Element |
getIdentifier(String idName)
Returns a previously registered element with the specified
identifier name, or null if no element is registered.
|
DOMImplementation |
getImplementation()
Retrieve information describing the abilities of this particular
DOM implementation.
|
String |
getInputEncoding()
DOM Level 3 CR - Experimental.
|
String |
getNodeName()
Returns the node name.
|
protected int |
getNodeNumber()
NON-DOM: Get the number associated with this document.
|
protected int |
getNodeNumber(Node node) |
short |
getNodeType()
Returns the node type.
|
Document |
getOwnerDocument()
Find the Document that this Node belongs to (the document in
whose context the Node was created).
|
boolean |
getStrictErrorChecking() |
String |
getTextContent()
This attribute returns the text content of this node and its
descendants.
|
protected Object |
getUserData(NodeImpl n) |
Object |
getUserData(Node n,
String key)
Retrieves the object associated to a key on a this node.
|
protected Hashtable<String,net.sourceforge.htmlunit.xerces.dom.ParentNode.UserDataRecord> |
getUserDataRecord(Node n) |
String |
getXmlEncoding()
DOM Level 3 WD - Experimental.
|
boolean |
getXmlStandalone()
DOM Level 3 WD - Experimental.
|
String |
getXmlVersion()
DOM Level 3 WD - Experimental.
|
Node |
importNode(Node source,
boolean deep)
Copies a node from another document to this document.
|
Node |
insertBefore(Node newChild,
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(Node parent,
Node child)
Uses the kidOK lookup table to check whether the proposed
tree structure is legal.
|
static boolean |
isValidQName(String prefix,
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(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
|
void |
normalizeDocument()
DOM Level 3 WD - Experimental
Normalize document.
|
void |
putIdentifier(String idName,
Element element)
Registers an identifier name with a specified element node.
|
Node |
removeChild(Node oldChild)
Since insertBefore caches the docElement (and, currently, docType),
removeChild has to know how to undo the cache
|
protected void |
removeEventListener(NodeImpl node,
String type,
EventListener listener,
boolean useCapture) |
void |
removeIdentifier(String idName)
Removes a previously registered element with the specified
identifier name.
|
Node |
renameNode(Node n,
String namespaceURI,
String name)
DOM Level 3 WD - Experimental.
|
Node |
replaceChild(Node newChild,
Node oldChild)
Since we cache the docElement (and, currently, docType),
replaceChild has to update the cache
|
void |
setDocumentURI(String documentURI)
DOM Level 3 WD - Experimental.
|
void |
setErrorChecking(boolean check)
Sets whether the DOM implementation performs error checking
upon operations.
|
void |
setInputEncoding(String value)
DOM Internal
(Was a DOM L3 Core WD public interface method setActualEncoding )
|
void |
setStrictErrorChecking(boolean check) |
void |
setTextContent(String textContent)
This attribute returns the text content of this node and its
descendants.
|
protected void |
setUserData(NodeImpl n,
Object data) |
Object |
setUserData(Node n,
String key,
Object data,
UserDataHandler handler)
Associate an object to a key on this node.
|
void |
setXmlEncoding(String value)
DOM Internal
(Was a DOM L3 Core WD public interface method setXMLEncoding )
|
void |
setXmlStandalone(boolean value)
DOM Level 3 CR - Experimental.
|
void |
setXmlVersion(String value)
DOM Level 3 CR - Experimental.
|
protected void |
undeferChildren(Node node)
Traverses the DOM Tree and expands deferred nodes and their
children.
|
getChildNodes, getChildNodesUnoptimized, getFirstChild, getLastChild, getLength, hasChildNodes, isEqualNode, item, setOwnerDocument, setReadOnly, synchronizeChildrengetNextSibling, getParentNode, getPreviousSiblingaddEventListener, appendChild, compareDocumentPosition, dispatchEvent, getAttributes, getFeature, getLocalName, getNamespaceURI, getNodeValue, getPrefix, getReadOnly, getUserData, getUserData, getUserDataRecord, hasAttributes, isDefaultNamespace, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, needsSyncChildren, normalize, removeEventListener, setNodeValue, setPrefix, setUserData, setUserData, synchronizeData, toStringequals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitappendChild, compareDocumentPosition, getAttributes, getChildNodes, getFeature, 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 net.sourceforge.htmlunit.xerces.dom.NodeListCache fFreeNLCache
protected String encoding
protected String actualEncoding
protected String version
protected boolean standalone
protected String fDocumentURI
protected Map<Node,Hashtable<String,net.sourceforge.htmlunit.xerces.dom.ParentNode.UserDataRecord>> userData
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)
grammarAccess - grammar acess flagpublic CoreDocumentImpl(DocumentType doctype)
doctype - the DocumentTypepublic CoreDocumentImpl(DocumentType doctype, boolean grammarAccess)
doctype - the DocumentTypegrammarAccess - grammar access flagpublic final Document getOwnerDocument()
ParentNodegetOwnerDocument in interface NodegetOwnerDocument in class ParentNodepublic short getNodeType()
getNodeType in interface NodegetNodeType in class NodeImplpublic String getNodeName()
getNodeName in interface NodegetNodeName in class NodeImplpublic Node cloneNode(boolean deep)
cloneNode in interface 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 Node insertBefore(Node newChild, Node refChild) throws 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 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().DOMException - HIERARCHY_REQUEST_ERR if newChild is of a
type that shouldn't be a child of this node, or if newChild is an
ancestor of this node.ParentNodepublic Node removeChild(Node oldChild) throws DOMException
REVISIT: According to the spec it is not allowed to alter neither the document element nor the document type in any way
removeChild in interface NoderemoveChild in class ParentNodeDOMException - NOT_FOUND_ERR if oldChild is not a child of
this node.ParentNodepublic Node replaceChild(Node newChild, Node oldChild) throws DOMException
REVISIT: According to the spec it is not allowed to alter neither the document element nor the document type in any way
replaceChild in interface NodereplaceChild in class ParentNodeDOMException - HIERARCHY_REQUEST_ERR if newChild is of a
type that shouldn't be a child of this node, or if newChild is
one of our ancestors.ParentNodepublic String getTextContent() throws 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 |
getTextContent in interface NodegetTextContent in class ParentNodeDOMException - NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.public void setTextContent(String textContent) throws 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 NodesetTextContent in class ParentNodeDOMException - NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.public Attr createAttribute(String name) throws DOMException
createAttribute in interface Documentname - The name of the attribute. Note that the attribute's value is
_not_ established at the factory; remember to set it!DOMException - INVALID_NAME_ERR if the attribute name is not acceptable.public CDATASection createCDATASection(String data) throws DOMException
createCDATASection in interface Documentdata - The initial contents of the CDATADOMException - NOT_SUPPORTED_ERR for HTML documents. (HTML
not yet implemented.)public Comment createComment(String data)
createComment in interface Documentdata - The initial contents of the Comment.public DocumentFragment createDocumentFragment()
createDocumentFragment in interface Documentpublic Element createElement(String tagName) throws DOMException
createElement in interface 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.DOMException - INVALID_NAME_ERR if the tag name is not
acceptable.public EntityReference createEntityReference(String name) throws DOMException
createEntityReference in interface Documentname - The name of the Entity we wish to refer toDOMException - NOT_SUPPORTED_ERR for HTML documents, where
nonstandard entities are not permitted. (HTML not yet
implemented.)public ProcessingInstruction createProcessingInstruction(String target, String data) throws DOMException
createProcessingInstruction in interface Documenttarget - The target "processor channel"data - Parameter string to be passed to the target.DOMException - INVALID_NAME_ERR if the target name is not
acceptable.DOMException - NOT_SUPPORTED_ERR for HTML documents. (HTML
not yet implemented.)public Text createTextNode(String data)
createTextNode in interface Documentdata - The initial contents of the Text.public DocumentType getDoctype()
getDoctype in interface Documentpublic Element getDocumentElement()
(HTML not yet supported.)
getDocumentElement in interface Documentpublic NodeList getElementsByTagName(String tagname)
getElementsByTagName in interface Documenttagname - The type of Element we want to gather. "*" will be
taken as a wildcard, meaning "all elements in the document."DeepNodeListImplpublic DOMImplementation getImplementation()
getImplementation in interface Documentpublic void setErrorChecking(boolean check)
Turning off error checking does not turn off the following checks:
check - check flagpublic void setStrictErrorChecking(boolean check)
setStrictErrorChecking in interface Documentpublic boolean getErrorChecking()
public boolean getStrictErrorChecking()
getStrictErrorChecking in interface Documentpublic String getInputEncoding()
An attribute specifying the encoding used for this document
at the time of the parsing. This is null when
it is not known, such as when the Document was
created in memory.
getInputEncoding in interface Documentpublic void setInputEncoding(String value)
An attribute specifying the actual encoding of this document. This is
null otherwise.
This attribute represents the property [character encoding scheme]
defined in.
value - the valuepublic void setXmlEncoding(String value)
An attribute specifying, as part of the XML declaration, the encoding of this document. This is null when unspecified.
value - the valuepublic String getXmlEncoding()
getXmlEncoding in interface Documentpublic void setXmlVersion(String value)
setXmlVersion in interface Documentpublic String getXmlVersion()
getXmlVersion in interface Documentpublic void setXmlStandalone(boolean value)
throws DOMException
Xmlstandalone - An attribute specifying, as part of the XML declaration, whether this document is standalone
setXmlStandalone in interface DocumentDOMException - NOT_SUPPORTED_ERR: Raised if this document does not support the
"XML" feature.public boolean getXmlStandalone()
getXmlStandalone in interface Documentpublic 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 Documentprotected boolean canRenameElements(String newNamespaceURI, String newNodeName, ElementImpl el)
public Node renameNode(Node n, String namespaceURI, String name) throws DOMException
renameNode in interface DocumentDOMExceptionpublic void normalizeDocument()
normalizeDocument in interface Documentpublic DOMConfiguration getDomConfig()
The configuration used when Document.normalizeDocument is
invoked.
getDomConfig in interface Documentpublic String getBaseURI()
getBaseURI in interface NodegetBaseURI in class NodeImplpublic void setDocumentURI(String documentURI)
setDocumentURI in interface Documentpublic DocumentType createDocumentType(String qualifiedName, String publicID, String systemID) throws DOMException
qualifiedName - the namepublicID - the public idsystemID - the system idDocumentTypeDOMException - NOT_SUPPORTED_ERR for HTML documents, where
DTDs are not permitted. (HTML not yet implemented.)public Entity createEntity(String name) throws 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.)public ElementDefinitionImpl createElementDefinition(String name) throws DOMException
DOMExceptionprotected int getNodeNumber()
getNodeNumber in class NodeImplprotected int getNodeNumber(Node node)
public Node importNode(Node source, boolean deep) throws DOMException
According to the DOM specifications, document nodes cannot be imported and a NOT_SUPPORTED_ERR exception is thrown if attempted.
importNode in interface DocumentDOMExceptionpublic Node adoptNode(Node source)
adoptNode in interface Documentsource - The node to adopt.importNode(org.w3c.dom.Node, boolean)protected void undeferChildren(Node node)
node - the nodepublic Element getElementById(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 DocumentgetIdentifier(java.lang.String)protected final void clearIdentifiers()
public void putIdentifier(String idName, Element element)
idName - the nameelement - the elementgetIdentifier(String),
removeIdentifier(String)public Element getIdentifier(String idName)
idName - the nameputIdentifier(String, Element),
removeIdentifier(String)public void removeIdentifier(String idName)
idName - the nameputIdentifier(String, Element),
getIdentifier(String)public Element createElementNS(String namespaceURI, String qualifiedName) throws 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 DocumentnamespaceURI - The namespace URI of the element to
create.qualifiedName - The qualified name of the element type to
instantiate.DOMException - INVALID_CHARACTER_ERR: Raised if the specified
name contains an invalid character.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 Element createElementNS(String namespaceURI, String qualifiedName, String localpart) throws 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.DOMException - INVALID_CHARACTER_ERR: Raised if the specified
name contains an invalid character.public Attr createAttributeNS(String namespaceURI, String qualifiedName) throws 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 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.DOMException - INVALID_CHARACTER_ERR: Raised if the specified
name contains an invalid character.public Attr createAttributeNS(String namespaceURI, String qualifiedName, String localpart) throws 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.DOMException - INVALID_CHARACTER_ERR: Raised if the specified
name contains an invalid character.public NodeList getElementsByTagNameNS(String namespaceURI, 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 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 Object clone() throws CloneNotSupportedException
clone in class ObjectCloneNotSupportedExceptionpublic static boolean isXMLName(String s, boolean xml11Version)
s - the string to checkxml11Version - if true use xml 11 rulespublic static boolean isValidQName(String prefix, String local, boolean xml11Version)
prefix - prefix of qualified namelocal - local part of qualified namexml11Version - if true use xml 11 rulesprotected boolean isKidOK(Node parent, Node child)
parent - the parentchild - the childprotected void changed()
protected int changes()
public Object setUserData(Node n, String key, Object data, 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.
REVISIT: we could use a free list of UserDataRecord herepublic Object getUserData(Node n, 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 Hashtable<String,net.sourceforge.htmlunit.xerces.dom.ParentNode.UserDataRecord> getUserDataRecord(Node n)
protected void callUserDataHandlers(Node n, 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(String qname, int colon1, int colon2)
protected final void checkQName(String prefix, String local)
prefix - prefix of qualified namelocal - local part of qualified nameprotected void addEventListener(NodeImpl node, String type, EventListener listener, boolean useCapture)
protected void removeEventListener(NodeImpl node, String type, EventListener listener, boolean useCapture)
Copyright © 2023 Gargoyle Software Inc.. All rights reserved.