Class DocumentTypeImpl

All Implemented Interfaces:
Cloneable, DocumentType, EventTarget, Node, NodeList

public class DocumentTypeImpl extends ParentNode implements DocumentType
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.

Author:
Arnaud Le Hors, IBM, Joe Kesselman, IBM, Andy Clark, IBM
  • Constructor Details

    • DocumentTypeImpl

      public DocumentTypeImpl(CoreDocumentImpl ownerDocument, String name)
      Factory method for creating a document type node.
      Parameters:
      ownerDocument - the owner document
      name - the name
    • DocumentTypeImpl

      public DocumentTypeImpl(CoreDocumentImpl ownerDocument, String qualifiedName, String publicID, String systemID)
  • Method Details

    • getPublicId

      public String getPublicId()
      Introduced in DOM Level 2.

      Return the public identifier of this Document type.

      Specified by:
      getPublicId in interface DocumentType
    • getSystemId

      public String getSystemId()
      Introduced in DOM Level 2.

      Return the system identifier of this Document type.

      Specified by:
      getSystemId in interface DocumentType
    • setInternalSubset

      public void setInternalSubset(String internalSubset)
    • getInternalSubset

      public String getInternalSubset()
      Introduced in DOM Level 2.

      Return the internalSubset given as a string.

      Specified by:
      getInternalSubset in interface DocumentType
    • getNodeType

      public short 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. 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.
      Specified by:
      getNodeType in interface Node
      Specified by:
      getNodeType in class NodeImpl
    • getNodeName

      public String getNodeName()
      Returns the name of this node.
      Specified by:
      getNodeName in interface Node
      Specified by:
      getNodeName in class NodeImpl
    • cloneNode

      public Node cloneNode(boolean deep)
      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.

      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.
      Specified by:
      cloneNode in interface Node
      Overrides:
      cloneNode in class ParentNode
      Parameters:
      deep - whether to recursively clone all children in the subtree
      Returns:
      the cloned node
      See Also:
    • getTextContent

      public String getTextContent() throws DOMException
      Get Node text content
      Specified by:
      getTextContent in interface Node
      Overrides:
      getTextContent in class ParentNode
      Throws:
      DOMException
    • setTextContent

      public void setTextContent(String textContent) throws DOMException
      Set Node text content
      Specified by:
      setTextContent in interface Node
      Overrides:
      setTextContent in class ParentNode
      Throws:
      DOMException
    • isEqualNode

      public boolean isEqualNode(Node arg)
      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.
      Specified by:
      isEqualNode in interface Node
      Overrides:
      isEqualNode in class ParentNode
    • setOwnerDocument

      protected void setOwnerDocument(CoreDocumentImpl doc)
      NON-DOM set the ownerDocument of this node and its children NON-DOM set the ownerDocument of this node and its children
      Overrides:
      setOwnerDocument in class ParentNode
    • getNodeNumber

      protected int getNodeNumber()
      Returns the node number. NON-DOM Get the number associated with this doctype.
      Overrides:
      getNodeNumber in class NodeImpl
      Returns:
      the node number
    • getName

      public String getName()
      Name of this document type. If we loaded from a DTD, this should be the name immediately following the DOCTYPE keyword.
      Specified by:
      getName in interface DocumentType
    • getEntities

      public NamedNodeMap 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.

      Specified by:
      getEntities in interface DocumentType
    • getNotations

      public NamedNodeMap 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.
      Specified by:
      getNotations in interface DocumentType
    • getElements

      public NamedNodeMap getElements()
    • setUserData

      public Object setUserData(String key, Object data, UserDataHandler handler)
      Specified by:
      setUserData in interface Node
      Overrides:
      setUserData in class NodeImpl
    • getUserData

      public Object getUserData(String key)
      Specified by:
      getUserData in interface Node
      Overrides:
      getUserData in class NodeImpl