Class CoreDocumentImpl
- java.lang.Object
-
- org.htmlunit.cyberneko.xerces.dom.NodeImpl
-
- org.htmlunit.cyberneko.xerces.dom.ChildNode
-
- org.htmlunit.cyberneko.xerces.dom.ParentNode
-
- org.htmlunit.cyberneko.xerces.dom.CoreDocumentImpl
-
- All Implemented Interfaces:
Cloneable,Document,EventTarget,Node,NodeList
- Direct Known Subclasses:
DocumentImpl
public class CoreDocumentImpl extends ParentNode implements Document
The Document interface represents the entire HTML or XML document. Conceptually, it is the root of the document tree, and provides the primary access to the document's data.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.
- Author:
- Arnaud Le Hors, IBM, Joe Kesselman, IBM, Andy Clark, IBM, Ralf Pfeiffer, IBM
-
-
Field Summary
Fields Modifier and Type Field Description protected intchangesNumber of alterations made to this document since its creation.protected booleanerrorCheckingBypass error checking.-
Fields inherited from class org.htmlunit.cyberneko.xerces.dom.ParentNode
firstChild, fNodeListCache, ownerDocument
-
Fields inherited from class org.htmlunit.cyberneko.xerces.dom.ChildNode
nextSibling_, previousSibling_
-
Fields inherited from class org.htmlunit.cyberneko.xerces.dom.NodeImpl
DOCUMENT_POSITION_CONTAINS, DOCUMENT_POSITION_DISCONNECTED, DOCUMENT_POSITION_FOLLOWING, DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, DOCUMENT_POSITION_IS_CONTAINED, DOCUMENT_POSITION_PRECEDING, FIRSTCHILD, HASSTRING, ID, NORMALIZED, OWNED, ownerNode_, READONLY, SPECIFIED, SYNCCHILDREN
-
Fields 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 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(DocumentType doctype)For DOM2 support.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddEventListener(NodeImpl node, String type, EventListener listener, boolean useCapture)NodeadoptNode(Node source)DOM Level 3 WD - Experimental Change the node's ownerDocument, and its subtree, to this Documentprotected booleancanRenameElements(String newNamespaceURI, String newNodeName, ElementImpl el)protected voidchanged()Denotes that this node has changed.protected intchanges()Returns the number of changes to this node.protected voidcheckDOMNSErr(String prefix, String namespace)protected voidcheckNamespaceWF(String qname, int colon1, int colon2)protected voidcheckQName(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 voidclearIdentifiers()Remove all identifiers from the ID tableObjectclone()Clone.NodecloneNode(boolean deep)Deep-clone a document, including fixing ownerDoc for the cloned children.protected voidcloneNode(CoreDocumentImpl newdoc, boolean deep)protected voidcopyEventListeners(NodeImpl src, NodeImpl tgt)AttrcreateAttribute(String name)Factory method; creates an Attribute having this Document as its OwnerDoc.AttrcreateAttributeNS(String namespaceURI, String qualifiedName)Introduced in DOM Level 2.AttrcreateAttributeNS(String namespaceURI, String qualifiedName, String localpart)NON-DOM: a factory method used by the Xerces DOM parser to create an element.CDATASectioncreateCDATASection(String data)Factory method; creates a CDATASection having this Document as its OwnerDoc.CommentcreateComment(String data)Factory method; creates a Comment having this Document as its OwnerDoc.DocumentFragmentcreateDocumentFragment()Factory method; creates a DocumentFragment having this Document as its OwnerDoc.DocumentTypecreateDocumentType(String qualifiedName, String publicID, String systemID)NON-DOM Factory method; creates a DocumentType having this Document as its OwnerDoc.ElementcreateElement(String tagName)Factory method; creates an Element having this Document as its OwnerDoc.ElementcreateElementNS(String namespaceURI, String qualifiedName)Introduced in DOM Level 2.ElementcreateElementNS(String namespaceURI, String qualifiedName, String localpart)NON-DOM: a factory method used by the Xerces DOM parser to create an element.EntitycreateEntity(String name)NON-DOM Factory method; creates an Entity having this Document as its OwnerDoc.EntityReferencecreateEntityReference(String name)Factory method; creates an EntityReference having this Document as its OwnerDoc.ProcessingInstructioncreateProcessingInstruction(String target, String data)Factory method; creates a ProcessingInstruction having this Document as its OwnerDoc.TextcreateTextNode(String data)Factory method; creates a Text node having this Document as its OwnerDoc.StringgetBaseURI()Returns the absolute base URI of this node or null if the implementation wasn't able to obtain an absolute URI.DocumentTypegetDoctype()For XML, this provides access to the Document Type Definition.ElementgetDocumentElement()Convenience method, allowing direct access to the child node which is considered the root of the actual document content.StringgetDocumentURI()DOM Level 3 WD - Experimental.DOMConfigurationgetDomConfig()DOM Level 3 CR - ExperimentalElementgetElementById(String elementId)Introduced in DOM Level 2 Returns the Element whose ID is given by elementId.NodeListgetElementsByTagName(String tagname)Return a live collection of all descendant Elements (not just immediate children) having the specified tag name.NodeListgetElementsByTagNameNS(String namespaceURI, String localName)Introduced in DOM Level 2.booleangetErrorChecking()ElementgetIdentifier(String idName)Returns a previously registered element with the specified identifier name, or null if no element is registered.DOMImplementationgetImplementation()Retrieve information describing the abilities of this particular DOM implementation.StringgetInputEncoding()DOM Level 3 CR - Experimental.StringgetNodeName()Returns the node name.protected intgetNodeNumber()NON-DOM: Get the number associated with this document.protected intgetNodeNumber(Node node)shortgetNodeType()Returns the node type.DocumentgetOwnerDocument()Find the Document that this Node belongs to (the document in whose context the Node was created).booleangetStrictErrorChecking()StringgetTextContent()This attribute returns the text content of this node and its descendants.StringgetXmlEncoding()DOM Level 3 WD - Experimental.booleangetXmlStandalone()DOM Level 3 WD - Experimental. standalone that specifies whether this document is standalone (part of XML Declaration)StringgetXmlVersion()DOM Level 3 WD - Experimental.NodeimportNode(Node source, boolean deep)Copies a node from another document to this document.NodeinsertBefore(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 booleanisKidOK(Node parent, Node child)Uses the kidOK lookup table to check whether the proposed tree structure is legal.static booleanisValidQName(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 booleanisXMLName(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 classvoidnormalizeDocument()DOM Level 3 WD - Experimental Normalize document.voidputIdentifier(String idName, Element element)Registers an identifier name with a specified element node.NoderemoveChild(Node oldChild)Since insertBefore caches the docElement (and, currently, docType), removeChild has to know how to undo the cacheprotected voidremoveEventListener(NodeImpl node, String type, EventListener listener, boolean useCapture)voidremoveIdentifier(String idName)Removes a previously registered element with the specified identifier name.NoderenameNode(Node n, String namespaceURI, String name)DOM Level 3 WD - Experimental.NodereplaceChild(Node newChild, Node oldChild)Since we cache the docElement (and, currently, docType), replaceChild has to update the cachevoidsetDocumentURI(String documentURI)DOM Level 3 WD - Experimental.voidsetErrorChecking(boolean check)Sets whether the DOM implementation performs error checking upon operations.voidsetInputEncoding(String value)DOM Internal (Was a DOM L3 Core WD public interface method setActualEncoding )voidsetStrictErrorChecking(boolean check)voidsetTextContent(String textContent)This attribute returns the text content of this node and its descendants.voidsetXmlEncoding(String value)DOM Internal (Was a DOM L3 Core WD public interface method setXMLEncoding )voidsetXmlStandalone(boolean value)DOM Level 3 CR - Experimental.voidsetXmlVersion(String value)DOM Level 3 CR - Experimental. version - An attribute specifying, as part of the XML declaration, the version number of this document.-
Methods inherited from class org.htmlunit.cyberneko.xerces.dom.ParentNode
getChildNodes, getChildNodesUnoptimized, getFirstChild, getLastChild, getLength, hasChildNodes, isEqualNode, item, setOwnerDocument, synchronizeChildren
-
Methods inherited from class org.htmlunit.cyberneko.xerces.dom.ChildNode
getNextSibling, getParentNode, getPreviousSibling
-
Methods inherited from class org.htmlunit.cyberneko.xerces.dom.NodeImpl
addEventListener, appendChild, compareDocumentPosition, dispatchEvent, getAttributes, getFeature, getLocalName, getNamespaceURI, getNodeValue, getPrefix, getUserData, hasAttributes, isDefaultNamespace, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, needsSyncChildren, normalize, removeEventListener, setNodeValue, setPrefix, setUserData, toString
-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.w3c.dom.Node
appendChild, 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, setUserData
-
-
-
-
Field Detail
-
changes
protected int changes
Number of alterations made to this document since its creation. Serves as a "dirty bit" so that live objects such as NodeList can recognize when an alteration has been made and discard its cached state information.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.
-
errorChecking
protected boolean errorChecking
Bypass error checking.
-
-
Constructor Detail
-
CoreDocumentImpl
public 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
public CoreDocumentImpl(DocumentType doctype)
For DOM2 support. The createDocument factory method is in DOMImplementation.- Parameters:
doctype- theDocumentType
-
-
Method Detail
-
getOwnerDocument
public final Document getOwnerDocument()
Description copied from class:ParentNodeFind the Document that this Node belongs to (the document in whose context the Node was created). The Node may or may not currently be part of that Document's actual contents. Find the Document that this Node belongs to (the document in whose context the Node was created). The Node may or may not currently be part of that Document's actual contents.- Specified by:
getOwnerDocumentin interfaceNode- Overrides:
getOwnerDocumentin classParentNode
-
getNodeType
public short getNodeType()
Returns the node type.- Specified by:
getNodeTypein interfaceNode- Specified by:
getNodeTypein classNodeImpl
-
getNodeName
public String getNodeName()
Returns the node name.- Specified by:
getNodeNamein interfaceNode- Specified by:
getNodeNamein classNodeImpl
-
cloneNode
public Node cloneNode(boolean deep)
Deep-clone a document, including fixing ownerDoc for the cloned children. Note that this requires bypassing the WRONG_DOCUMENT_ERR protection. I've chosen to implement it by calling importNode which is DOM Level 2.- Specified by:
cloneNodein interfaceNode- Overrides:
cloneNodein classParentNode- Parameters:
deep- boolean, iff true replicate children- Returns:
- org.w3c.dom.Node
- See Also:
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.
-
cloneNode
protected void cloneNode(CoreDocumentImpl newdoc, boolean deep)
-
insertBefore
public Node insertBefore(Node newChild, Node refChild) throws DOMException
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. Since appendChild() is implemented as insertBefore(,null), altering the latter fixes both.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
- Specified by:
insertBeforein interfaceNode- Overrides:
insertBeforein classParentNode- Parameters:
newChild- 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().- Returns:
- newChild, in its new state (relocated, or emptied in the case of DocumentNode.)
- Throws:
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.- See Also:
ParentNode
-
removeChild
public Node removeChild(Node oldChild) throws DOMException
Since insertBefore caches the docElement (and, currently, docType), removeChild has to know how to undo the cacheREVISIT: According to the spec it is not allowed to alter neither the document element nor the document type in any way
- Specified by:
removeChildin interfaceNode- Overrides:
removeChildin classParentNode- Returns:
- oldChild, in its new state (removed).
- Throws:
DOMException- NOT_FOUND_ERR if oldChild is not a child of this node.- See Also:
ParentNode
-
replaceChild
public Node replaceChild(Node newChild, Node oldChild) throws DOMException
Since we cache the docElement (and, currently, docType), replaceChild has to update the cacheREVISIT: According to the spec it is not allowed to alter neither the document element nor the document type in any way
- Specified by:
replaceChildin interfaceNode- Overrides:
replaceChildin classParentNode- Returns:
- oldChild, in its new state (removed).
- Throws:
DOMException- 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.- See Also:
ParentNode
-
getTextContent
public String getTextContent() throws DOMException
Description copied from class:NodeImplThis 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- Overrides:
getTextContentin classParentNode- Throws:
DOMException- DOMSTRING_SIZE_ERR: Raised when it would return more characters than fit in aDOMStringvariable on the implementation platform.
-
setTextContent
public void setTextContent(String textContent) throws DOMException
Description copied from class:NodeImplThis 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- Overrides:
setTextContentin classParentNode- Throws:
DOMException- DOMSTRING_SIZE_ERR: Raised when it would return more characters than fit in aDOMStringvariable on the implementation platform.
-
createAttribute
public Attr createAttribute(String name) throws DOMException
Factory method; creates an Attribute having this Document as its OwnerDoc.- Specified by:
createAttributein interfaceDocument- Parameters:
name- The name of the attribute. Note that the attribute's value is _not_ established at the factory; remember to set it!- Throws:
DOMException- INVALID_NAME_ERR if the attribute name is not acceptable.
-
createCDATASection
public CDATASection createCDATASection(String data) throws DOMException
Factory method; creates a CDATASection having this Document as its OwnerDoc.- Specified by:
createCDATASectionin interfaceDocument- Parameters:
data- The initial contents of the CDATA- Throws:
DOMException- NOT_SUPPORTED_ERR for HTML documents. (HTML not yet implemented.)
-
createComment
public Comment createComment(String data)
Factory method; creates a Comment having this Document as its OwnerDoc.- Specified by:
createCommentin interfaceDocument- Parameters:
data- The initial contents of the Comment.- Returns:
- comment
-
createDocumentFragment
public DocumentFragment createDocumentFragment()
Factory method; creates a DocumentFragment having this Document as its OwnerDoc.- Specified by:
createDocumentFragmentin interfaceDocument
-
createElement
public Element createElement(String tagName) throws DOMException
Factory method; creates an Element having this Document as its OwnerDoc.- Specified by:
createElementin interfaceDocument- Parameters:
tagName- 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.- Throws:
DOMException- INVALID_NAME_ERR if the tag name is not acceptable.
-
createEntityReference
public EntityReference createEntityReference(String name) throws DOMException
Factory method; creates an EntityReference having this Document as its OwnerDoc.- Specified by:
createEntityReferencein interfaceDocument- Parameters:
name- The name of the Entity we wish to refer to- Throws:
DOMException- NOT_SUPPORTED_ERR for HTML documents, where nonstandard entities are not permitted. (HTML not yet implemented.)
-
createProcessingInstruction
public ProcessingInstruction createProcessingInstruction(String target, String data) throws DOMException
Factory method; creates a ProcessingInstruction having this Document as its OwnerDoc.- Specified by:
createProcessingInstructionin interfaceDocument- Parameters:
target- The target "processor channel"data- Parameter string to be passed to the target.- Throws:
DOMException- INVALID_NAME_ERR if the target name is not acceptable.DOMException- NOT_SUPPORTED_ERR for HTML documents. (HTML not yet implemented.)
-
createTextNode
public Text createTextNode(String data)
Factory method; creates a Text node having this Document as its OwnerDoc.- Specified by:
createTextNodein interfaceDocument- Parameters:
data- The initial contents of the Text.- Returns:
- the text
-
getDoctype
public DocumentType getDoctype()
For XML, this provides access to the Document Type Definition. For HTML documents, and XML documents which don't specify a DTD, it will be null.- Specified by:
getDoctypein interfaceDocument
-
getDocumentElement
public Element getDocumentElement()
Convenience method, allowing direct access to the child node which is considered the root of the actual document content. For HTML, where it is legal to have more than one Element at the top level of the document, we pick the one with the tagName "HTML". For XML there should be only one top-level(HTML not yet supported.)
- Specified by:
getDocumentElementin interfaceDocument
-
getElementsByTagName
public NodeList getElementsByTagName(String tagname)
Return a live collection of all descendant Elements (not just immediate children) having the specified tag name.- Specified by:
getElementsByTagNamein interfaceDocument- Parameters:
tagname- The type of Element we want to gather. "*" will be taken as a wildcard, meaning "all elements in the document."- See Also:
DeepNodeListImpl
-
getImplementation
public DOMImplementation getImplementation()
Retrieve information describing the abilities of this particular DOM implementation. Intended to support applications that may be using DOMs retrieved from several different sources, potentially with different underlying representations.- Specified by:
getImplementationin interfaceDocument
-
setErrorChecking
public void setErrorChecking(boolean check)
Sets whether the DOM implementation performs error checking upon operations. Turning off error checking only affects the following DOM checks:- Checking strings to make sure that all characters are legal XML characters
- Hierarchy checking such as allowed children, checks for cycles, etc.
Turning off error checking does not turn off the following checks:
- Read only checks
- Checks related to DOM events
- Parameters:
check- check flag
-
setStrictErrorChecking
public void setStrictErrorChecking(boolean check)
- Specified by:
setStrictErrorCheckingin interfaceDocument
-
getErrorChecking
public boolean getErrorChecking()
- Returns:
- true if the DOM implementation performs error checking.
-
getStrictErrorChecking
public boolean getStrictErrorChecking()
- Specified by:
getStrictErrorCheckingin interfaceDocument
-
getInputEncoding
public String getInputEncoding()
DOM Level 3 CR - Experimental. (Was getActualEncoding)An attribute specifying the encoding used for this document at the time of the parsing. This is
nullwhen it is not known, such as when theDocumentwas created in memory.- Specified by:
getInputEncodingin interfaceDocument
-
setInputEncoding
public void setInputEncoding(String value)
DOM Internal (Was a DOM L3 Core WD public interface method setActualEncoding )An attribute specifying the actual encoding of this document. This is
nullotherwise.
This attribute represents the property [character encoding scheme] defined in.- Parameters:
value- the value
-
setXmlEncoding
public void setXmlEncoding(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. This is null when unspecified.
- Parameters:
value- the value
-
getXmlEncoding
public String getXmlEncoding()
DOM Level 3 WD - Experimental. The encoding of this document (part of XML Declaration)- Specified by:
getXmlEncodingin interfaceDocument
-
setXmlVersion
public void setXmlVersion(String value)
DOM Level 3 CR - Experimental. version - An attribute specifying, as part of the XML declaration, the version number of this document.- Specified by:
setXmlVersionin interfaceDocument
-
getXmlVersion
public String getXmlVersion()
DOM Level 3 WD - Experimental. The version of this document (part of XML Declaration)- Specified by:
getXmlVersionin interfaceDocument
-
setXmlStandalone
public void setXmlStandalone(boolean value) throws DOMExceptionDOM Level 3 CR - Experimental.Xmlstandalone - An attribute specifying, as part of the XML declaration, whether this document is standalone
- Specified by:
setXmlStandalonein interfaceDocument- Throws:
DOMException- NOT_SUPPORTED_ERR: Raised if this document does not support the "XML" feature.
-
getXmlStandalone
public boolean getXmlStandalone()
DOM Level 3 WD - Experimental. standalone that specifies whether this document is standalone (part of XML Declaration)- Specified by:
getXmlStandalonein interfaceDocument
-
getDocumentURI
public String getDocumentURI()
DOM Level 3 WD - Experimental. 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
-
canRenameElements
protected boolean canRenameElements(String newNamespaceURI, String newNodeName, ElementImpl el)
-
renameNode
public Node renameNode(Node n, String namespaceURI, String name) throws DOMException
DOM Level 3 WD - Experimental. Renaming node- Specified by:
renameNodein interfaceDocument- Throws:
DOMException
-
normalizeDocument
public void normalizeDocument()
DOM Level 3 WD - Experimental Normalize document.- Specified by:
normalizeDocumentin interfaceDocument
-
getDomConfig
public DOMConfiguration getDomConfig()
DOM Level 3 CR - ExperimentalThe configuration used when
Document.normalizeDocumentis invoked.- Specified by:
getDomConfigin interfaceDocument
-
getBaseURI
public String getBaseURI()
Returns the absolute base URI of this node or null if the implementation wasn't able to obtain an absolute URI. Note: If the URI is malformed, a null is returned.- Specified by:
getBaseURIin interfaceNode- Overrides:
getBaseURIin classNodeImpl- Returns:
- The absolute base URI of this node or null.
-
setDocumentURI
public void setDocumentURI(String documentURI)
DOM Level 3 WD - Experimental.- Specified by:
setDocumentURIin interfaceDocument
-
createDocumentType
public DocumentType createDocumentType(String qualifiedName, String publicID, String systemID) throws DOMException
NON-DOM Factory method; creates a DocumentType having this Document as its OwnerDoc. (REC-DOM-Level-1-19981001 left the process of building DTD information unspecified.)- Parameters:
qualifiedName- the namepublicID- the public idsystemID- the system id- Returns:
- the
DocumentType - Throws:
DOMException- NOT_SUPPORTED_ERR for HTML documents, where DTDs are not permitted. (HTML not yet implemented.)
-
createEntity
public Entity createEntity(String name) throws DOMException
NON-DOM Factory method; creates an Entity having this Document as its OwnerDoc. (REC-DOM-Level-1-19981001 left the process of building DTD information unspecified.)- Parameters:
name- The name of the Entity we wish to provide a value for.- Returns:
- the new entity
- Throws:
DOMException- NOT_SUPPORTED_ERR for HTML documents, where nonstandard entities are not permitted. (HTML not yet implemented.)
-
getNodeNumber
protected int getNodeNumber()
NON-DOM: Get the number associated with this document. Used to order documents in the implementation.- Overrides:
getNodeNumberin classNodeImpl- Returns:
- the node number
-
getNodeNumber
protected int getNodeNumber(Node node)
-
importNode
public Node importNode(Node source, boolean deep) throws DOMException
Copies a node from another document to this document. The new nodes are created using this document's factory methods and are populated with the data from the source's accessor methods defined by the DOM interfaces. Its behavior is otherwise similar to that of cloneNode.According to the DOM specifications, document nodes cannot be imported and a NOT_SUPPORTED_ERR exception is thrown if attempted.
- Specified by:
importNodein interfaceDocument- Throws:
DOMException
-
adoptNode
public Node adoptNode(Node source)
DOM Level 3 WD - Experimental Change the node's ownerDocument, and its subtree, to this Document- Specified by:
adoptNodein interfaceDocument- Parameters:
source- The node to adopt.- See Also:
importNode(org.w3c.dom.Node, boolean)
-
getElementById
public Element getElementById(String elementId)
Introduced in DOM Level 2 Returns the Element whose ID is given by elementId. If no such element exists, returns null. Behavior is not defined if more than one element has this ID.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.
- Specified by:
getElementByIdin interfaceDocument- See Also:
getIdentifier(java.lang.String)
-
clearIdentifiers
protected final void clearIdentifiers()
Remove all identifiers from the ID table
-
putIdentifier
public void putIdentifier(String idName, Element element)
Registers an identifier name with a specified element node. If the identifier is already registered, the new element node replaces the previous node. If the specified element node is null, removeIdentifier() is called.- Parameters:
idName- the nameelement- the element- See Also:
getIdentifier(String),removeIdentifier(String)
-
getIdentifier
public Element getIdentifier(String idName)
Returns a previously registered element with the specified identifier name, or null if no element is registered.- Parameters:
idName- the name- Returns:
- the element
- See Also:
putIdentifier(String, Element),removeIdentifier(String)
-
removeIdentifier
public void removeIdentifier(String idName)
Removes a previously registered element with the specified identifier name.- Parameters:
idName- the name- See Also:
putIdentifier(String, Element),getIdentifier(String)
-
createElementNS
public Element createElementNS(String namespaceURI, String qualifiedName) throws DOMException
Introduced in DOM Level 2.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].
- Specified by:
createElementNSin interfaceDocument- Parameters:
namespaceURI- The namespace URI of the element to create.qualifiedName- The qualified name of the element type to instantiate.- Returns:
- Element A new Element object with the following attributes:
- Throws:
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.
-
createElementNS
public Element createElementNS(String namespaceURI, String qualifiedName, String localpart) throws DOMException
NON-DOM: a factory method used by the Xerces DOM parser to create an element.- Parameters:
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.- Returns:
- Element A new Element object with the following attributes:
- Throws:
DOMException- INVALID_CHARACTER_ERR: Raised if the specified name contains an invalid character.
-
createAttributeNS
public Attr createAttributeNS(String namespaceURI, String qualifiedName) throws DOMException
Introduced in DOM Level 2.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].
- Specified by:
createAttributeNSin interfaceDocument- Parameters:
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.- Returns:
- Attr A new Attr object.
- Throws:
DOMException- INVALID_CHARACTER_ERR: Raised if the specified name contains an invalid character.
-
createAttributeNS
public Attr createAttributeNS(String namespaceURI, String qualifiedName, String localpart) throws DOMException
NON-DOM: a factory method used by the Xerces DOM parser to create an element.- Parameters:
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.- Returns:
- Attr A new Attr object.
- Throws:
DOMException- INVALID_CHARACTER_ERR: Raised if the specified name contains an invalid character.
-
getElementsByTagNameNS
public NodeList getElementsByTagNameNS(String namespaceURI, String localName)
Introduced in DOM Level 2.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.
- Specified by:
getElementsByTagNameNSin interfaceDocument- Parameters:
namespaceURI- 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.- Returns:
- NodeList A new NodeList object containing all the matched Elements.
-
clone
public Object clone() throws CloneNotSupportedException
Clone.- Overrides:
clonein classObject- Throws:
CloneNotSupportedException
-
isXMLName
public 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- Parameters:
s- the string to checkxml11Version- if true use xml 11 rules- Returns:
- true or false
-
isValidQName
public 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.- Parameters:
prefix- prefix of qualified namelocal- local part of qualified namexml11Version- if true use xml 11 rules- Returns:
- true or false
-
isKidOK
protected boolean isKidOK(Node parent, Node child)
Uses the kidOK lookup table to check whether the proposed tree structure is legal.- Parameters:
parent- the parentchild- the child- Returns:
- true or false
-
changed
protected void changed()
Denotes that this node has changed.
-
changes
protected int changes()
Returns the number of changes to this node.
-
checkNamespaceWF
protected final void checkNamespaceWF(String qname, int colon1, int colon2)
-
checkQName
protected final 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.- Parameters:
prefix- prefix of qualified namelocal- local part of qualified name
-
addEventListener
protected void addEventListener(NodeImpl node, String type, EventListener listener, boolean useCapture)
-
removeEventListener
protected void removeEventListener(NodeImpl node, String type, EventListener listener, boolean useCapture)
-
-