All Packages Class Hierarchy This Package Previous Next Index
Class oracle.xml.parser.v2.XMLDocument
java.lang.Object
|
+----oracle.xml.parser.v2.XMLNode
|
+----oracle.xml.parser.v2.XMLDocument
- public class XMLDocument
- extends XMLNode
- implements Document, Serializable
This class implements the DOM Document interface, represents an entire
XML document and serves the root of the Document Object Model tree. Each
XML tag can either represent a node or a leaf of this tree.
According to the XML specification, the root of the tree consists of any
combination of comments and processing instructions, but only one root
element. A helper method getDocumentElement
is provided as
a short cut to finding the root element.
-
XMLDocument()
- Creates an empty document.
-
cloneNode(boolean)
- Returns a duplicate of this document node.
-
createAttribute(String)
- Creates an
Attr
of the given name.
-
createCDATASection(String)
- Creates a
CDATASection
node whose value is the specified
string.
-
createComment(String)
- Creates a
Comment
node given the specified string.
-
createDocumentFragment()
- Creates an empty
DocumentFragment
object.
-
createElement(String)
- Creates an element of the type specified.
-
createEntityReference(String)
- Creates an EntityReference object.
-
createProcessingInstruction(String, String)
- Creates a
ProcessingInstruction
node given the specified
name and data strings.
-
createTextNode(String)
- Creates a
Text
node given the specified string.
-
expectedElements(Element)
- Returns vector of element names that can be appended to the element.
-
getDoctype()
- The Document Type Declaration (DTD) associated with this document.
-
getDocumentElement()
- This is a convenience attribute that allows direct access to the
child node that is the root element of the document.
-
getElementsByTagName(String)
- Returns a
NodeList
of all the Element
s with a
given tag name in the order in which they would be encountered in a
preorder traversal of the Document
tree.
-
getEncoding()
- Retrieves the character encoding information.
-
getImplementation()
- The
DOMImplementation
object that handles this document.
-
getOwnerDocument()
- The
Document
object associated with this node.
-
getStandalone()
- Retrieves the standalone information.
-
getVersion()
- Retrieves the version information.
-
print(OutputStream)
- Writes the contents of this document to the given output stream.
-
print(OutputStream, String)
- Writes the contents of this document to the given output stream.
-
print(PrintWriter)
- Writes the contents of this document to the given output stream.
-
printExternalDTD(OutputStream)
- Writes the contents of this document to the given output stream.
-
printExternalDTD(OutputStream, String)
- Writes the contents of the external DTD to the given output stream.
-
printExternalDTD(PrintWriter)
- Writes the contents of this document to the given output stream.
-
replaceChild(Node, Node)
- Replaces the child node
oldChild
with newChild
in the list of children, and returns the oldChild
node.
-
setDoctype(String, String, String)
- Sets the doctype URI for the document
-
setEncoding(String)
- Sets the character encoding for output.
-
setLocale(Locale)
- Sets the locale for error reporting
-
setStandalone(String)
- Sets the standalone information stored in the <?xml ...?> tag.
-
setVersion(String)
- Sets the version number stored in the <?xml ...?> tag.
-
validateElementContent(Element)
- Validates the content of a element node.
XMLDocument
public XMLDocument()
- Creates an empty document.
getDoctype
public DocumentType getDoctype()
- The Document Type Declaration (DTD) associated with this document.
For XML documents without a DTD, this returns
null
.
Note that the DOM Level 1 specification does not support editing the
DTD.
- Returns:
- The associated DTD
- See Also:
- DocumentType
getImplementation
public DOMImplementation getImplementation()
- The
DOMImplementation
object that handles this document. A
DOM application may use objects from multiple implementations.
- Returns:
- The associated DOM implementation.
getDocumentElement
public Element getDocumentElement()
- This is a convenience attribute that allows direct access to the
child node that is the root element of the document.
- Returns:
- The root element
getOwnerDocument
public Document getOwnerDocument()
- The
Document
object associated with this node. Since this
node is a Document
this is null
.
- Returns:
-
null
- Overrides:
- getOwnerDocument in class XMLNode
createElement
public Element createElement(String tagName) throws DOMException
- Creates an element of the type specified. Note that the instance returned
implements the Element interface, so attributes can be specified
directly on the returned object.
- Parameters:
- tagName - The name of the element type to instantiate. The name is
treated as case-sensitive.
- Returns:
- A new
Element
object.
- Throws: DOMException
- INVALID_CHARACTER_ERR: Raised if the specified name contains an
invalid character.
createDocumentFragment
public DocumentFragment createDocumentFragment()
- Creates an empty
DocumentFragment
object.
- Returns:
- A new
DocumentFragment
.
createTextNode
public Text createTextNode(String data)
- Creates a
Text
node given the specified string.
- Parameters:
- data - The data for the node.
- Returns:
- The new
Text
object.
createComment
public Comment createComment(String data)
- Creates a
Comment
node given the specified string.
- Parameters:
- data - The data for the node.
- Returns:
- The new
Comment
object.
createCDATASection
public CDATASection createCDATASection(String data) throws DOMException
- Creates a
CDATASection
node whose value is the specified
string.
- Parameters:
- data - The data for the
CDATASection
contents.
- Returns:
- The new
CDATASection
object.
- Throws: DOMException
- A
DOMException
could be thrown.
createProcessingInstruction
public ProcessingInstruction createProcessingInstruction(String target,
String data) throws DOMException
- Creates a
ProcessingInstruction
node given the specified
name and data strings.
- Parameters:
- target - The target part of the processing instruction.
- data - The data for the node.
- Returns:
- The new
ProcessingInstruction
object.
- Throws: DOMException
- INVALID_CHARACTER_ERR: Raised if an invalid character is specified.
createAttribute
public Attr createAttribute(String name) throws DOMException
- Creates an
Attr
of the given name. Note that the
Attr
instance can then be set on an Element
using the setAttribute
method.
- Parameters:
- name - The name of the attribute.
- Returns:
- A new
Attr
object.
- Throws: DOMException
- INVALID_CHARACTER_ERR: Raised if the specified name contains an
invalid character.
createEntityReference
public EntityReference createEntityReference(String name) throws DOMException
- Creates an EntityReference object.
- Parameters:
- name - The name of the entity to reference.
- Returns:
- The new
EntityReference
object.
- Throws: DOMException
- INVALID_CHARACTER_ERR: Raised if the specified name contains an
invalid character.
getElementsByTagName
public NodeList getElementsByTagName(String tagname)
- Returns a
NodeList
of all the Element
s with a
given tag name in the order in which they would be encountered in a
preorder traversal of the Document
tree.
- Parameters:
- tagname - The name of the tag to match on. The special value "*"
matches all tags.
- Returns:
- A new
NodeList
object containing all the matched
Element
s.
replaceChild
public Node replaceChild(Node newChild,
Node oldChild) throws DOMException
- Replaces the child node
oldChild
with newChild
in the list of children, and returns the oldChild
node. If
the newChild
is already in the tree, it is first removed.
This is an override of the XMLNode.removeChild
method
- Parameters:
- newChild - The new node to put in the child list.
- oldChild - The node being replaced in the list.
- Returns:
- The node replaced.
- Throws: DOMException
- HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not
allow children of the type of the
newChild
node.
WRONG_DOCUMENT_ERR: Raised if newChild
was created
from a different document than this one.
NOT_FOUND_ERR: Raised if oldChild
is not a child of
this node.
- Overrides:
- replaceChild in class XMLNode
cloneNode
public Node cloneNode(boolean deep)
- Returns a duplicate of this document node.
- Parameters:
- deep - If
true
, recursively clone the subtree under
the document; if false
, clone only the document itself
- Returns:
- The duplicate document node.
- Overrides:
- cloneNode in class XMLNode
setDoctype
public void setDoctype(String rootname,
String sysid,
String pubid)
- Sets the doctype URI for the document
- Parameters:
- root - The name of the root element
- sysid - The system id of the doctype
- pubid - The public id of the doctype
print
public void print(PrintWriter out) throws IOException
- Writes the contents of this document to the given output stream.
- Parameters:
- out -
PrintWriter
to write to
- Throws: IOException
- if an error occurs
- Overrides:
- print in class XMLNode
print
public void print(OutputStream out) throws IOException
- Writes the contents of this document to the given output stream.
- Parameters:
- out -
OutputStream
to write to
- Throws: IOException
- if an error occurs
- Overrides:
- print in class XMLNode
print
public void print(OutputStream out,
String enc) throws IOException
- Writes the contents of this document to the given output stream.
- Parameters:
- out -
OutputStream
to write to
- enc - Encoding to use for the output
- Throws: IOException
- if an invalid encoding was specified or
if any other error occurs
- Overrides:
- print in class XMLNode
printExternalDTD
public void printExternalDTD(PrintWriter out) throws IOException
- Writes the contents of this document to the given output stream.
- Parameters:
- out -
PrintWriter
to write to
- Throws: IOException
- if an error occurs
printExternalDTD
public void printExternalDTD(OutputStream out) throws IOException
- Writes the contents of this document to the given output stream.
- Parameters:
- out -
OutputStream
to write to
- Throws: IOException
- if an error occurs
printExternalDTD
public void printExternalDTD(OutputStream out,
String enc) throws IOException
- Writes the contents of the external DTD to the given output stream.
- Parameters:
- out -
OutputStream
to write to
- enc - Encoding to use for the output
- Throws: IOException
- if an invalid encoding was specified or
if any other error occurs
validateElementContent
public boolean validateElementContent(Element e)
- Validates the content of a element node.
- Parameters:
- e - Element to be validated
- Returns:
- True if valid, else false
setLocale
public final void setLocale(Locale locale)
- Sets the locale for error reporting
- Parameters:
- locale - Locale for error reporting.
expectedElements
public Vector expectedElements(Element e)
- Returns vector of element names that can be appended to the element.
- Parameters:
- e - Element
- Returns:
- Vector of names
getVersion
public final String getVersion()
- Retrieves the version information.
- Returns:
- the version number stored in the <?xml ...?> tag.
setVersion
public final void setVersion(String version)
- Sets the version number stored in the <?xml ...?> tag.
- Parameters:
- version - The version information to set.
getEncoding
public final String getEncoding()
- Retrieves the character encoding information.
- Returns:
- the encoding information stored in the <?xml ...?> tag or
the user-defined output encoding if it has been more recently set.
setEncoding
public final void setEncoding(String encoding)
- Sets the character encoding for output. Eventually it sets the ENCODING
stored in the <?xml ...?> tag, but not until the document is saved.
You should not call this method until the Document has been loaded.
- Parameters:
- encoding - The character encoding to set
getStandalone
public final String getStandalone()
- Retrieves the standalone information.
- Returns:
- the standalone attribute stored in the <?xml ...?> tag.
setStandalone
public final void setStandalone(String value)
- Sets the standalone information stored in the <?xml ...?> tag.
- Parameters:
- value - The attribute value ('yes' or 'no').
All Packages Class Hierarchy This Package Previous Next Index