|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnu.xom.Node
nu.xom.ParentNode
nu.xom.Document
The Document
class represents
a complete XML document including its root element,
prolog, and epilog.
Constructor Summary | |
Document(Document doc)
Creates a copy of the Document . |
|
Document(Element root)
Creates a new Document object with the
specified root element. |
Method Summary | |
Node |
copy()
Returns a complete copy of this document. |
java.lang.String |
getBaseURI()
Returns the URI from which this document was loaded. |
DocType |
getDocType()
Returns this document's document type declaration, or null if it doesn't have one. |
Element |
getRootElement()
Returns this document's root element. |
java.lang.String |
getValue()
Returns the value of the document as defined by XPath 1.0. |
Node |
removeChild(int position)
Removes the child of this document at the specified position. |
Node |
removeChild(Node child)
Removes the specified child from this document. |
void |
replaceChild(Node oldChild,
Node newChild)
Replaces an existing child with a new child node. |
void |
setBaseURI(java.lang.String URI)
Sets the URI from which this node was loaded, and against which relative URLs in this node will be resolved. |
void |
setDocType(DocType doctype)
Sets this document's document type declaration. |
void |
setRootElement(Element root)
Replaces the current root element with a different root element. |
java.lang.String |
toString()
Returns a string representation of this document suitable for debugging and diagnosis. |
java.lang.String |
toXML()
Returns the actual complete, well-formed XML document as a String . |
Methods inherited from class nu.xom.ParentNode |
appendChild, getChild, getChildCount, indexOf, insertChild |
Methods inherited from class nu.xom.Node |
detach, equals, getDocument, getParent, hashCode |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public Document(Element root)
Creates a new Document
object with the
specified root element.
root
- the root element of this document
java.lang.NullPointerException
- if root is nullpublic Document(Document doc)
Creates a copy of the Document
.
doc
- the Document to copy
java.lang.NullPointerException
- if doc
is nullMethod Detail |
public final DocType getDocType()
Returns this document's document type declaration, or null if it doesn't have one.
setDocType(nu.xom.DocType)
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. Otherwise, it's inserted at the beginning of the document.
doctype
- the document type declaration
MultipleParentException
- if doctype belongs to
another document
java.lang.NullPointerException
- if doctype is nullpublic final Element getRootElement()
Returns this document's root element. This is guaranteed to be non-null.
public void setRootElement(Element root)
Replaces the current root element with a different root element.
root
- the new root element
MultipleParentException
- if root has a parent
java.lang.NullPointerException
- if root is nullpublic void setBaseURI(java.lang.String URI)
Sets the URI from which this node was loaded, and against which relative URLs in this node will be resolved.
setBaseURI
in class ParentNode
URI
- the base URI of this document
MalformedURIException
- if URI
is
not a legal IRIpublic final java.lang.String getBaseURI()
Returns the URI from which this document was loaded.
getBaseURI
in class Node
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. The root element cannot be
removed. Instead, use setRootElement
to replace
the existing root element with a different element.
removeChild
in class ParentNode
position
- index of the node to remove
java.lang.IndexOutOfBoundsException
- if the index is negative or
greater than the number of children of this document - 1
WellformednessException
- if the index points
to the root elementpublic Node removeChild(Node child)
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.
removeChild
in class ParentNode
child
- node to remove
NoSuchChildException
- if the node is not a
child of this node
WellformednessException
- if child is the root elementpublic 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.
The root element can only be replaced by another element.
replaceChild
in class ParentNode
oldChild
- the node removed from the treenewChild
- the node inserted into the tree
MultipleParentException
- if newChild
already
has a parent
NoSuchChildException
- if oldChild
is not a child of this node
java.lang.NullPointerException
- if either argument is null
IllegalAddException
- if newChild
is an
attribute
WellformednessException
- if newChild
oldChild
is an element and
newChild
is notpublic final java.lang.String getValue()
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.
getValue
in class Node
Node.getValue()
public final java.lang.String toXML()
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.
toXML
in class Node
String
containing this entire
XML documentNode.toXML()
public Node copy()
Returns a complete copy of this document.
copy
in class Node
Document
objectNode.copy()
public final java.lang.String toString()
Returns a string representation of this document suitable for debugging and diagnosis. This is not the XML representation of this document.
Document
objectObject.toString()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |