public class DocumentTypeImpl extends ParentNode implements DocumentType
DocumentType is an Extended DOM feature, used in XML documents but not in HTML.
Note that Entities and Notations are no longer children of the DocumentType, but are parentless nodes hung only in their appropriate NamedNodeMaps.
This area is UNDERSPECIFIED IN REC-DOM-Level-1-19981001 Most notably, absolutely no provision was made for storing and using Element and Attribute information. Nor was the linkage between Entities and Entity References nailed down solidly.
| Modifier and Type | Field and Description |
|---|---|
protected NamedNodeMapImpl |
elements
Elements.
|
protected NamedNodeMapImpl |
entities
Entities.
|
protected String |
internalSubset |
protected String |
name
Document type name.
|
protected NamedNodeMapImpl |
notations
Notations.
|
protected String |
publicID |
protected String |
systemID |
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 |
|---|
DocumentTypeImpl(CoreDocumentImpl ownerDocument,
String name)
Factory method for creating a document type node.
|
DocumentTypeImpl(CoreDocumentImpl ownerDocument,
String qualifiedName,
String publicID,
String systemID) |
| Modifier and Type | Method and Description |
|---|---|
Node |
cloneNode(boolean deep)
Returns a duplicate of a given node.
|
NamedNodeMap |
getElements() |
NamedNodeMap |
getEntities()
Access the collection of general Entities, both external and
internal, defined in the DTD.
|
String |
getInternalSubset()
Introduced in DOM Level 2.
|
String |
getName()
Name of this document type.
|
String |
getNodeName()
the name of this node.
|
protected int |
getNodeNumber()
NON-DOM
Get the number associated with this doctype.
|
short |
getNodeType()
A short integer indicating what type of node this is.
|
NamedNodeMap |
getNotations()
Access the collection of Notations defined in the DTD.
|
String |
getPublicId()
Introduced in DOM Level 2.
|
String |
getSystemId()
Introduced in DOM Level 2.
|
String |
getTextContent()
This attribute returns the text content of this node and its
descendants.
|
Object |
getUserData(String key)
Retrieves the object associated to a key on a this node.
|
protected Hashtable<String,net.sourceforge.htmlunit.xerces.dom.ParentNode.UserDataRecord> |
getUserDataRecord() |
boolean |
isEqualNode(Node arg)
Tests whether two nodes are equal.
|
void |
setInternalSubset(String internalSubset) |
protected void |
setOwnerDocument(CoreDocumentImpl doc)
NON-DOM set the ownerDocument of this node and its children
|
void |
setReadOnly(boolean readOnly,
boolean deep)
NON-DOM: PR-DOM-Level-1-19980818 mentions readonly nodes in conjunction
with Entities, but provides no API to support this.
|
void |
setTextContent(String textContent)
This attribute returns the text content of this node and its
descendants.
|
Object |
setUserData(String key,
Object data,
UserDataHandler handler)
Associate an object to a key on this node.
|
getChildNodes, getChildNodesUnoptimized, getFirstChild, getLastChild, getLength, getOwnerDocument, hasChildNodes, insertBefore, item, removeChild, replaceChild, synchronizeChildrengetNextSibling, getParentNode, getPreviousSiblingaddEventListener, appendChild, changed, changes, compareDocumentPosition, dispatchEvent, getAttributes, getBaseURI, getFeature, getLocalName, getNamespaceURI, getNodeValue, getPrefix, getReadOnly, getUserData, hasAttributes, isDefaultNamespace, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, needsSyncChildren, normalize, removeEventListener, setNodeValue, setPrefix, setUserData, synchronizeData, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitappendChild, compareDocumentPosition, getAttributes, getBaseURI, getChildNodes, getFeature, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNodeValue, getOwnerDocument, getParentNode, getPrefix, getPreviousSibling, hasAttributes, hasChildNodes, insertBefore, isDefaultNamespace, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, normalize, removeChild, replaceChild, setNodeValue, setPrefixprotected final String name
protected NamedNodeMapImpl entities
protected NamedNodeMapImpl notations
protected NamedNodeMapImpl elements
protected String publicID
protected String systemID
protected String internalSubset
public DocumentTypeImpl(CoreDocumentImpl ownerDocument, String name)
ownerDocument - the owner documentname - the namepublic DocumentTypeImpl(CoreDocumentImpl ownerDocument, String qualifiedName, String publicID, String systemID)
public String getPublicId()
Return the public identifier of this Document type.
getPublicId in interface DocumentTypepublic String getSystemId()
Return the system identifier of this Document type.
getSystemId in interface DocumentTypepublic void setInternalSubset(String internalSubset)
public String getInternalSubset()
Return the internalSubset given as a string.
getInternalSubset in interface DocumentTypepublic short getNodeType()
getNodeType in interface NodegetNodeType in class NodeImplpublic String getNodeName()
getNodeName in interface NodegetNodeName in class NodeImplpublic Node cloneNode(boolean deep)
Note: since we never have any children deep is meaningless here, ParentNode overrides this behavior. Returns a duplicate of a given node. You can consider this a generic "copy constructor" for nodes. The newly returned object should be completely independent of the source object's subtree, so changes in one after the clone has been made will not affect the other.
Note: since we never have any children deep is meaningless here, ParentNode overrides this behavior. Returns a duplicate of a given node. You can consider this a generic "copy constructor" for nodes. The newly returned object should be completely independent of the source object's subtree, so changes in one after the clone has been made will not affect the other.
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. Clones the node.
cloneNode in interface NodecloneNode in class ParentNode
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.
public String getTextContent() throws DOMException
Text 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
Text 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 boolean isEqualNode(Node arg)
Node.isSameNode. All nodes that are the same
will also be equal, though the reverse may not be true.
nodeName, localName,
namespaceURI, prefix, nodeValue
, baseURI. This is: they are both null, or
they have the same length and are character for character identical.
The attributes NamedNodeMaps are equal.
This is: they are both null, or they have the same
length and for each node that exists in one map there is a node that
exists in the other map and is equal, although not necessarily at the
same index.The childNodes NodeLists are
equal. This is: they are both null, or they have the
same length and contain equal nodes at the same index. This is true
for Attr nodes as for any other type of node. Note that
normalization can affect equality; to avoid this, nodes should be
normalized before being compared.
DocumentType nodes to be equal, the following
conditions must also be satisfied: The following string attributes
are equal: publicId, systemId,
internalSubset.The entities
NamedNodeMaps are equal.The notations
NamedNodeMaps are equal.
ownerDocument attribute, the specified
attribute for Attr nodes, the
isWhitespaceInElementContent attribute for
Text nodes, as well as any user data or event listeners
registered on the nodes.
DOM Level 3 WD- Experimental.
Override inherited behavior from NodeImpl to support deep equal.
DOM Level 3 WD- Experimental.
Override inherited behavior from ParentNodeImpl to support deep equal.isEqualNode in interface NodeisEqualNode in class ParentNodearg - The node to compare equality with.true otherwise false.protected void setOwnerDocument(CoreDocumentImpl doc)
setOwnerDocument in class ParentNodeprotected int getNodeNumber()
getNodeNumber in class NodeImplpublic String getName()
getName in interface DocumentTypepublic NamedNodeMap getEntities()
<!doctype example SYSTEM "ex.dtd" [
<!ENTITY foo "foo">
<!ENTITY bar "bar">
<!ENTITY % baz "baz">
]>
The Entities map includes foo and bar, but not baz. It is promised that only Nodes which are Entities will exist in this NamedNodeMap.
For HTML, this will always be null.
Note that "built in" entities such as & and < should be converted to their actual characters before being placed in the DOM's contained text, and should be converted back when the DOM is rendered as XML or HTML, and hence DO NOT appear here.
getEntities in interface DocumentTypepublic NamedNodeMap getNotations()
getNotations in interface DocumentTypepublic void setReadOnly(boolean readOnly,
boolean deep)
Most DOM users should not touch this method. Its anticpated use is during construction of EntityRefernces, where it will be used to lock the contents replicated from Entity so they can't be casually altered. It _could_ be published as a DOM extension, if desired.
Note: since we never have any children deep is meaningless here, ParentNode overrides this behavior. Override default behavior so that if deep is true, children are also toggled. NON-DOM: Subclassed to flip the entities' and notations' readonly switch as well.
setReadOnly in class ParentNodereadOnly - True or false as desired.deep - If true, children are also toggled. Note that this will
not change the state of an EntityReference or its children,
which are always read-only.NodeImpl.setReadOnly(boolean, boolean)public NamedNodeMap getElements()
public Object setUserData(String key, Object data, UserDataHandler handler)
getUserData with the
same key.setUserData in interface NodesetUserData in class NodeImplkey - 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 Object getUserData(String key)
setUserData with the same key.getUserData in interface NodegetUserData in class NodeImplkey - 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()
getUserDataRecord in class NodeImplCopyright © 2023 Gargoyle Software Inc.. All rights reserved.