XMLDocument - Oracle 9i

Syntax

All Implemented Interfaces

java.lang.Cloneable, org.w3c.dom.Document, org.w3c.dom.Node, java.io.Serializable, oracle.xml.parser.v2.XMLConstants

Description
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 combinationof 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

XMLDocument

XMLDocument

XMLDocument inh

XML Document inh

Constructor
XMLDocument()

public XMLDocument() Creates an empty document.

Methods
cloneNode(boolean)

public org.w3c.dom.Node cloneNode(boolean deep)

Returns a duplicate of this document node.

Specified By

org.w3c.dom.Node.cloneNode(boolean) in interface org.w3c.dom.Node

Overrides

cloneNode(boolean) in class XMLNode

Parameters

deep - If true, recursively clone the subtree under the document; if false, clone only the document itself

Returns
The duplicate document node.

createAttribute(String)

public org.w3c.dom.Attr createAttribute(java.lang.String name)

Creates an Attr of the given name. Note that the Attr instance can then be set on an Element using the setAttribute method.

Specified By

org.w3c.dom.Document.createAttribute(String) in interface org.w3c.dom.Document

Parameters

name - The name of the attribute.

Returns

A new Attr object.

Throws

org.w3c.dom.DOMException - INVALID_CHARACTER_ERR: Raised if the specified name contains an invalid character.

createCDATASection(String)

public org.w3c.dom.CDATASection createCDATASection(java.lang.String data)
Creates a CDATASection node whose value is the specified string.

Specified By

org.w3c.dom.Document.createCDATASection(String) in interface org.w3c.dom.Document

Parameters

data - The data for the CDATASection contents.

Returns

The new CDATASection object.

Throws

org.w3c.dom.DOMException - A DOMException could be thrown.

createComment(String)

public org.w3c.dom.Comment createComment(java.lang.String data)
Creates a Comment node given the specified string.

Specified By

org.w3c.dom.Document.createComment(String) in interface org.w3c.dom.Document

Parameters

data - The data for the node.

Returns

The new Comment object.

createDocumentFragment()

public org.w3c.dom.DocumentFragment createDocumentFragment()

Creates an empty DocumentFragment object.

Specified By

org.w3c.dom.Document.createDocumentFragment() in interface org.w3c.dom.Document

Returns
A new DocumentFragment.

createElement(String)

public org.w3c.dom.Element createElement(java.lang.String tagName)

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.

Specified By

org.w3c.dom.Document.createElement(String) in interface org.w3c.dom.Document

Parameters

tagName - The name of the element type to instantiate. The name is treated as case-sensitive.

Returns
A new Element object.

Throws

org.w3c.dom.DOMException - INVALID_CHARACTER_ERR: Raised if the specified name contains an invalid character.

createEntityReference(String)

public org.w3c.dom.EntityReference createEntityReference(java.lang.String name)

Creates an EntityReference object.

Specified By

org.w3c.dom.Document.createEntityReference(String) in interface org.w3c.dom.Document

Parameters
name - The name of the entity to reference.

Returns
The new EntityReference object.

Throws

org.w3c.dom.DOMException - INVALID_CHARACTER_ERR: Raised if the specified name contains an invalid character.

createProcessingInstruction(String, String)

public org.w3c.dom.ProcessingInstruction createProcessingInstruction(java.lang.String target, java.lang.String data) Creates a ProcessingInstruction node given the specified name and data strings.

Specified By

org.w3c.dom.Document.createProcessingInstruction(String,String) in interface org.w3c.dom.Document

Parameters

target - The target part of the processing instruction. data - The data for the node.

Returns
The new ProcessingInstruction object.

Throws

org.w3c.dom.DOMException - INVALID_CHARACTER_ERR: Raised if an invalid character is specified.

createTextNode(String)

public org.w3c.dom.Text createTextNode(java.lang.String data) Creates a Text node given the specified string.

Specified By

org.w3c.dom.Document.createTextNode(String) in interface org.w3c.dom.Document

Parameters
data - The data for the node.

Returns
The new Text object.

expectedElements(Element)

public java.util.Vector expectedElements(org.w3c.dom.Element e) Returns vector of element names that can be appended to the element.

Parameters

e - Element

Returns

Vector of names

getDoctype()

