| Oracle9i XML API Reference - XDK and Oracle XML DB Release 2 (9.2) Part Number A96616-01 |
|
An XML document can be viewed as a tree whose nodes consisting of information between start-tags and end-tags. This tree representation, or the Document Object Model (DOM), is formed in memory when the XML parser parses a document. The DOM APIs are contained in the oracle.xml.parser.v2 package.
This chapter discusses the APIs for accessing and navigating this tree and includes the following sections:
public interface NSResolver
This interface provides support for resolving Namespaces.
XMLElement
Finds and returns the namespace definition in scope for a given namespace prefix; returns null if prefix could not be resolved.
public String resolveNamespacePrefix( String prefix);
| Parameter | Description |
|---|---|
|
prefix |
Namespace prefix to be resolved. |
The PrintDriver interface defines methods used to print XML documents represented as DOM trees.
public interface PrintDriver
XMLPrintDriver
Closes the output stream or print writer
public void close();
Flushes the output stream or print writer
public void flush();
Prints an XMLAttr node
public void printAttribute( XMLAttr attr);
| Parameter | Description |
|---|---|
|
attr |
The XMLAttr node. |
Calls print method for each attribute of the XMLElement.
public void printAttributeNodes( XMLElement elem);
| Parameter | Description |
|---|---|
|
elem |
The elem whose attributes are to be printed. |
Prints an XMLCDATA node.
public void printCDATASection( XMLCDATA cdata);
| Parameter | Description |
|---|---|
|
cdata |
The XMLCDATA node. |
Calls print method for each child of the XMLNode
public void printChildNodes( XMLNode node);
| Parameter | Description |
|---|---|
|
node |
The node whose children are to be printed. |
Prints an XMLComment node.
public void printComment( XMLComment comment);
| Parameter | Description |
|---|---|
|
comment |
The comment node. |
Prints a DTD.
public void printDoctype( DTD dtd);
| Parameter | Description |
|---|---|
|
dtd |
The DTD to be printed. |
Prints an XMLDocument.
public void printDocument( XMLDocument doc);
| Parameter | Description |
|---|---|
|
doc |
The document to be printed. |
Prints an empty XMLDocumentFragment object.
public void printDocumentFragment( XMLDocumentFragment dfrag);
| Parameter | Description |
|---|---|
|
dfrag |
The document fragment to be printed. |
Prints an XMLElement.
public void printElement( XMLElement elem);
| Parameter | Description |
|---|---|
|
elem |
The element to be printed. |
Prints an XMLEntityReference node.
public void printEntityReference( XMLEntityReference eref);
| Parameter | Description |
|---|---|
|
eref |
The XMLEntityReference node to be printed. |
Prints an XMLPI node.
public void printProcessingInstruction( XMLPI pi);
| Parameter | Description |
|---|---|
|
pi |
The XMLPI node to be printed. |
Prints an XMLText node.
public void printTextNode( XMLText text);
| Parameter | Description |
|---|---|
|
text |
The text node. |
Sets the encoding of the print driver.
public void setEncoding( String enc);
| Parameter | Description |
|---|---|
|
enc |
The encoding of the document being printed. |
This class hold information about each attribute declared in an attribute list in the Document Type Definition.
public class AttrDecl implements java.io.Externalizable oracle.xml.parser.v2.AttrDecl
java.io.Externalizable, java.io.Serializable
Default constructor. Note that this constructor is used only during deserialization/ decompression of this DOM node. In order to deserialize this node to construct the DOM node from the serialized/ compressed stream, it is required to create a handle of the object.
public static final int REQUIRED public AttrDecl();
Returns attribute presence.
public int getAttrPresence();
Returns attribute type.
public int getAttrType();
Returns attribute default value.
public String getDefaultValue();
Returns attribute values as an Enumeration.
public java.util.Vector getEnumerationValues();
Returns the name of the Attr Decl.
public String getNodeName();
Returns a code representing the type of the underlying object.
public short getNodeType();
Reads the information written in the compressed stream by writeExternal method and restores the object correspondingly. Throws:
IOException is thrown when there is an error in reading the input stream.ClassNotFoundException is thrown when the class is not foundpublic void readExternal( java.io.ObjectInput i);
| Parameter | Description |
|---|---|
|
in |
The ObjectInput stream used for reading the compressed stream. |
Returns a string representation of the attribute type.
public static String typeToString( int type);
| Parameter | Description |
|---|---|
|
type |
Numerical representation of the attribute type. |
Saves the state of the object by creating a binary compressed stream with information about this object. Throws IOException when there is an exception while writing the serialized/compressed stream.
public void writeExternal( java.io.ObjectOutput out);
| Parameter | Description |
|---|---|
|
out |
The ObjectOutput stream used to write the serialized/ compressed stream. |
Implements the DOM DocumentType interface and holds the Document Type. Definition information for an XML document.
public class DTD implements java.io.Externalizable oracle.xml.parser.v2.DTD
java.io.Externalizable, java.io.Serializable
Default constructor. Note that this constructor is used only during deserialization/decompression of this DOM node. In order to deserialize this node to construct the DOM node from the serialized/ compressed stream, it is required to create a handle of the object.
public DTD();
Finds and returns an element declaration for the given tag name.
public final ElementDecl findElementDecl( String name);
| Parameter | Description |
|---|---|
|
name |
The tag name. |
Finds and returns a named entity in the DTD; returns null if it is not found.
public final org.w3c.dom.Entity findEntity( String n, boolean par);
| Parameter | Description |
|---|---|
|
n |
The name of the entity. |
|
par |
Boolean indicating if the entity is parameter Entity. |
Retrieves the named notation from the DTD; returns null if it is not found.
public final org.w3c.dom.Notation findNotation( String name);
| Parameter | Description |
|---|---|
|
name |
The name of the notation. |
Return a NodeList that contains all children of this node. If there are no children, this is a NodeList containing no nodes. The content of the returned NodeList is "live" in the sense that, for instance, changes to the children of the node object that it was created from are immediately reflected in the nodes returned by the NodeList accessors; it is not a static snapshot of the content of the node. This is true for every NodeList, including the ones returned by the getElementsByTagName method.
public org.w3c.dom.NodeList getChildNodes();
Returns a NamedNodeMap containing the element declarations in the DTD. Every node in this map is an ElementDecl object. The element declarations in the DTD The DOM Level 1 does not support editing ElementDecl, therefore ElementDecl cannot be altered in any way.
public org.w3c.dom.NamedNodeMap getElementDecls();
Returns a NamedNodeMap containing the general entities, both external and internal, declared in the DTD. Duplicates are discarded. For example in:<!DOCTYPE ex SYSTEM "ex.dtd" [ <!ENTITY foo "foo"> <!ENTITY bar "bar"> <!ENTITY % baz "baz">]> <ex/> the interface provides access to foo and bar but not baz. Every node in this map also implements the Entity interface. The DOM Level 1 does not support editing entities, therefore entities cannot be altered in any way.
public org.w3c.dom.NamedNodeMap getEntities();
Returns the internal subset of the DTD.
public String getInternalSubset();
Returns the name of the DTD, or the name immediately following the DOCTYPE keyword.
public String getName();
Returns the name of the DTD; or the name immediately following the DOCTYPE keyword.
public String getNodeName();
Returns a code representing the type of the underlying object.
public short getNodeType();
Returns a NamedNodeMap containing the notations declared in the DTD. Duplicates are discarded. Every node in this map also implements the Notation interface. The DOM Level 1 does not support editing notations, therefore notations cannot be altered in any way.
public org.w3c.dom.NamedNodeMap getNotations();
Returns the owner of the DTD implementation.
public XMLDOMImplementation getOwnerImplementation();
Returns the public identifier associated with the DTD, if specified. If the public identifier was not specified, this is null.
public String getPublicId();
Returns the root tag for the DTD.
public String getRootTag();
Returns the system identifier associated with the DTD, if specified. If the system identifier was not specified, this is null.
public String getSystemId();
Determines whether a node has any children; return false always, as DTD cannot have any overrides method in XMLNode.
public boolean hasChildNodes();
Normalizes the DTD.
public void normalize();
Writes the contents of this document to the given output. Throws IOException if an invalid encoding is specified or another error occurs. The options are described in the following table.
| Parameter | Description |
|---|---|
|
out |
The output. |
|
enc |
Encoding used for the output. |
Reads the information written in the compressed stream by writeExternal method and restores the object correspondingly. Throws the following exceptions:
IOException when there is an error in reading the input stream.ClassNotFoundException when the class is not found.public void readExternal( java.io.ObjectInput in);
| Parameter | Description |
|---|---|
|
in |
The ObjectInput stream used for reading the compressed stream. |
Set the root tag for the DTD
public void setRootTag( String root);
| Parameter | Description |
|---|---|
|
root |
The root tag. |
Saves the state of the object by creating a binary compressed stream with information about this object. Throws IOException when there is an exception while writing the serialized/compressed stream.
public void writeExternal( java.io.ObjectOutput out);
| Parameter | Description |
|---|---|
|
out |
The ObjectOutput stream used to write the serialized/ compressed stream. |
This class represents an element declaration in a DTD.
public class ElementDecl implements java.io.Serializable, java.io.Externalizable oracle.xml.parser.v2.ElementDecl
java.io.Externalizable, java.io.Serializable
Default constructor. Note that this constructor is used only during deserialization/decompression of this DOM node. In order to deserialize this node to construct the DOM node from the serialized/ compressed stream, it is required to create a handle of the object.
public ElementDecl();
Returns a duplicate of this node; serves as a generic copy constructor for nodes. The duplicate node has no parent (parentNode returns null.). Cloning an Element copies all attributes and their values, including those generated by the XML processor to represent defaulted attributes, but this method does not copy any text it contains unless it is a deep clone, since the text is contained in a child Text node. Cloning any other type of node simply returns a copy of this node.
public org.w3c.dom.Node cloneNode(boolean deep);
| Parameter | Description |
|---|---|
|
deep |
If |
Returns vector of element names that can be appended to the element.
public java.util.Vector expectedElements( org.w3c.dom.Element e);
| Parameter | Description |
|---|---|
|
e |
Element. |
Returns an attribute declaration object or null if not found
public final AttrDecl findAttrDecl( String name);
| Parameter | Description |
|---|---|
|
name |
The attribute declaration to find. |
Returns an enumeration of attribute declarations.
public org.w3c.dom.NamedNodeMap getAttrDecls();
Returns a vector of elements that can be appended to this element.
public final java.util.Vector getContentElements();
Returns the content model of element.
public int getContentType();
Returs the name of the Element Decl.
public String getNodeName();
Returns a code representing the type of the underlying object.
public short getNodeType();
Returns the root node of Content Model Parse Tree. Node.getFirstChild() and Node.getLastChild() return the parse tree branches. Node.getNodeType() and Node.getNodeName() return the parse tree node type and name.
public final org.w3c.dom.Node getParseTree();
Reads the information written in the compressed stream by writeExternal method and restores the object correspondingly. Throws the following exceptions:
IOException when there is an error in reading the input stream.ClassNotFoundException when the class is not found.public void readExternal( java.io.ObjectInput in);
| Parameter | Description |
|---|---|
|
in |
The ObjectInput stream used for reading the compressed stream. |
Validates the content of a element node; returns TRUE if valid, FLASE otherwise.
public boolean validateContent(org.w3c.dom.Element e);
| Parameter | Description |
|---|---|
|
e |
Element node to validate. |
Saves the state of the object by creating a binary compressed stream with information about this object. Throws IOException when there is an exception while writing the serialized/compressed stream.
public void writeExternal( java.io.ObjectOutput out);
| Parameter | Description |
|---|---|
|
out |
The ObjectOutput stream used to write the serialized/ compressed stream. |
This class implements the DOM Attr interface and holds information on each attribute of an element. See also Attr, NodeFactory, DOMParser.setNodeFactory().
public class XMLAttr implements oracle.xml.parser.v2.NSName,
java.io.Externalizable
oracle.xml.parser.v2.XMLAttr
java.io.Externalizable, NSName, oracle.xml.util.NSName, java.io.Serializable