Top Description Fields Constructors Methods
org.apache.xerces.dom

public Class DocumentTypeImpl

extends ParentNode
implements DocumentType
Class Inheritance
All Implemented Interfaces
org.w3c.dom.DocumentType, org.w3c.dom.Node
Known Direct Subclasses
org.apache.xerces.dom.DeferredDocumentTypeImpl
Imports
java.util.Hashtable, org.w3c.dom.DOMException, .DocumentType, .NamedNodeMap, .Node, .UserDataHandler

This class represents a Document Type declaraction in the document itself, not a Document Type Definition (DTD). An XML document may (or may not) have such a reference.

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.

Authors
Arnaud Le Hors, IBM, Joe Kesselman, IBM, Andy Clark, IBM
Since
PR-DOM-Level-1-19980818.
Version
$Id: DocumentTypeImpl.java 699892 2008-09-28 21:08:27Z mrglavas $

Field Summary

Modifier and TypeField and Description
private int
doctypeNumber

The following are required for compareDocumentPosition

protected NamedNodeMapImpl
elements

Elements.

protected NamedNodeMapImpl
entities

Entities.

protected String
protected String
name

Document type name.

protected NamedNodeMapImpl
notations

Notations.

protected String
pack-priv static final long
protected String
private Hashtable<K, V>
Inherited from org.apache.xerces.dom.ParentNode:
firstChildfNodeListCacheownerDocument

Constructor Summary

AccessConstructor and Description
public
DocumentTypeImpl(CoreDocumentImpl ownerDocument, String name)

Factory method for creating a document type node.

public
DocumentTypeImpl(CoreDocumentImpl ownerDocument, String qualifiedName, String publicID, String systemID)

Factory method for creating a document type node.

Method Summary

Modifier and TypeMethod and Description
public Node
cloneNode(boolean
If true, recursively clone the subtree under the specified node; if false, clone only the node itself (and its attributes, if it is an Element).
deep
)

Overrides org.apache.xerces.dom.ParentNode.cloneNode.

Implements org.w3c.dom.Node.cloneNode.

Clones the node.
public NamedNodeMap
getElements()

NON-DOM: Access the collection of ElementDefinitions.

public NamedNodeMap
getEntities()

Implements org.w3c.dom.DocumentType.getEntities.

Access the collection of general Entities, both external and internal, defined in the DTD.
public String
getInternalSubset()

Implements org.w3c.dom.DocumentType.getInternalSubset.

Introduced in DOM Level 2.
public String
getName()

Implements org.w3c.dom.DocumentType.getName.

Name of this document type.
public String
getNodeName()

Implements abstract org.apache.xerces.dom.NodeImpl.getNodeName.

Implements org.w3c.dom.Node.getNodeName.

Returns the document type name
protected int
getNodeNumber()

Overrides org.apache.xerces.dom.NodeImpl.getNodeNumber.

NON-DOM Get the number associated with this doctype.
public short
getNodeType()

Implements abstract org.apache.xerces.dom.NodeImpl.getNodeType.

Implements org.w3c.dom.Node.getNodeType.

A short integer indicating what type of node this is.
public NamedNodeMap
getNotations()

Implements org.w3c.dom.DocumentType.getNotations.

Access the collection of Notations defined in the DTD.
public String
getPublicId()

Implements org.w3c.dom.DocumentType.getPublicId.

Introduced in DOM Level 2.
public String
getSystemId()

Implements org.w3c.dom.DocumentType.getSystemId.

Introduced in DOM Level 2.
public String
getTextContent()

Overrides org.apache.xerces.dom.ParentNode.getTextContent.

Implements org.w3c.dom.Node.getTextContent.

This attribute returns the text content of this node and its descendants.
public Object
getUserData(String
The key the object is associated to.
key
)

Overrides org.apache.xerces.dom.NodeImpl.getUserData.

Implements org.w3c.dom.Node.getUserData.

Retrieves the object associated to a key on a this node.
protected Hashtable<K, V>
public boolean
isEqualNode(Node
The node to compare equality with.
arg
)

Overrides org.apache.xerces.dom.ParentNode.isEqualNode.

Implements org.w3c.dom.Node.isEqualNode.

DOM Level 3 WD- Experimental.
public void
setInternalSubset(String internalSubset)

NON-DOM.

protected void
setOwnerDocument(CoreDocumentImpl doc)

Overrides org.apache.xerces.dom.ParentNode.setOwnerDocument.

NON-DOM set the ownerDocument of this node and its children
public void
setReadOnly(boolean
True or false as desired.
readOnly
,
boolean
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.
deep
)

Overrides org.apache.xerces.dom.ParentNode.setReadOnly.

NON-DOM: Subclassed to flip the entities' and notations' readonly switch as well.
public void
setTextContent(String textContent)

