Class HTMLDocumentImpl
- All Implemented Interfaces:
Serializable,Cloneable,Document,DocumentEvent,EventTarget,HTMLDocument,Node,NodeList,DocumentRange,DocumentTraversal
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 Node.appendChild(org.w3c.dom.Node) or Node.insertBefore(org.w3c.dom.Node, org.w3c.dom.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(java.lang.String)) and HTTP attribute
methods (getURL(), getCookie()).
INTERNAL:
- Usage of this class is not supported. It may be altered or removed at any time.
- Version:
- $Revision: 1029415 $ $Date: 2010-10-31 22:32:22 +0530 (Sun, 31 Oct 2010) $
- Author:
- Assaf Arkin
- See Also:
-
Field Summary
Fields inherited from class org.apache.xerces.dom.DocumentImpl
eventListeners, iteratorReferenceQueue, iterators, mutationEvents, rangeReferenceQueue, rangesFields inherited from class org.apache.xerces.dom.CoreDocumentImpl
actualEncoding, allowGrammarAccess, changes, docElement, docType, encoding, errorChecking, fDocumentURI, identifiers, standalone, userData, version, xmlVersionChangedFields inherited from class org.apache.xerces.dom.ParentNode
firstChild, fNodeListCache, ownerDocumentFields inherited from class org.apache.xerces.dom.ChildNode
nextSibling, previousSiblingFields inherited from class org.apache.xerces.dom.NodeImpl
DOCUMENT_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, SYNCDATA, TREE_POSITION_ANCESTOR, TREE_POSITION_DESCENDANT, TREE_POSITION_DISCONNECTED, TREE_POSITION_EQUIVALENT, TREE_POSITION_FOLLOWING, TREE_POSITION_PRECEDING, TREE_POSITION_SAME_NODEFields 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 -
Method Summary
Modifier and TypeMethodDescriptionprotected booleancanRenameElements(String newNamespaceURI, String newNodeName, org.apache.xerces.dom.ElementImpl el) cloneNode(boolean deep) Deep-clone a document, including fixing ownerDoc for the cloned children.voidclose()createAttribute(String name) Creates an Attribute having this Document as its OwnerDoc.createElement(String tagName) Factory method; creates an Element having this Document as its OwnerDoc.createElementNS(String namespaceURI, String qualifiedName) Introduced in DOM Level 2.createElementNS(String namespaceURI, String qualifiedName, String localpart) Xerces-specific constructor.getBody()Convenience method, allowing direct access to the child node which is considered the root of the actual document content.getElementById(String elementId) Introduced in DOM Level 2 Returns the Element whose ID is given by elementId.getElementsByName(String elementName) final NodeListgetElementsByTagName(String tagName) Return a live collection of all descendent Elements (not just immediate children) having the specified tag name.final NodeListgetElementsByTagNameNS(String namespaceURI, String localName) Introduced in DOM Level 2.getForms()getHead()Obtains the <HEAD> element in the document, creating one if does not exist before.getLinks()getTitle()getURL()voidopen()voidsetBody(HTMLElement newBody) voidvoidvoidvoidMethods inherited from class org.apache.xerces.dom.DocumentImpl
addEventListener, copyEventListeners, createEvent, createNodeIterator, createNodeIterator, createRange, createTreeWalker, createTreeWalker, dispatchAggregateEvents, dispatchAggregateEvents, dispatchEvent, dispatchEventToSubtree, dispatchingEventToSubtree, getEventListeners, getImplementation, removeEventListener, saveEnclosingAttr, setEventListenersMethods inherited from class org.apache.xerces.dom.CoreDocumentImpl
abort, adoptNode, callUserDataHandlers, changed, changes, checkDOMNSErr, checkNamespaceWF, checkQName, clearIdentifiers, clone, cloneNode, createAttributeNS, createAttributeNS, createCDATASection, createComment, createDocumentFragment, createDocumentType, createElementDefinition, createEntity, createEntityReference, createNotation, createProcessingInstruction, createTextNode, getAsync, getBaseURI, getDoctype, getDocumentURI, getDomConfig, getEncoding, getErrorChecking, getFeature, getIdentifier, getIdentifiers, getInputEncoding, getNodeName, getNodeNumber, getNodeNumber, getNodeType, getOwnerDocument, getStandalone, getStrictErrorChecking, getTextContent, getUserData, getUserData, getUserDataRecord, getVersion, getXmlEncoding, getXmlStandalone, getXmlVersion, importNode, insertBefore, isKidOK, isValidQName, isXMLName, load, loadXML, normalizeDocument, putIdentifier, removeChild, removeIdentifier, renameNode, replaceChild, saveXML, setAsync, setDocumentURI, setEncoding, setErrorChecking, setInputEncoding, setStandalone, setStrictErrorChecking, setTextContent, setUserData, setUserData, setVersion, setXmlEncoding, setXmlStandalone, setXmlVersion, undeferChildrenMethods inherited from class org.apache.xerces.dom.ParentNode
getChildNodes, getChildNodesUnoptimized, getFirstChild, getLastChild, getLength, hasChildNodes, isEqualNode, item, normalize, setOwnerDocument, setReadOnly, synchronizeChildrenMethods inherited from class org.apache.xerces.dom.ChildNode
getNextSibling, getParentNode, getPreviousSiblingMethods inherited from class org.apache.xerces.dom.NodeImpl
addEventListener, appendChild, compareDocumentPosition, compareTreePosition, dispatchEvent, getAttributes, getContainer, getLocalName, getNamespaceURI, getNodeValue, getPrefix, getReadOnly, getUserData, getUserData, getUserDataRecord, hasAttributes, isDefaultNamespace, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, needsSyncChildren, removeEventListener, setNodeValue, setPrefix, setUserData, setUserData, synchronizeData, toStringMethods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.w3c.dom.Document
adoptNode, createAttributeNS, createCDATASection, createComment, createDocumentFragment, createEntityReference, createProcessingInstruction, createTextNode, getDoctype, getDocumentURI, getDomConfig, getImplementation, getInputEncoding, getStrictErrorChecking, getXmlEncoding, getXmlStandalone, getXmlVersion, importNode, normalizeDocument, renameNode, setDocumentURI, setStrictErrorChecking, setXmlStandalone, setXmlVersionMethods inherited from interface org.w3c.dom.Node
appendChild, compareDocumentPosition, getAttributes, getBaseURI, getChildNodes, getFeature, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNodeName, getNodeType, getNodeValue, getOwnerDocument, getParentNode, getPrefix, getPreviousSibling, getTextContent, getUserData, hasAttributes, hasChildNodes, insertBefore, isDefaultNamespace, isEqualNode, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, normalize, removeChild, replaceChild, setNodeValue, setPrefix, setTextContent, setUserData
-
Constructor Details
-
HTMLDocumentImpl
public HTMLDocumentImpl()
-
-
Method Details
-
getDocumentElement
Description copied from class:org.apache.xerces.dom.CoreDocumentImplConvenience 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- Overrides:
getDocumentElementin classorg.apache.xerces.dom.CoreDocumentImpl
-
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 callinggetDocumentElement(). If the element does not exist, one is created.Called by
getTitle(),setTitle(java.lang.String),getBody()andsetBody(org.w3c.dom.html.HTMLElement)to assure the document has the <HEAD> element correctly placed.- Returns:
- The <HEAD> element
-
getTitle
- Specified by:
getTitlein interfaceHTMLDocument
-
setTitle
- Specified by:
setTitlein interfaceHTMLDocument
-
getBody
- Specified by:
getBodyin interfaceHTMLDocument
-
setBody
- Specified by:
setBodyin interfaceHTMLDocument
-
getElementById
Description copied from class:org.apache.xerces.dom.CoreDocumentImplIntroduced 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- Overrides:
getElementByIdin classorg.apache.xerces.dom.CoreDocumentImpl- See Also:
-
getElementsByName
- Specified by:
getElementsByNamein interfaceHTMLDocument
-
getElementsByTagName
Description copied from class:org.apache.xerces.dom.CoreDocumentImplReturn a live collection of all descendent Elements (not just immediate children) having the specified tag name.- Specified by:
getElementsByTagNamein interfaceDocument- Overrides:
getElementsByTagNamein classorg.apache.xerces.dom.CoreDocumentImpl- Parameters:
tagName- The type of Element we want to gather. "*" will be taken as a wildcard, meaning "all elements in the document."- See Also:
-
getElementsByTagNameNS
Description copied from class:org.apache.xerces.dom.CoreDocumentImplIntroduced 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- Overrides:
getElementsByTagNameNSin classorg.apache.xerces.dom.CoreDocumentImpl- 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.
-
createElementNS
public Element createElementNS(String namespaceURI, String qualifiedName, String localpart) throws DOMException Xerces-specific constructor. "localName" is passed in, so we don't need to create a new String for it.- Overrides:
createElementNSin classorg.apache.xerces.dom.CoreDocumentImpl- 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.
-
createElementNS
Description copied from class:org.apache.xerces.dom.CoreDocumentImplIntroduced 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- Overrides:
createElementNSin classorg.apache.xerces.dom.CoreDocumentImpl- 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:
-
createElement
Description copied from class:org.apache.xerces.dom.CoreDocumentImplFactory method; creates an Element having this Document as its OwnerDoc.- Specified by:
createElementin interfaceDocument- Overrides:
createElementin classorg.apache.xerces.dom.CoreDocumentImpl- 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
-
createAttribute
Creates an Attribute having this Document as its OwnerDoc. OverridesCoreDocumentImpl.createAttribute(java.lang.String)and returns and attribute whose name is lower case.- Specified by:
createAttributein interfaceDocument- Overrides:
createAttributein classorg.apache.xerces.dom.CoreDocumentImpl- Parameters:
name- The name of the attribute- Returns:
- An attribute whose name is all lower case
- Throws:
DOMException
-
getReferrer
- Specified by:
getReferrerin interfaceHTMLDocument
-
getDomain
- Specified by:
getDomainin interfaceHTMLDocument
-
getURL
- Specified by:
getURLin interfaceHTMLDocument
-
getCookie
- Specified by:
getCookiein interfaceHTMLDocument
-
setCookie
- Specified by:
setCookiein interfaceHTMLDocument
-
getImages
- Specified by:
getImagesin interfaceHTMLDocument
-
getApplets
- Specified by:
getAppletsin interfaceHTMLDocument
-
getLinks
- Specified by:
getLinksin interfaceHTMLDocument
-
getForms
- Specified by:
getFormsin interfaceHTMLDocument
-
getAnchors
- Specified by:
getAnchorsin interfaceHTMLDocument
-
open
public void open()- Specified by:
openin interfaceHTMLDocument
-
close
public void close()- Specified by:
closein interfaceHTMLDocument
-
write
- Specified by:
writein interfaceHTMLDocument
-
writeln
- Specified by:
writelnin interfaceHTMLDocument
-
cloneNode
Description copied from class:org.apache.xerces.dom.DocumentImplDeep-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. -
canRenameElements
protected boolean canRenameElements(String newNamespaceURI, String newNodeName, org.apache.xerces.dom.ElementImpl el) - Overrides:
canRenameElementsin classorg.apache.xerces.dom.CoreDocumentImpl
-