Class HTMLDocument
- All Implemented Interfaces:
DOMNode,NonDocumentTypeChildNode,ParentNode,CSSDocument,CSSNode,Serializable,Document,Node,org.w3c.dom.stylesheets.DocumentStyle
HTML Document.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.sf.carte.doc.style.css.CSSDocument
CSSDocument.ComplianceMode -
Field Summary
FieldsFields 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 TypeMethodDescriptionappendChild(Node newChild) Adds the nodenewChildto the end of the list of children of this node.cloneNode(boolean deep) shortcompareDocumentPosition(Node other) booleanTest ifnodeis an inclusive descendant of this node.createAttributeNS(String namespaceURI, String qualifiedName) createElement(String tagName) Creates an element of the type specified, with anullnamespace URI.createElementNS(String namespaceURI, String qualifiedName) Creates an element with the given qualified name and namespace URI.Creates a new iterator descending over the child nodes, starting from the last child node.Creates a new iterator over the child elements.elementIterator(String tagname) Creates a new iterator over the child elements of the given tagname.elementIteratorNS(String namespaceURI, String localName) Creates a new iterator over the child elements of the given namespaceURI and localName.Gets the absolute base URI of this node.Gets the base URL of this Document.intGets the number of child nodes of type Element that this parent node has.Get the children of this node.Gets the live ElementList containing all nodes of type Element that are children of this Element.Get the child node which is the document element of this document.getElementsByTagName(String name) Gives anElementListof all the elements descending from this context node that have the given tag name, in document order.getElementsByTagNameNS(String namespaceURI, String localName) Gives anElementListof all the elements descending from this context node that have the given local name and namespace URI, in document order.getFeature(String feature, String version) Deprecated.Get the first child of this node.Gets the Element that is the first child of this ParentNode.Get the last child of this node.Gets the DOMElement that is the last child of this ParentNode.Gives the local part of the qualified name of this node.Gets the first following sibling that is an element.Get the node immediately following this node in its parent's child list.shortGet theDOMDocumentobject related to this node (for all nodes exceptDocumentType, it is the document that created it), which is also the object that should be used to create new nodes for the document.Gets the first preceding sibling that is an element.Get the node immediately preceding this node in its parent's child list.getUserData(String key) booleanbooleanDoes this node have any child nodes ?booleanisDefaultNamespace(String namespaceURI) booleanisEqualNode(Node arg) booleanisSameNode(Node other) booleanisSupported(String feature, String version) Deprecated.iterator()Creates a new iterator over the child nodes.iterator(int whatToShow, NodeFilter filter) Creates a new iterator over the child nodes.iterator(NodeFilter filter) Creates a new iterator over the child nodes.Creates a new iterator over the child nodes.Creates a new list iterator over the child nodes.voidprependChild(Node newChild) querySelectorAll(String selectors) Gets a static list of the elements that match any of the specified group of selectors.voidRemoves all the children from this node, if any.removeChild(Node oldChild) Removes the nodeoldChildfrom the children of this node.voidsetDocumentURI(String documentURI) Sets the location of this document.voidsetNodeValue(String nodeValue) voidvoidsetTextContent(String textContent) setUserData(String key, Object data, UserDataHandler handler) typeIterator(short typeToShow) Creates a new iterator over the child nodes.Methods inherited from class io.sf.carte.doc.dom.DOMDocument
adoptNode, createAttribute, createCDATASection, createComment, createDocumentFragment, createEntityReference, createNodeIterator, createProcessingInstruction, createTextNode, createTreeWalker, enableStyleSheetsForSet, getCanvas, getCompatMode, getComplianceMode, getDoctype, getDocumentURI, getDomConfig, getElementById, getElementsByClassName, getErrorHandler, getImplementation, getInputEncoding, getLastStyleSheetSet, getNodeName, getParentNode, getReferrerPolicy, getSelectedStyleSheetSet, getStrictErrorChecking, getStyleDatabase, getStyleSheet, getStyleSheetFactory, getStyleSheets, getStyleSheetSets, getTargetMedium, getURL, getXmlEncoding, getXmlStandalone, getXmlVersion, hasStyleIssues, importNode, insertBefore, isAuthorizedOrigin, isSafeOrigin, isVisitedURI, lookupNamespaceURI, lookupPrefix, normalizeDocument, onMetaAdded, onMetaRemoved, openStream, rebuildCascade, registerProperty, renameNode, replaceChild, setReferrerPolicyHeader, setSelectedStyleSheetSet, setStrictErrorChecking, setTargetMedium, setXmlStandalone, setXmlVersion, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface io.sf.carte.doc.style.css.CSSDocument
openConnectionMethods inherited from interface org.w3c.dom.Document
getElementsByTagName, getElementsByTagNameNSMethods inherited from interface io.sf.carte.doc.dom.DOMNode
appendChild, getFirstChild, getLastChild, getNextSibling, getPreviousSibling, hasChildNodes, removeAllChild, removeChildMethods inherited from interface org.w3c.dom.Node
compareDocumentPosition, getAttributes, getFeature, getLocalName, getNamespaceURI, getNodeType, getNodeValue, getPrefix, getTextContent, getUserData, hasAttributes, isEqualNode, isSameNode, isSupported, normalize, setNodeValue, setPrefix, setTextContent, setUserDataMethods inherited from interface io.sf.carte.doc.dom.ParentNode
getChildElementCount, getChildNodes, getFirstElementChild, getLastElementChild, prependChild
-
Field Details
-
HTML_NAMESPACE_URI
- See Also:
-
-
Constructor Details
-
HTMLDocument
-
-
Method Details
-
getDocumentElement
Description copied from class:DOMDocumentGet the child node which is the document element of this document.- Specified by:
getDocumentElementin interfaceCSSDocument- Specified by:
getDocumentElementin interfaceDocument- Overrides:
getDocumentElementin classDOMDocument- Returns:
- the document element.
-
getOwnerDocument
Description copied from class:DOMDocumentGet theDOMDocumentobject related to this node (for all nodes exceptDocumentType, it is the document that created it), which is also the object that should be used to create new nodes for the document.- Specified by:
getOwnerDocumentin interfaceCSSNode- Specified by:
getOwnerDocumentin interfaceDOMNode- Specified by:
getOwnerDocumentin interfaceNode- Overrides:
getOwnerDocumentin classDOMDocument- Returns:
- the
DOMDocumentobject corresponding to this node. When this node is aDOMDocumentor aDocumentTypewhich was not added to anyDOMDocumentyet, this isnull.
-
cloneNode
Description copied from class:DOMDocument- Specified by:
cloneNodein interfaceNode- Overrides:
cloneNodein classDOMDocument
-
createElement
Description copied from class:DOMDocumentCreates an element of the type specified, with anullnamespace URI.The
tagNameis transformed to lower case.No default attributes are created.
- Specified by:
createElementin interfaceCSSDocument- Specified by:
createElementin interfaceDocument- Overrides:
createElementin classDOMDocument- Parameters:
tagName- the tag name of the element to create.- Returns:
- the new
DOMElement. - Throws:
DOMException- INVALID_CHARACTER_ERR if the name is not an XML valid name.
-
createElementNS
Description copied from class:DOMDocumentCreates an element with the given qualified name and namespace URI.If
namespaceURIisnullor the empty string, thequalifiedNameis transformed to lower case.No default attributes are created.
- Specified by:
createElementNSin interfaceCSSDocument- Specified by:
createElementNSin interfaceDocument- Overrides:
createElementNSin classDOMDocument- Parameters:
namespaceURI- the namespace URI of the element to create.qualifiedName- the qualified name of the element to create. The namespace prefix, if any, is extracted from this name.- Returns:
- the new
DOMElement. - Throws:
DOMException- INVALID_CHARACTER_ERR if the name is not an XML valid name.
NAMESPACE_ERR: if thequalifiedNameis a malformed qualified name, if thequalifiedNamehas a prefix and thenamespaceURIisnull, or if thequalifiedNamehas a prefix that is"xml"and thenamespaceURIis different from"http://www.w3.org/XML/1998/namespace", or if thequalifiedNameor its prefix is"xmlns"and thenamespaceURIis different from"http://www.w3.org/2000/xmlns/", or if thenamespaceURIis"http://www.w3.org/2000/xmlns/"and neither thequalifiedNamenor its prefix is"xmlns".
-
createAttributeNS
Description copied from class:DOMDocument- Specified by:
createAttributeNSin interfaceDocument- Overrides:
createAttributeNSin classDOMDocument- Throws:
DOMException
-
getBaseURL
Gets the base URL of this Document.If the Document's
headelement has abasechild element, the base URI is computed using the value of the href attribute of thebaseelement.- Specified by:
getBaseURLin interfaceCSSDocument- Overrides:
getBaseURLin classDOMDocument- Returns:
- the base URL, or
nullif no base URL could be found.
-
getBaseURI
Gets the absolute base URI of this node.- Specified by:
getBaseURIin interfaceNode- Overrides:
getBaseURIin classDOMDocument- Returns:
- the absolute base URI of this node, or
nullif an absolute URI could not be obtained.
-
setDocumentURI
Description copied from class:DOMDocumentSets the location of this document.For security reasons, if you want to retrieve linked style sheets from local URLs (like
file:), you need to set thedocumentURIto a local scheme (file:orjar:) as well.No lexical checking is performed when setting this attribute; this could result in a
nullvalue returned when usingDOMDocument.getBaseURI().- Specified by:
setDocumentURIin interfaceDocument- Overrides:
setDocumentURIin classDOMDocument- Parameters:
documentURI- the document URI.
-
isDefaultNamespace
- Specified by:
isDefaultNamespacein interfaceNode- Overrides:
isDefaultNamespacein classDOMDocument
-
getChildren
Gets the live ElementList containing all nodes of type Element that are children of this Element.- Specified by:
getChildrenin interfaceParentNode- Returns:
- the ElementList containing all nodes of type Element that are children of this Element.
-
querySelectorAll
Gets a static list of the elements that match any of the specified group of selectors.Unlike methods like
ParentNode.getElementsByTagName(String)orParentNode.getElementsByClassName(String), this is not a live list but a static one, representing the state of the document when the method was called. If no elements match, the list will be empty.- Specified by:
querySelectorAllin interfaceParentNode- Parameters:
selectors- a comma-separated list of selectors.- Returns:
- an ElementList with the elements that match any of the specified group of selectors.
-
iterator
Creates a new iterator over the child nodes.- Specified by:
iteratorin interfaceParentNode- Returns:
- an iterator over the child nodes.
-
descendingIterator
Creates a new iterator descending over the child nodes, starting from the last child node.- Specified by:
descendingIteratorin interfaceParentNode- Returns:
- an iterator descending over the child nodes.
-
iterator
Creates a new iterator over the child nodes.It only iterates over types set in the whatToShow bit field.
Example:
BitSet mask = new BitSet(32); mask.set(Node.ELEMENT_NODE); Iterator<Node> it = node.iterator(mask);- Specified by:
iteratorin interfaceParentNode- Parameters:
whatToShow- a bit set.- Returns:
- an iterator over the child nodes.
-
elementIterator
Creates a new iterator over the child elements.- Specified by:
elementIteratorin interfaceParentNode- Returns:
- an iterator over the child elements.
-
elementIterator
Creates a new iterator over the child elements of the given tagname.- Specified by:
elementIteratorin interfaceParentNode- Parameters:
tagname- The tag name of the child elements to match on.- Returns:
- an iterator over the child elements.
-
elementIteratorNS
Creates a new iterator over the child elements of the given namespaceURI and localName.- Specified by:
elementIteratorNSin interfaceParentNode- Parameters:
namespaceURI- the namespace URI of the elements to match on.localName- The local name of the elements to match on.- Returns:
- an iterator over the child elements.
-
iterator
Creates a new iterator over the child nodes.It only iterates over types set in the whatToShow mask that satisfy the custom
NodeFilter.Example:
Iterator<Node> it = node.iterator(NodeFilter.SHOW_ELEMENT, null);
- Specified by:
iteratorin interfaceParentNode- Parameters:
whatToShow- the bit field mask to apply to the node types, seeNodeFilter. Do not confuse this argument with theshortargument of theParentNode.typeIterator(short)method.filter- the filter to use in the iteration. ifnull, only thewhatToShowmask filter is applied.- Returns:
- an iterator over the child nodes.
-
typeIterator
Creates a new iterator over the child nodes.Do not confuse the
typeToShowargument with theintargument of theParentNode.iterator(int, NodeFilter)method, which is a bit field.- Specified by:
typeIteratorin interfaceParentNode- Parameters:
typeToShow- the node type to show (fromNode.getNodeType()).- Returns:
- an iterator over the child nodes.
-
iterator
Creates a new iterator over the child nodes.It only iterates over nodes accepted by the filter.
- Specified by:
iteratorin interfaceParentNode- Parameters:
filter- a filter, seeNodeFilter.- Returns:
- an iterator over the child nodes.
-
listIterator
Creates a new list iterator over the child nodes.- Specified by:
listIteratorin interfaceParentNode- Returns:
- a list iterator over the child nodes.
-
getElementsByTagNameNS
Gives anElementListof all the elements descending from this context node that have the given local name and namespace URI, in document order.The list is a live collection, and changes to the document made after calling this method are reflected in the
ElementList.The most efficient way to browse the returned list is to iterate it.
- Specified by:
getElementsByTagNameNSin interfaceParentNode- Parameters:
namespaceURI- the namespace URI of the elements to match on. The special value "*" matches all namespaces.localName- The local name of the elements to match on. The special value "*" matches all local names.- Returns:
- the
ElementListobject containing all the matched elements.
-
getElementsByTagName
Gives anElementListof all the elements descending from this context node that have the given tag name, in document order.The list is a live collection, and changes to the document made after calling this method are reflected in the
ElementList.The most efficient way to browse the returned list is to iterate it.
- Specified by:
getElementsByTagNamein interfaceParentNode- Parameters:
name- The tag name of the elements to match on. The special value "*" matches all tag names.- Returns:
- the
ElementListobject containing all the matched elements.
-
getFirstElementChild
Gets the Element that is the first child of this ParentNode.- Returns:
- the Element that is the first child of this ParentNode, or null if there is none.
-
getLastElementChild
Gets the DOMElement that is the last child of this ParentNode.- Returns:
- the DOMElement that is the last child of this ParentNode, or null if there is none.
-
getChildElementCount
public int getChildElementCount()Gets the number of child nodes of type Element that this parent node has.- Returns:
- the number of child nodes of type Element that this ParentNode has.
-
hasChildNodes
public boolean hasChildNodes()Description copied from interface:DOMNodeDoes this node have any child nodes ?- Specified by:
hasChildNodesin interfaceDOMNode- Specified by:
hasChildNodesin interfaceNode- Returns:
trueif this node has child nodes,falseotherwise.
-
getPreviousElementSibling
Description copied from interface:NonDocumentTypeChildNodeGets the first preceding sibling that is an element.- Specified by:
getPreviousElementSiblingin interfaceNonDocumentTypeChildNode- Returns:
- the first preceding sibling that is an element, and
nullotherwise.
-
getNextElementSibling
Description copied from interface:NonDocumentTypeChildNodeGets the first following sibling that is an element.- Specified by:
getNextElementSiblingin interfaceNonDocumentTypeChildNode- Returns:
- the first following sibling that is an element, and
nullotherwise.
-
prependChild
- Throws:
DOMException
-
getNodeValue
- Specified by:
getNodeValuein interfaceNode- Throws:
DOMException
-
setNodeValue
- Specified by:
setNodeValuein interfaceNode- Throws:
DOMException
-
getNodeType
public short getNodeType()- Specified by:
getNodeTypein interfaceNode
-
getLocalName
Gives the local part of the qualified name of this node. For nodes of any type other thanELEMENT_NODEandATTRIBUTE_NODE, this is always null.- Specified by:
getLocalNamein interfaceNode- Returns:
- the local part of the qualified name of this node, or null if this
node is not an
ELEMENT_NODEnor anATTRIBUTE_NODE.
-
getAttributes
- Specified by:
getAttributesin interfaceNode
-
hasAttributes
public boolean hasAttributes()- Specified by:
hasAttributesin interfaceNode
-
getChildNodes
Description copied from interface:DOMNodeGet the children of this node.- Specified by:
getChildNodesin interfaceDOMNode- Specified by:
getChildNodesin interfaceNode- Returns:
- a
DOMNodeListwith the children of this node. If there are no children, an empty list is returned.
-
getFirstChild
Description copied from interface:DOMNodeGet the first child of this node.- Specified by:
getFirstChildin interfaceDOMNode- Specified by:
getFirstChildin interfaceNode- Returns:
- the first child of this node,
nullif has no child nodes.
-
getLastChild
Description copied from interface:DOMNodeGet the last child of this node.- Specified by:
getLastChildin interfaceDOMNode- Specified by:
getLastChildin interfaceNode- Returns:
- the last child of this node,
nullif has no child nodes.
-
getPreviousSibling
Description copied from interface:DOMNodeGet the node immediately preceding this node in its parent's child list.- Specified by:
getPreviousSiblingin interfaceDOMNode- Specified by:
getPreviousSiblingin interfaceNode- Returns:
- the node immediately preceding this node in the child list, or
nullif none.
-
getNextSibling
Description copied from interface:DOMNodeGet the node immediately following this node in its parent's child list.- Specified by:
getNextSiblingin interfaceDOMNode- Specified by:
getNextSiblingin interfaceNode- Returns:
- the node immediately following this node in the child list, or
nullif none.
-
appendChild
Description copied from interface:DOMNodeAdds the nodenewChildto the end of the list of children of this node. If thenewChildis already in the tree, it is first removed.- Specified by:
appendChildin interfaceDOMNode- Specified by:
appendChildin interfaceNode- Parameters:
newChild- the node to append. If it is aDocumentFragmentobject, the entire contents of the document fragment are moved into the child list of this node.- Returns:
- the appended node.
- Throws:
DOMException- HIERARCHY_REQUEST_ERR: raised if this node is of a type that does not allow children of the type of thenewChildnode, or if the node to append is one of this node's ancestors or this node itself, or if this node is of typeDocumentand the DOM application attempts to append a secondDocumentTypeorElementnode.
WRONG_DOCUMENT_ERR: ifnewChildwas created from a different document than the one that created this node.
NOT_SUPPORTED_ERR: if this implementation does not support children of the type ofnewChildat this node.
-
removeChild
Description copied from interface:DOMNodeRemoves the nodeoldChildfrom the children of this node.- Specified by:
removeChildin interfaceDOMNode- Specified by:
removeChildin interfaceNode- Parameters:
oldChild- the node to remove.- Returns:
- the removed node.
- Throws:
DOMException- NOT_FOUND_ERR: ifoldChildis not a child of this node.
-
removeAllChild
public void removeAllChild()Description copied from interface:DOMNodeRemoves all the children from this node, if any.- Specified by:
removeAllChildin interfaceDOMNode
-
setUserData
- Specified by:
setUserDatain interfaceNode
-
getUserData
- Specified by:
getUserDatain interfaceNode
-
normalize
public void normalize() -
getFeature
Deprecated.This method is deprecated and not supported.- Specified by:
getFeaturein interfaceNode- Parameters:
feature- ignored.version- ignored.- Returns:
null.
-
isSupported
Deprecated.This method is not supported.- Specified by:
isSupportedin interfaceNode- Parameters:
feature- ignored.version- ignored.- Returns:
- Always
true.
-
compareDocumentPosition
- Specified by:
compareDocumentPositionin interfaceNode- Throws:
DOMException
-
getTextContent
- Specified by:
getTextContentin interfaceNode- Throws:
DOMException
-
setTextContent
- Specified by:
setTextContentin interfaceNode- Throws:
DOMException
-
getNamespaceURI
- Specified by:
getNamespaceURIin interfaceNode
-
getPrefix
-
setPrefix
- Specified by:
setPrefixin interfaceNode- Throws:
DOMException
-
isEqualNode
- Specified by:
isEqualNodein interfaceNode
-
isSameNode
- Specified by:
isSameNodein interfaceNode
-
contains
Test ifnodeis an inclusive descendant of this node.- Parameters:
node- the node to test.- Returns:
trueifnodeis an inclusive descendant of this node,falseotherwise (includingnodebeingnull).
-