public org.w3c.dom.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.

Specified By

org.w3c.dom.Document.getDoctype() in interface org.w3c.dom.Document

Returns
The associated DTD

See Also
org.w3c.dom.DocumentType

getDocumentElement()

public org.w3c.dom.Element getDocumentElement()

This is a convenience attribute that allows direct access to the child node that is the root element of the document.

Specified By

org.w3c.dom.Document.getDocumentElement() in interface org.w3c.dom.Document

Returns
The root element

getElementsByTagName(String)

public org.w3c.dom.NodeList getElementsByTagName(java.lang.String tagname)

Returns a NodeList of all the Elements with a given tag name in the order in which they would be encountered in a preorder traversal of the Document tree.

Specified By

org.w3c.dom.Document.getElementsByTagName(String) in interface org.w3c.dom.Document

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 Elements.

getEncoding()

public final java.lang.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.

getImplementation()

public org.w3c.dom.DOMImplementation getImplementation()

The DOMImplementation object that handles this document. A DOM application may use objects from multiple implementations.

Specified By

org.w3c.dom.Document.getImplementation() in interface org.w3c.dom.Document

Returns
The associated DOM implementation.

getOwnerDocument()

public org.w3c.dom.Document getOwnerDocument()

The Document object associated with this node. Since this node is a Document this is null.
Specified By

org.w3c.dom.Node.getOwnerDocument() in interface org.w3c.dom.Node

Overrides

getOwnerDocument() in class XMLNode

Returns
null

getStandalone()

public final java.lang.String getStandalone()

Retrieves the standalone information.

Returns
the standalone attribute stored in the <?xml ...?> tag.

getVersion()

public final java.lang.String getVersion()

Retrieves the version information.

Returns

the version number stored in the <?xml ...?> tag.

print(OutputStream)

public void print(java.io.OutputStream out)

Writes the contents of this document to the given output stream.

Overrides

print(OutputStream) in class XMLNode

Parameters

out - OutputStream to write to

Throws

IOException - if an error occurs

print(OutputStream, String)

public void print(java.io.OutputStream out, java.lang.String enc)
Writes the contents of this document to the given output stream.

Overrides

print(OutputStream, String) in class XMLNode

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

print(PrintWriter)

public void print(java.io.PrintWriter out)
Writes the contents of this document to the given output stream.

Overrides

print(PrintWriter) in class XMLNode

Parameters

out - PrintWriter to write to

Throws

IOException - if an error occurs

printExternalDTD(OutputStream)

public void printExternalDTD(java.io.OutputStream out)
Writes the contents of this document to the given output stream.

Parameters

out - OutputStream to write to

Throws

IOException - if an error occurs

printExternalDTD(OutputStream, String)

public void printExternalDTD(java.io.OutputStream out, java.lang.String enc) 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

printExternalDTD(PrintWriter)

public void printExternalDTD(java.io.PrintWriter out) Writes the contents of this document to the given output stream.

Parameters

out - PrintWriter to write to

Throws

IOException - if an error occurs

replaceChild(Node, Node)

public org.w3c.dom.Node replaceChild(org.w3c.dom.Node newChild, org.w3c.dom.Node oldChild)

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

Specified By

org.w3c.dom.Node.replaceChild(Node, Node) in interface org.w3c.dom.Node

Overrides

replaceChild(Node, Node) in class XMLNode

Parameters

newChild - The new node to put in the child list. oldChild - The node being replaced in the list.

Returns
The node replaced.

Throws
org.w3c.dom.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.

setEncoding(String)
public final void setEncoding(java.lang.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

setLocale(Locale)

public final void setLocale(java.util.Locale locale) Sets the locale for error reporting

Parameters

locale - Locale for error reporting.

setStandalone(String)

public final void setStandalone(java.lang.String value) Sets the standalone information stored in the <?xml ...?> tag.

Parameters

value - The attribute value ('yes' or 'no').

setVersion(String)

public final void setVersion(java.lang.String version) Sets the version number stored in the <?xml ...?> tag.

Parameters

version - The version information to set.

validateElementContent(Element)

public boolean validateElementContent(org.w3c.dom.Element e) Validates the content of a element node.

Parameters

e - Element to be validated

Returns

True if valid, else false

All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Oracle 9i Topics