Overrides org.apache.xerces.dom.ParentNode.setTextContent.

Implements org.w3c.dom.Node.setTextContent.

This attribute returns the text content of this node and its descendants.
public Object
setUserData(String
The key to associate the object to.
key
,
Object
The object to associate to the given key, or null to remove any existing association to that key.
data
,
UserDataHandler
The handler to associate to that key, or null.
handler
)

Overrides org.apache.xerces.dom.NodeImpl.setUserData.

Implements org.w3c.dom.Node.setUserData.

Associate an object to a key on this node.
Inherited from org.apache.xerces.dom.ParentNode:
checkNormalizationAfterInsertcheckNormalizationAfterRemovegetChildNodesgetChildNodesUnoptimizedgetFirstChildgetLastChildgetLengthgetOwnerDocumentgetTextContenthasChildNodeshasTextContentinsertBeforeinternalInsertBeforeinternalRemoveChilditemlastChildlastChildnormalizeownerDocumentremoveChildreplaceChildsynchronizeChildren

Field Detail

doctypeNumberback to summary
private int doctypeNumber

The following are required for compareDocumentPosition

elementsback to summary
protected NamedNodeMapImpl elements

Elements.

entitiesback to summary
protected NamedNodeMapImpl entities

Entities.

internalSubsetback to summary
protected String internalSubset
nameback to summary
protected String name

Document type name.

notationsback to summary
protected NamedNodeMapImpl notations

Notations.

publicIDback to summary
protected String publicID
serialVersionUIDback to summary
pack-priv static final long serialVersionUID

Hides org.apache.xerces.dom.ParentNode.serialVersionUID.

Serialization version.

systemIDback to summary
protected String systemID
userDataback to summary
private Hashtable<K, V> userData

Constructor Detail

DocumentTypeImplback to summary
public DocumentTypeImpl(CoreDocumentImpl ownerDocument, String name)

Factory method for creating a document type node.

DocumentTypeImplback to summary
public DocumentTypeImpl(CoreDocumentImpl ownerDocument, String qualifiedName, String publicID, String systemID)

Factory method for creating a document type node.

Method Detail

cloneNodeback to summary
public Node cloneNode(boolean deep)

Overrides org.apache.xerces.dom.ParentNode.cloneNode.

Implements org.w3c.dom.Node.cloneNode.

Clones the node.

Parameters
deep:boolean

Doc from org.w3c.dom.Node.cloneNode.

If true, recursively clone the subtree under the specified node; if false, clone only the node itself (and its attributes, if it is an Element).

Returns:Node

Doc from org.w3c.dom.Node.cloneNode.

The duplicate node.

getElementsback to summary
public NamedNodeMap getElements()

NON-DOM: Access the collection of ElementDefinitions.

See Also
ElementDefinitionImpl
getEntitiesback to summary
public NamedNodeMap getEntities()

Implements org.w3c.dom.DocumentType.getEntities.

Access the collection of general Entities, both external and internal, defined in the DTD. For example, in:

  <!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.

getInternalSubsetback to summary
public String getInternalSubset()

Implements org.w3c.dom.DocumentType.getInternalSubset.

Introduced in DOM Level 2.

Return the internalSubset given as a string.

Since
WD-DOM-Level-2-19990923
getNameback to summary
public String getName()

Implements org.w3c.dom.DocumentType.getName.

Name of this document type. If we loaded from a DTD, this should be the name immediately following the DOCTYPE keyword.

getNodeNameback to summary
public String getNodeName()

Implements abstract org.apache.xerces.dom.NodeImpl.getNodeName.

Implements org.w3c.dom.Node.getNodeName.

Returns the document type name

getNodeNumberback to summary
protected int getNodeNumber()

Overrides org.apache.xerces.dom.NodeImpl.getNodeNumber.

NON-DOM Get the number associated with this doctype.

getNodeTypeback to summary
public short getNodeType()

Implements abstract org.apache.xerces.dom.NodeImpl.getNodeType.

Implements org.w3c.dom.Node.getNodeType.

A short integer indicating what type of node this is. The named constants for this value are defined in the org.w3c.dom.Node interface.

getNotationsback to summary
public NamedNodeMap getNotations()

Implements org.w3c.dom.DocumentType.getNotations.

Access the collection of Notations defined in the DTD. A notation declares, by name, the format of an XML unparsed entity or is used to formally declare a Processing Instruction target.

getPublicIdback to summary
public String getPublicId()

Implements org.w3c.dom.DocumentType.getPublicId.

Introduced in DOM Level 2.

Return the public identifier of this Document type.

Since
WD-DOM-Level-2-19990923
getSystemIdback to summary
public String getSystemId()

Implements org.w3c.dom.DocumentType.getSystemId.

Introduced in DOM Level 2.

Return the system identifier of this Document type.

