|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--xml.dom.DomNode | +--xml.dom.DomDocument | +--xml.dom.xhtml.XhtmlDomDocument
XHTML subclass of "DomDocument", supporting the HTML DOM interfaces that make the most sense in the XHTML world.
This is basically just an XML DOM which does a little bit of error checking for nodes in the XHTML namespace. It doesn't support many of the HTML DOM custom element subclasses, and while it enforces case in some ways, it does so using the XHTML rules not those of the HTML DOM. In short, it's an XML DOM that you can safely use anywhere, but it has some added intelligence about the XHTML namespace, as well as basic HTML DOM support.
Note that a number of the HTMLDocument methods are not implemented, and invoking them will cause a DOMException to be thrown. These include all methods returning HTMLCollection objects, which are superfluous since the L2 iterators can do the same things more generically. They also include the methods which require interaction with a parser, since those exist primarily to support JavaScript code that writes literal HTML text to the parser, instead of supporting generally useful functionality such as loading a document given its URI.
Fields inherited from interface org.w3c.dom.Node |
ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE |
Constructor Summary | |
|
XhtmlDomDocument()
Constructs a Document node, associating it with an instance of the XhtmlDomImpl class. |
protected |
XhtmlDomDocument(XhtmlDomImpl impl)
Constructs a Document node, associating it with the specified XhtmlDomImpl instance. |
Method Summary | |
void |
close()
Closes a document stream opened by open() and forces
rendering. |
Attr |
createAttributeNS(java.lang.String namespaceURI,
java.lang.String name)
DOM L2 Returns a newly created attribute with the specified name and namespace information. |
Element |
createElementNS(java.lang.String namespaceURI,
java.lang.String name)
DOM L2 Returns a newly created element with the specified name and namespace information; if this is the XHTML namespace, it requires that the name be an XHTML name (after any prefix is removed) |
HTMLCollection |
getAnchors()
A collection of all the anchor ( A ) elements in a document
with a value for the name attribute. |
HTMLCollection |
getApplets()
A collection of all the OBJECT elements that include
applets and APPLET ( deprecated ) elements in a document. |
HTMLElement |
getBody()
DOM L1 (HTML) Returns the first "body" or "frameset" element in the document. |
java.lang.String |
getCookie()
The cookies associated with this document. |
java.lang.String |
getDomain()
The domain name of the server that served the document, or null if the server cannot be identified by a domain name. |
Element |
getElementById(java.lang.String id)
DOM L1 (HTML) Returns the element with the specified "id" attribute. |
NodeList |
getElementsByName(java.lang.String name)
DOM L1 (HTML) Same as the getElementsByTagname () method. |
HTMLCollection |
getForms()
A collection of all the forms of a document. |
HTMLCollection |
getImages()
A collection of all the IMG elements in a document. |
HTMLCollection |
getLinks()
A collection of all AREA elements and anchor (
A ) elements in a document with a value for the
href attribute. |
java.lang.String |
getReferrer()
Returns the URI of the page that linked to this page. |
java.lang.String |
getTitle()
The title of a document as specified by the TITLE element
in the head of the document. |
java.lang.String |
getURL()
The complete URI of the document. |
void |
open()
Note. |
void |
setBody(HTMLElement body)
|
void |
setCookie(java.lang.String cookies)
|
void |
setTitle(java.lang.String title)
|
void |
write(java.lang.String xhtmlText)
Write a string of text to a document stream opened by open() . |
void |
writeln(java.lang.String xhtmlText)
Write a string of text followed by a newline character to a document stream opened by open() . |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.w3c.dom.Document |
createAttribute, createCDATASection, createComment, createDocumentFragment, createElement, createEntityReference, createProcessingInstruction, createTextNode, getDoctype, getDocumentElement, getElementsByTagName, getElementsByTagNameNS, getImplementation, importNode |
Methods inherited from interface org.w3c.dom.Node |
appendChild, cloneNode, getAttributes, getChildNodes, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNodeName, getNodeType, getNodeValue, getOwnerDocument, getParentNode, getPrefix, getPreviousSibling, hasAttributes, hasChildNodes, insertBefore, isSupported, normalize, removeChild, replaceChild, setNodeValue, setPrefix |
Constructor Detail |
public XhtmlDomDocument()
XhtmlDomImpl
protected XhtmlDomDocument(XhtmlDomImpl impl)
Method Detail |
public Attr createAttributeNS(java.lang.String namespaceURI, java.lang.String name)
createAttributeNS
in interface Document
createAttributeNS
in class DomDocument
org.w3c.dom.Document
namespaceURIThe
- namespace URI of the attribute to create.qualifiedNameThe
- qualified name of the attribute to instantiate.Attr
object with the following attributes:
AttributeValueNode.nodeName
qualifiedName
Node.namespaceURI
namespaceURI
Node.prefix
prefix, extracted from
qualifiedName
, or null
if there is no
prefixNode.localName
local name, extracted from
qualifiedName
Attr.name
qualifiedName
Node.nodeValue
the empty
stringDOMException
- INVALID_CHARACTER_ERR: Raised if the specified qualified name
contains an illegal character.
qualifiedName
is
malformed, if the qualifiedName
has a prefix and the
namespaceURI
is null
, if the
qualifiedName
has a prefix that is "xml" and the
namespaceURI
is different from "
http://www.w3.org/XML/1998/namespace", or if the
qualifiedName
is "xmlns" and the
namespaceURI
is different from "
http://www.w3.org/2000/xmlns/".public Element createElementNS(java.lang.String namespaceURI, java.lang.String name)
createElementNS
in interface Document
createElementNS
in class DomDocument
org.w3c.dom.Document
namespaceURIThe
- namespace URI of the element to create.qualifiedNameThe
- qualified name of the element type to
instantiate.Element
object with the following
attributes:AttributeValueNode.nodeName
qualifiedName
Node.namespaceURI
namespaceURI
Node.prefix
prefix, extracted
from qualifiedName
, or null
if there is
no prefixNode.localName
local name, extracted from
qualifiedName
Element.tagName
qualifiedName
DOMException
- INVALID_CHARACTER_ERR: Raised if the specified qualified name
contains an illegal character.
qualifiedName
is
malformed, if the qualifiedName
has a prefix and the
namespaceURI
is null
, or if the
qualifiedName
has a prefix that is "xml" and the
namespaceURI
is different from "
http://www.w3.org/XML/1998/namespace" .public HTMLElement getBody()
getBody
in interface HTMLDocument
public void setBody(HTMLElement body)
setBody
in interface HTMLDocument
public java.lang.String getTitle()
HTMLDocument
TITLE
element
in the head of the document.getTitle
in interface HTMLDocument
public void setTitle(java.lang.String title)
setTitle
in interface HTMLDocument
public Element getElementById(java.lang.String id)
getElementById
in interface Document
getElementById
in class DomDocument
org.w3c.dom.Document
elementIdThe
- unique id
value for an element.public NodeList getElementsByName(java.lang.String name)
getElementsByName
in interface HTMLDocument
org.w3c.dom.html.HTMLDocument
elementName
- The name
attribute value for an
element.public java.lang.String getCookie()
HTMLDocument
name=value;expires=date
.getCookie
in interface HTMLDocument
public void setCookie(java.lang.String cookies)
setCookie
in interface HTMLDocument
public java.lang.String getDomain()
HTMLDocument
null
if the server cannot be identified by a domain name.getDomain
in interface HTMLDocument
public java.lang.String getReferrer()
HTMLDocument
getReferrer
in interface HTMLDocument
public java.lang.String getURL()
HTMLDocument
getURL
in interface HTMLDocument
public void open()
HTMLDocument
open
in interface HTMLDocument
public void close()
HTMLDocument
open()
and forces
rendering.close
in interface HTMLDocument
public void write(java.lang.String xhtmlText)
HTMLDocument
open()
. The text is parsed into the document's structure
model.write
in interface HTMLDocument
org.w3c.dom.html.HTMLDocument
text
- The string to be parsed into some structure in the
document structure model.public void writeln(java.lang.String xhtmlText)
HTMLDocument
open()
. The text is parsed into the
document's structure model.writeln
in interface HTMLDocument
org.w3c.dom.html.HTMLDocument
text
- The string to be parsed into some structure in the
document structure model.public HTMLCollection getAnchors()
HTMLDocument
A
) elements in a document
with a value for the name
attribute. Note. For reasons
of backwards compatibility, the returned set of anchors only contains
those anchors created with the name
attribute, not those
created with the id
attribute.getAnchors
in interface HTMLDocument
public HTMLCollection getApplets()
HTMLDocument
OBJECT
elements that include
applets and APPLET
( deprecated ) elements in a document.getApplets
in interface HTMLDocument
public HTMLCollection getForms()
HTMLDocument
getForms
in interface HTMLDocument
public HTMLCollection getImages()
HTMLDocument
IMG
elements in a document. The
behavior is limited to IMG
elements for backwards
compatibility.getImages
in interface HTMLDocument
public HTMLCollection getLinks()
HTMLDocument
AREA
elements and anchor (
A
) elements in a document with a value for the
href
attribute.getLinks
in interface HTMLDocument
|
Source code is GPL'd at http://xmlconf.sourceforge.net. |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |