| java.lang.Object nu.xom.Node nu.xom.ParentNode nu.xom.Document
Document | public class Document extends ParentNode (Code) | |
The Document class represents
a complete XML document including its root element,
prolog, and epilog.
author: Elliotte Rusty Harold version: 1.1b5 |
Constructor Summary | |
public | Document(Element root)
Creates a new Document object with the
specified root element. | public | Document(Document doc)
Creates a copy of this document. |
Method Summary | |
public Node | copy()
Returns a complete copy of this document. | final public String | getBaseURI()
Returns the absolute URI from which this document was loaded. | final public DocType | getDocType()
Returns this document's document type declaration,
or null if it doesn't have one. | final public Element | getRootElement()
Returns this document's root element. | final public String | getValue()
Returns the value of the document as defined by XPath 1.0. | final void | insertionAllowed(Node child, int position) | boolean | isDocument() | public Node | removeChild(int position)
Removes the child of this document at the specified position.
Indexes begin at 0 and count up to one less than the number
of children of this document. | public Node | removeChild(Node child)
Removes the specified child from this document. | public void | replaceChild(Node oldChild, Node newChild)
Replaces an existing child with a new child node.
If oldChild is not a child of this node,
then a NoSuchChildException is thrown. | public void | setBaseURI(String URI)
Sets the URI from which this document was loaded, and
against which relative URLs in this document will be resolved. | public void | setDocType(DocType doctype)
Sets this document's document type declaration.
If this document already has a document type declaration,
then it's inserted at that position. | public void | setRootElement(Element root)
Replaces the current root element with a different root element. | final public String | toString()
Returns a string representation of this document suitable
for debugging and diagnosis. | final public String | toXML()
Returns the actual complete, well-formed XML document as a
String . |
copy | public Node copy()(Code) | |
Returns a complete copy of this document.
a deep copy of this Document object |
getBaseURI | final public String getBaseURI()(Code) | |
Returns the absolute URI from which this document was loaded.
This method returns the empty string if the base URI is not
known; for instance if the document was created in memory with
a constructor rather than by parsing an existing document.
the base URI of this document |
getDocType | final public DocType getDocType()(Code) | |
Returns this document's document type declaration,
or null if it doesn't have one.
the document type declaration See Also: Document.setDocType |
getRootElement | final public Element getRootElement()(Code) | |
Returns this document's root element.
This is guaranteed to be non-null.
the root element |
getValue | final public String getValue()(Code) | |
Returns the value of the document as defined by XPath 1.0.
This is the same as the value of the root element, which
is the complete PCDATA content of the root element, without
any tags, comments, or processing instructions after all
entity and character references have been resolved.
value of the root element of this document |
insertionAllowed | final void insertionAllowed(Node child, int position)(Code) | | |
isDocument | boolean isDocument()(Code) | | |
removeChild | public Node removeChild(int position)(Code) | |
Removes the child of this document at the specified position.
Indexes begin at 0 and count up to one less than the number
of children of this document. The root element cannot be
removed. Instead, use setRootElement to replace
the existing root element with a different element.
Parameters: position - index of the node to remove the node which was removed throws: IndexOutOfBoundsException - if the index is negative or greater than the number of children of this document - 1 throws: WellformednessException - if the index points to the root element |
removeChild | public Node removeChild(Node child)(Code) | |
Removes the specified child from this document.
The root element cannot be removed.
Instead, use setRootElement to replace the
existing root element with a different element.
Parameters: child - node to remove the node which was removed throws: NoSuchChildException - if the node is not achild of this node throws: WellformednessException - if child is the root element |
replaceChild | public void replaceChild(Node oldChild, Node newChild)(Code) | |
Replaces an existing child with a new child node.
If oldChild is not a child of this node,
then a NoSuchChildException is thrown.
The root element can only be replaced by another element.
Parameters: oldChild - the node removed from the tree Parameters: newChild - the node inserted into the tree throws: MultipleParentException - if newChild alreadyhas a parent throws: NoSuchChildException - if oldChild is not a child of this node throws: NullPointerException - if either argument is null throws: IllegalAddException - if newChild is anattribute or a text node throws: WellformednessException - if newChild oldChild is an element and newChild is not |
setBaseURI | public void setBaseURI(String URI)(Code) | |
Sets the URI from which this document was loaded, and
against which relative URLs in this document will be resolved.
Setting the base URI to null or the empty string removes any
existing base URI.
Parameters: URI - the base URI of this document throws: MalformedURIException - if URI is not a legal absolute URI |
setDocType | public void setDocType(DocType doctype)(Code) | |
Sets this document's document type declaration.
If this document already has a document type declaration,
then it's inserted at that position. Otherwise, it's inserted
at the beginning of the document.
Parameters: doctype - the document type declaration throws: MultipleParentException - if doctype belongs to another document throws: NullPointerException - if doctype is null |
toString | final public String toString()(Code) | |
Returns a string representation of this document suitable
for debugging and diagnosis. This is not
the XML representation of this document.
a non-XML string representation of this document |
toXML | final public String toXML()(Code) | |
Returns the actual complete, well-formed XML document as a
String . Significant white space is preserved.
Insignificant white space in tags, the prolog, the epilog,
and the internal DTD subset is not preserved.
Entity and character references are not preserved.
The entire document is contained in this one string.
a string containing this entire XML document |
|
|