public class

HTMLDocumentImpl

extends DocumentImpl
implements HTMLDocument
java.lang.Object
   ↳ org.apache.xerces.dom.NodeImpl
     ↳ org.apache.xerces.dom.ChildNode
       ↳ org.apache.xerces.dom.ParentNode
         ↳ org.apache.xerces.dom.CoreDocumentImpl
           ↳ org.apache.xerces.dom.DocumentImpl
             ↳ org.apache.html.dom.HTMLDocumentImpl

Class Overview

Implements an HTML document. Provides access to the top level element in the document, its body and title.

Several methods create new nodes of all basic types (comment, text, element, etc.). These methods create new nodes but do not place them in the document tree. The nodes may be placed in the document tree using appendChild(Node) or insertBefore(Node, Node), or they may be placed in some other document tree.

Note: <FRAMESET> documents are not supported at the moment, neither are direct document writing (open(), write(String)) and HTTP attribute methods (getURL(), getCookie()).@xerces.internal

See Also
  • org.w3c.dom.html.HTMLDocument

Summary

[Expand]
Inherited Constants
From class org.apache.xerces.dom.NodeImpl
From interface org.w3c.dom.Node
[Expand]
Inherited Fields
From class org.apache.xerces.dom.DocumentImpl
From class org.apache.xerces.dom.CoreDocumentImpl
From class org.apache.xerces.dom.ParentNode
From class org.apache.xerces.dom.ChildNode
From class org.apache.xerces.dom.NodeImpl
Public Constructors
HTMLDocumentImpl()
Public Methods
Node cloneNode(boolean deep)
Deep-clone a document, including fixing ownerDoc for the cloned children.
void close()
Attr createAttribute(String name)
Creates an Attribute having this Document as its OwnerDoc.
Element createElement(String tagName)
Factory method; creates an Element having this Document as its OwnerDoc.
Element createElementNS(String namespaceURI, String qualifiedName)
Introduced in DOM Level 2.
Element createElementNS(String namespaceURI, String qualifiedName, String localpart)
Xerces-specific constructor.
HTMLCollection getAnchors()
HTMLCollection getApplets()
synchronized HTMLElement getBody()
String getCookie()
synchronized Element getDocumentElement()
Convenience method, allowing direct access to the child node which is considered the root of the actual document content.
String getDomain()
synchronized Element getElementById(String elementId)
Introduced in DOM Level 2 Returns the Element whose ID is given by elementId.
NodeList getElementsByName(String elementName)
final NodeList getElementsByTagName(String tagName)
Return a live collection of all descendent Elements (not just immediate children) having the specified tag name.
final NodeList getElementsByTagNameNS(String namespaceURI, String localName)
Introduced in DOM Level 2.
HTMLCollection getForms()
synchronized HTMLElement getHead()
Obtains the <HEAD> element in the document, creating one if does not exist before.
HTMLCollection getImages()
HTMLCollection getLinks()
String getReferrer()
synchronized String getTitle()
String getURL()
void open()
synchronized void setBody(HTMLElement newBody)
void setCookie(String cookie)
synchronized void setTitle(String newTitle)
void write(String text)
void writeln(String text)
[Expand]
Inherited Methods
From class org.apache.xerces.dom.DocumentImpl
From class org.apache.xerces.dom.CoreDocumentImpl
From class org.apache.xerces.dom.ParentNode
From class org.apache.xerces.dom.ChildNode
From class org.apache.xerces.dom.NodeImpl
From class java.lang.Object
From interface org.w3c.dom.Document
From interface org.w3c.dom.Node
From interface org.w3c.dom.NodeList
From interface org.w3c.dom.events.DocumentEvent
From interface org.w3c.dom.events.EventTarget
From interface org.w3c.dom.html.HTMLDocument
From interface org.w3c.dom.ranges.DocumentRange
From interface org.w3c.dom.traversal.DocumentTraversal

Public Constructors

public HTMLDocumentImpl ()

Public Methods

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.

Parameters
deep boolean, iff true replicate children
Returns
  • org.w3c.dom.Node

public void close ()

public Attr createAttribute (String name)

Creates an Attribute having this Document as its OwnerDoc. Overrides createAttribute(String) and returns and attribute whose name is lower case.

Parameters
name The name of the attribute
Returns
  • An attribute whose name is all lower case
Throws
if the attribute name is not acceptable
DOMException

public Element createElement (String tagName)

Factory method; creates an Element having this Document as its OwnerDoc.

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

public Element createElementNS (String namespaceURI, String qualifiedName)

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

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:

public Element createElementNS (String namespaceURI, String qualifiedName, String localpart)

Xerces-specific constructor. "localName" is passed in, so we don't need to create a new String for it.

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

public HTMLCollection getAnchors ()

public HTMLCollection getApplets ()

public synchronized HTMLElement getBody ()

public String getCookie ()

public synchronized 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.)

public String getDomain ()

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

public NodeList getElementsByName (String elementName)

public final NodeList getElementsByTagName (String tagName)

Return a live collection of all descendent Elements (not just immediate children) having the specified tag name.

Parameters
tagName The type of Element we want to gather. "*" will be taken as a wildcard, meaning "all elements in the document."

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

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.

public HTMLCollection getForms ()

public synchronized HTMLElement getHead ()

Obtains the <HEAD> element in the document, creating one if does not exist before. The <HEAD> element is the first element in the <HTML> in the document. The <HTML> element is obtained by calling getDocumentElement(). If the element does not exist, one is created.

Called by getTitle(), setTitle(String), getBody() and setBody(HTMLElement) to assure the document has the <HEAD> element correctly placed.

Returns
  • The <HEAD> element

public HTMLCollection getImages ()

public HTMLCollection getLinks ()

public String getReferrer ()

public synchronized String getTitle ()

public String getURL ()

public void open ()

public synchronized void setBody (HTMLElement newBody)

public void setCookie (String cookie)

public synchronized void setTitle (String newTitle)

public void write (String text)

public void writeln (String text)