Since
WD-DOM-Level-2-19990923
getTextContentback to summary
public String getTextContent() throws DOMException

Overrides org.apache.xerces.dom.ParentNode.getTextContent.

Implements org.w3c.dom.Node.getTextContent.

Doc from org.w3c.dom.Node.getTextContent.

This attribute returns the text content of this node and its descendants. When it is defined to be null, setting it has no effect. On setting, any possible children this node may have are removed and, if it the new string is not empty or null, replaced by a single 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 and the returned string does not contain the white spaces in element content (see the attribute Text.isElementContentWhitespace). 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/Content table
Node type Content
ELEMENT_NODE, ATTRIBUTE_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. This is the empty string if the node has no children.
TEXT_NODE, CDATA_SECTION_NODE, COMMENT_NODE, PROCESSING_INSTRUCTION_NODE nodeValue
DOCUMENT_NODE, DOCUMENT_TYPE_NODE, NOTATION_NODE null
Exceptions
DOMException:
DOMSTRING_SIZE_ERR: Raised when it would return more characters than fit in a DOMString variable on the implementation platform.
getUserDataback to summary
public Object getUserData(String key)

Overrides org.apache.xerces.dom.NodeImpl.getUserData.

Implements org.w3c.dom.Node.getUserData.

Doc from org.w3c.dom.Node.getUserData.

Retrieves the object associated to a key on a this node. The object must first have been set to this node by calling setUserData with the same key.

Parameters
key:String

The key the object is associated to.

Returns:Object

Returns the DOMUserData associated to the given key on this node, or null if there was none.

getUserDataRecordback to summary
protected Hashtable<K, V> getUserDataRecord()

Overrides org.apache.xerces.dom.NodeImpl.getUserDataRecord.

isEqualNodeback to summary
public boolean isEqualNode(Node arg)

Overrides org.apache.xerces.dom.ParentNode.isEqualNode.

Implements org.w3c.dom.Node.isEqualNode.

DOM Level 3 WD- Experimental. Override inherited behavior from ParentNodeImpl to support deep equal.

Parameters
arg:Node

Doc from org.w3c.dom.Node.isEqualNode.

The node to compare equality with.

Returns:boolean

Doc from org.w3c.dom.Node.isEqualNode.

Returns true if the nodes are equal, false otherwise.

setInternalSubsetback to summary
public void setInternalSubset(String internalSubset)

NON-DOM.

Set the internalSubset given as a string.

setOwnerDocumentback to summary
protected void setOwnerDocument(CoreDocumentImpl doc)

Overrides org.apache.xerces.dom.ParentNode.setOwnerDocument.

NON-DOM set the ownerDocument of this node and its children

setReadOnlyback to summary
public void setReadOnly(boolean readOnly, boolean deep)

Overrides org.apache.xerces.dom.ParentNode.setReadOnly.

NON-DOM: Subclassed to flip the entities' and notations' readonly switch as well.

Parameters
readOnly:boolean

Doc from org.apache.xerces.dom.NodeImpl.setReadOnly.

True or false as desired.

deep:boolean

Doc from org.apache.xerces.dom.NodeImpl.setReadOnly.

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.

See Also
NodeImpl#setReadOnly
setTextContentback to summary
public void setTextContent(String textContent) throws DOMException

Overrides org.apache.xerces.dom.ParentNode.setTextContent.

Implements org.w3c.dom.Node.setTextContent.

Doc from org.w3c.dom.Node.setTextContent.

This attribute returns the text content of this node and its descendants. When it is defined to be null, setting it has no effect. On setting, any possible children this node may have are removed and, if it the new string is not empty or null, replaced by a single 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 and the returned string does not contain the white spaces in element content (see the attribute Text.isElementContentWhitespace). 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/Content table
Node type Content
ELEMENT_NODE, ATTRIBUTE_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. This is the empty string if the node has no children.
TEXT_NODE, CDATA_SECTION_NODE, COMMENT_NODE, PROCESSING_INSTRUCTION_NODE nodeValue
DOCUMENT_NODE, DOCUMENT_TYPE_NODE, NOTATION_NODE null
Exceptions
DOMException:
NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.
setUserDataback to summary
public Object setUserData(String key, Object data, UserDataHandler handler)

Overrides org.apache.xerces.dom.NodeImpl.setUserData.

Implements org.w3c.dom.Node.setUserData.

Doc from org.w3c.dom.Node.setUserData.

Associate an object to a key on this node. The object can later be retrieved from this node by calling getUserData with the same key.

Parameters
key:String

The key to associate the object to.

data:Object

The object to associate to the given key, or null to remove any existing association to that key.

handler:UserDataHandler

The handler to associate to that key, or null.

Returns:Object

Returns the DOMUserData previously associated to the given key on this node, or null if there was none.