Skip Headers

Oracle® XML Reference
10g (9.0.4)

Part Number B10926-01
Go To Documentation Library
Home
Go To Product List
Solution Area
Go To Table Of Contents
Contents
Go To Index
Index

Go to previous page Go to next page

2
Document Object Model (DOM)

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:


NSResolver Interface

This interface provides support for resolving Namespaces.

Syntax

public interface NSResolver

resolveNamespacePrefix()

Finds and returns the namespace definition in scope for a given namespace prefix; returns null if prefix could not be resolved.

Syntax

public String resolveNamespacePrefix( String prefix);

Parameter Description
prefix

Namespace prefix to be resolved.


PrintDriver Interface

The PrintDriver interface defines methods used to print XML documents represented as DOM trees.

Syntax

public interface PrintDriver

Table 2-1 Summary of Methods of PintDriver
Method Description

close()

Closes the output stream or print writer

flush()

Flushes the output stream or print writer

printAttribute()

Prints an XMLAttr node

printAttributeNodes()

Calls print method for each attribute of the XMLElement.

printCDATASection()

Prints an XMLCDATA node.

printChildNodes()

Calls print method for each child of the XMLNode

printComment()

Prints an XMLComment node.

printDoctype()

Prints a DTD.

printDocument()

Prints an XMLDocument.

printDocumentFragment()

Prints an empty XMLDocumentFragment object.

printElement()

Prints an XMLElement.

printEntityReference()

Prints an XMLEntityReference node.

printProcessingInstruction()

Prints an XMLPI node.

printTextNode()

Prints an XMLText node.

setEncoding()

Sets the encoding of the print driver.


close()

Closes the output stream or print writer

Syntax

public void close();

flush()

Flushes the output stream or print writer

Syntax

public void flush();

printAttribute()

Prints an XMLAttr node

Syntax

public void printAttribute( XMLAttr attr);

Parameter Description
attr

The XMLAttr node.


printAttributeNodes()

Calls print method for each attribute of the XMLElement.

Syntax

public void printAttributeNodes( XMLElement elem);

Parameter Description
elem

The elem whose attributes are to be printed.


printCDATASection()

Prints an XMLCDATA node.

Syntax

public void printCDATASection( XMLCDATA cdata);

Parameter Description
cdata

The XMLCDATA node.


printChildNodes()

Calls print method for each child of the XMLNode

Syntax

public void printChildNodes( XMLNode node);

Parameter Description
node

The node whose children are to be printed.


printComment()

Prints an XMLComment node.

Syntax

public void printComment( XMLComment comment);

Parameter Description
comment

The comment node.


printDoctype()

Prints a DTD.

Syntax

public void printDoctype( DTD dtd);

Parameter Description
dtd

The DTD to be printed.


printDocument()

Prints an XMLDocument.

Syntax

public void printDocument( XMLDocument doc);

Parameter Description
doc

The document to be printed.


printDocumentFragment()

Prints an empty XMLDocumentFragment object.

Syntax

public void printDocumentFragment( XMLDocumentFragment dfrag);

Parameter Description
dfrag

The document fragment to be printed.


printElement()

Prints an XMLElement.

Syntax

public void printElement( XMLElement elem);

Parameter Description
elem

The element to be printed.


printEntityReference()

Prints an XMLEntityReference node.

Syntax

public void printEntityReference( XMLEntityReference eref);

Parameter Description
eref

The XMLEntityReference node to be printed.


printProcessingInstruction()

Prints an XMLPI node.

Syntax

public void printProcessingInstruction( XMLPI pi);

Parameter Description
pi

The XMLPI node to be printed.


printTextNode()

Prints an XMLText node.

Syntax

public void printTextNode( XMLText text);

Parameter Description
text

The text node.


setEncoding()

Sets the encoding of the print driver.

Syntax

public void setEncoding( String enc);

Parameter Description
enc

The encoding of the document being printed.


AttrDecl Class

This class hold information about each attribute declared in an attribute list in the Document Type Definition.

Syntax

public class AttrDecl implements java.io.Externalizable

Table 2-2  Fields of AttrDecl
Field Syntax Description

CDATA

public static final int CDATA

AttType - StringType - CDATA

DEFAULT
public static final int 
DEFAULT

Attribute presence - Default

ENTITIES
public static final int 
ENTITIES

AttType - TokenizedType - Entities

ENTITY
public static final int 
ENTITY

AttType - TokenizedType - Entity

ENUMERATION
public static final int 
ENUMERATION

AttType - EnumeratedType - Enumeration

FIXED
public static final int 
FIXED

Attribute presence - Fixed

ID
public static final int 
ID

AttType - TokenizedType - ID

IDREF
public static final int 
IDREF

AttType - TokenizedType - ID reference

IDREFS
public static final int 
IDREFS

AttType - TokenizedType - ID references

IMPLIED
public static final int 
IMPLIED

Attribute presence - Implied

NMTOKEN
public static final int 
NMTOKEN

AttType - TokenizedType - Name token

NMTOKENS
public static final int 
NMTOKENS

AttType - TokenizedType - Name tokens

NOTATION
public static final int 
NOTATION

AttType - EnumeratedType - Notation

REQUIRED
public static final int 
REQUIRED

Attribute presence - Required

Table 2-3  Summary of Methods of AttrDecl
Methods Description

AttrDecl()

Default constructor.

getAttrPresence()

Returns attribute presence.

getAttrType()

Returns attribute type.

getDefaultValue()

Returns attribute default value.

getEnumerationValues()

Returns attribute values as an Enumeration.

getNodeName()

Returns the name of the Attr Decl.

getNodeType()

Returns a code representing the type of the underlying object.

readExternal()

Reads the information written in the compressed stream by writeExternal method and restores the object correspondingly.

typeToString()

Returns a string representation of the attribute type.

writeExternal()

Saves the state of the object by creating a binary compressed stream with information about this object.


AttrDecl()

Default constructor.

Syntax

public static final int REQUIRED public  AttrDecl();

getAttrPresence()

Returns attribute presence.

Syntax

public int getAttrPresence();

getAttrType()

Returns attribute type.

Syntax

public int getAttrType();

getDefaultValue()

Returns attribute default value.

Syntax

public String getDefaultValue();

getEnumerationValues()

Returns attribute values as an Enumeration.

Syntax

public java.util.Vector getEnumerationValues();

getNodeName()

Returns the name of the Attr Decl.

Syntax

public String getNodeName();

getNodeType()

Returns a code representing the type of the underlying object.

Syntax

public short getNodeType();

readExternal()

Restores the object after reading it from a compressed stream. Throws:

Syntax

public void readExternal( java.io.ObjectInput i);

Parameter Description
in

The ObjectInput stream used for reading the compressed stream.


typeToString()

Returns a string representation of the attribute type.

Syntax

public static String typeToString( int type);

Parameter Description
type

Numerical representation of the attribute type.


writeExternal()

Saves the state of the object by creating a binary compressed stream. Throws IOException if serialized/compressed stream.

Syntax

public void writeExternal( java.io.ObjectOutput out);

Parameter Description
out

The ObjectOutput stream used to write the stream.


DTD Class

Implements the DOM DocumentType interface and holds the Document Type. Definition information for an XML document.

Syntax

public class DTD implements java.io.Externalizable

Table 2-4  Summary of Methods of DTD
Method Description

DTD()

Default constructor.

findElementDecl()

Finds and returns an element declaration for the given tag name.

findEntity()

Finds and returns a named entity in the DTD; returns null if it is not found.

findNotation()

Retrieves the named notation from the DTD; returns null if it is not found.

getChildNodes()

Returns a NodeList that contains all children of this node.

getElementDecls()

Returns a NamedNodeMap containing the element declarations in the DTD.

getEntities()

Returns a NamedNodeMap containing the general entities, both external and internal, declared in the DTD.

getInternalSubset()

Returns the internal subset of the DTD.

getName()

Returns the name of the DTD, or the name immediately following the DOCTYPE keyword.

getNodeName()

Returns the name of the DTD, or the name immediately following the DOCTYPE keyword.

getNodeType()

Returns a code representing the type of the underlying object.

getNotations()

Returns a NamedNodeMap containing the notations declared in the DTD.

getOwnerImplementation()

Returns the owner of the DTD implementation.

getPublicId()

Returns the public identifier associated with the DTD, if specified.

getRootTag()

Returns the root tag for the DTD.

getSystemId()

Returns the system identifier associated with the DTD, if specified. If the system identifier was not specified, this is null.

hasChildNodes()

Determines whether a node has any children; return false always, as DTD cannot have any overrides method in XMLNode.

normalize()

Normalizes the DTD.

printExternalDTD()

Writes the contents of this document to the given output.

readExternal()

Reads the information written in the compressed stream by writeExternal method and restores the object correspondingly.

setRootTag()

Sets the root tag for the DTD.

writeExternal()

Saves the state of the object by creating a binary compressed stream with information about this object.


DTD()

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.

Syntax

public  DTD();

findElementDecl()

Finds and returns an element declaration for the given tag name.

Syntax

public final ElementDecl findElementDecl( String name);

Parameter Description
name

The tag name.


findEntity()

Finds and returns a named entity in the DTD; returns null if it is not found.

Syntax

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.


findNotation()

Retrieves the named notation from the DTD; returns null if it is not found.

Syntax

public final org.w3c.dom.Notation findNotation( String name);

Parameter Description
name

The name of the notation.


getChildNodes()

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.

Syntax

public org.w3c.dom.NodeList getChildNodes();

getElementDecls()

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

Syntax

public org.w3c.dom.NamedNodeMap getElementDecls();

getEntities()

Returns a NamedNodeMap containing the general entities, both external and internal, declared in the DTD. Duplicates are discarded. Every node in this map also implements the Entity interface.

Syntax

public org.w3c.dom.NamedNodeMap getEntities();

getInternalSubset()

Returns the internal subset of the DTD.

Syntax

public String getInternalSubset();

getName()

Returns the name of the DTD, or the name immediately following the DOCTYPE keyword.

Syntax

public String getName();

getNodeName()

Returns the name of the DTD; or the name immediately following the DOCTYPE keyword.

Syntax

public String getNodeName();

getNodeType()

Returns a code representing the type of the underlying object.

Syntax

public short getNodeType();

getNotations()

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.

Syntax

public org.w3c.dom.NamedNodeMap getNotations();

getOwnerImplementation()

Returns the owner of the DTD implementation.

Syntax

public XMLDOMImplementation getOwnerImplementation();

getPublicId()

Returns the public identifier associated with the DTD, if specified. If the public identifier was not specified, this is null.

Syntax

public String getPublicId();

getRootTag()

Returns the root tag for the DTD.

Syntax

public String getRootTag();

getSystemId()

Returns the system identifier associated with the DTD, if specified. If the system identifier was not specified, this is null.

Syntax

public String getSystemId();

hasChildNodes()

Determines whether a node has any children; return false always, as DTD cannot have any overrides method in XMLNode.

Syntax

public boolean hasChildNodes();

normalize()

Normalizes the DTD.

Syntax

public void normalize();

printExternalDTD()

Writes the contents of this document to the given output. Throws IOException if an invalid encoding is specified or another error occurs.

Syntax Description
public void printExternalDTD(
      java.io.OutputStream out);

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

public void printExternalDTD(
      java.io.OutputStream out,
      String enc);

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

public void printExternalDTD(
      java.io.PrintWriter out);

Writes the contents of this document to the given print writer.

Parameter Description
out

The output.

enc

Encoding used for the output.


readExternal()

Reads the information written in the compressed stream by writeExternal method and restores the object correspondingly. Throws the following exceptions:

Syntax

public void readExternal( java.io.ObjectInput in);

Parameter Description
in

The ObjectInput stream used for reading the compressed stream.


setRootTag()

Set the root tag for the DTD

Syntax

public void setRootTag( String root);

Parameter Description
root

The root tag.


writeExternal()

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.

Syntax

public void writeExternal( java.io.ObjectOutput out);

Parameter Description
out

The ObjectOutput stream


ElementDecl Class

This class represents an element declaration in a DTD.

Syntax

public class ElementDecl implements java.io.Serializable, java.io.Externalizable

Table 2-5  Fields of ElementDecl
Field Syntax Description
ANY
public static final byte ANY

Element content type - Children can be any element.

ASTERISK
public static final int ASTERISK

ContentModelParseTreeNode type - "*" node (has one child).

COMMA
public static final int COMMA

ContentModelParseTreeNode type - "," node (has two children).

ELEMENT
public static final int ELEMENT

ContentModelParseTreeNode type - 'leaf' node (has no children).

ELEMENT_DECLARED
public static final int 
     ELEMENT_DECLARED

Node flag to represent element declaration in a DTD.

ELEMENTS
public static final byte
     ELEMENTS

Element content type - Children can be elements; see Content Model.

EMPTY
public static final byte EMPTY

Element content type - No Children.

ID_ATTR_DECL
public static final int 
     ID_ATTR_DECL

Node flag to represent ID attribute declaration in a DTD.

MIXED
public static final byte MIXED

Element content type - Children can be PCDATA & elements; see Content Model.

OR
public static final int OR

ContentModelParseTreeNode type - "|" node (has two children).

PLUS
public static final int PLUS

ContentModelParseTreeNode type - "+" node (has one children).

QMARK
public static final int QMARK

ContentModelParseTreeNode type - "?" node (has one children).

Table 2-6  Summary of Methods of ElementDecl
Method Description

ElementDecl()

Default constructor.

cloneNode()

Returns a duplicate of this node; serves as a generic copy constructor for nodes.

expectedElements()

Returns vector of element names that can be appended to the element.

findAttrDecl()

Returns an attribute declaration object or null if not found

getAttrDecls()

Returns an enumeration of attribute declarations.

getContentElements()

Returns a vector of elements that can be appended to this element.

getContentType()

Returns the content model of element.

getNodeName()

Returns the name of the Element Decl.

getNodeType()

Returns a code representing the type of the underlying object.

getParseTree()

Returns the root node of Content Model Parse Tree.

readExternal()

Reads the information written in the compressed stream by writeExternal method and restores the object correspondingly. Throws the following exceptions:

validateContent()

Validates the content of a element node.

writeExternal()

Saves the state of the object by creating a binary compressed stream with information about this object.


ElementDecl()

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.

Syntax

public  ElementDecl();

cloneNode()

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.

Syntax

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

Parameter Description
deep

If true, recursively clone the subtree under the specified node; if false, clone only the node itself (and its attributes, if it is an Element)


expectedElements()

Returns vector of element names that can be appended to the element.

Syntax

public java.util.Vector expectedElements( org.w3c.dom.Element e);

Parameter Description
e

Element.


findAttrDecl()

Returns an attribute declaration object or null if not found

Syntax

public final AttrDecl findAttrDecl( String name);

Parameter Description
name

The attribute declaration to find.


getAttrDecls()

Returns an enumeration of attribute declarations.

Syntax

public org.w3c.dom.NamedNodeMap getAttrDecls();

getContentElements()

Returns a vector of elements that can be appended to this element.

Syntax

public final java.util.Vector getContentElements();

getContentType()

Returns the content model of element.

Syntax

public int getContentType();

getNodeName()

Returs the name of the Element Decl.

Syntax

public String getNodeName();

getNodeType()

Returns a code representing the type of the underlying object.

Syntax

public short getNodeType();

getParseTree()

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.

Syntax

public final org.w3c.dom.Node getParseTree();

readExternal()

Reads the information written in the compressed stream by writeExternal method and restores the object correspondingly. Throws the following exceptions:

Syntax

public void readExternal( java.io.ObjectInput in);

Parameter Description
in

The ObjectInput stream used for reading the compressed stream.


validateContent()

Validates the content of a element node; returns TRUE if valid, FLASE otherwise.

Syntax

public boolean validateContent(org.w3c.dom.Element e);

Parameter Description
e

Element node to validate.


writeExternal()

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.

Syntax

public void writeExternal( java.io.ObjectOutput out);

Parameter Description
out

The ObjectOutput stream used to write the serialized/ compressed stream.


XMLAttr Class

This class implements the DOM Attr interface and holds information on each attribute of an element. See also Attr, NodeFactory, DOMParser.setNodeFactory().

Syntax

public class XMLAttr implements oracle.xml.parser.v2.NSName, 
java.io.Externalizable

Table 2-7  Summary of Methods of XMLAttr
Method Description

addText()

Adds text to the XMLNode.

cloneNode()

Returns a duplicate of this node; serves as a generic copy constructor for nodes.

getExpandedName()

Returns the fully resolved Name for this attribute.

getLocalName()

Returns the local name of this attribute.

getName()

Returns the attribute name.

getNamespaceURI()

Returns the namespace of the attribute.

getNextAttribute()

Returns the next attribute, if any.

getNextSibling()

Returns the next sibling, if any.

getNodeType()

Returns a code representing the type of the underlying object.

getNodeValue()

Returns the value of this node, depending on its type.

getOwnerElement()

Returns the element which owns this attribute.

getParentNode()

Returns the parent of this node.

getPrefix()

Returns the name space prefix of the element.

getPreviousSibling()

Returns the previous sibling, if any.

getSpecified()

Returns TRUE if the attribute was specified explicitly in the element, FALSE otherwise.

getValue()

Returns the attribute value.

readExternal()

Restores the information written by writeExternal.

setNodeValue()

Sets the value of this node, depending on its type.

setValue()

Sets the value.

writeExternal()

Saves the state of the object in a binary compressed stream.


addText()

Adds text to the XMLNode.

Syntax

public XMLNode addText( String str);

Parameter Description
str

Text added.


cloneNode()

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.

Syntax

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

Parameter Description
deep

If true, recursively clone the subtree under the specified node; if false, clone only the node itself (and its attributes, if it is an Element).


getExpandedName()

Returns the fully resolved Name for this attribute.

Syntax

public String getExpandedName();

getLocalName()

Returns the local name of this attribute.

Syntax

public String getLocalName();

getName()

Returns the attribute name.

Syntax

public String getName();

getNamespaceURI()

Returns the namespace of the attribute.

Syntax

public String getNamespaceURI();

getNextAttribute()

Returns the next attribute, if any.

Syntax

public XMLAttr getNextAttribute();

getNextSibling()

Returns the next sibling, if any.

Syntax

public org.w3c.dom.Node getNextSibling();

getNodeType()

Returns a code representing the type of the underlying object.

Syntax

public short getNodeType();

getNodeValue()

Returns the value of this node, depending on its type. Throws DOMException:

Syntax

public String getNodeValue();

getOwnerElement()

Returns the element which owns this attribute.

Syntax

public org.w3c.dom.Element getOwnerElement();

getParentNode()

Returns the parent of this node. All nodes, except Document, DocumentFragment, and Attr may have a parent. However, if a node has just been created and not yet added to the tree, or if it has been removed from the tree, this is null.

Syntax

public org.w3c.dom.Node getParentNode();

getPrefix()

Returns the name space prefix of the element.

Syntax

public String getPrefix();

getPreviousSibling()

Returns the previous sibling, if any.

Syntax

public org.w3c.dom.Node getPreviousSibling();

getSpecified()

Returns TRUE if the attribute was specified explicitly in the element, FALSE otherwise.

Syntax

public boolean getSpecified();

getValue()

Returns the attribute value.

Syntax

public String getValue();

readExternal()

Restores the information written by writeExternal. Throws the following exceptions:

Syntax

public void readExternal( java.io.ObjectInput in);

Parameter Description
in

The ObjectInput stream used to read the compressed stream.


setNodeValue()

Sets the value of this node, depending on its type. Throws DOMException:

Syntax

public void setNodeValue( String nodeValue);

Parameter Description
nodeValue

The value of the node to be set.


setValue()

Sets the value.

Syntax

public void setValue( String val);

Parameter Description
val

The value to set.


writeExternal()

Saves the state of the object in a binary compressed stream. Throws IOException when there is an exception while writing the compressed stream.

Syntax

public void writeExternal( java.io.ObjectOutput out);

Parameter Description
out

The ObjectOutput stream used to write the compressed stream.


XMLCDATA Class

This class implements the DOM CDATASection interface. See also CDATASection, NodeFactory, DOMParser.setNodeFactory(NodeFactory).

Syntax

public class XMLCDATA implements java.io.Externalizable

Table 2-8  Summary of Methods of XMLCDATA
Method Description

XMLCDATA()

Default constructor.

getNodeName()

Returns the name of the node.

getNodeType()

Returns a code representing the type of the underlying object.

readExternal()

Reads the information written in the compressed stream by writeExternal() method and restores the object correspondingly.

writeExternal()

Saves the state of the object by creating a binary compressed stream with information about this object.


XMLCDATA()

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.

Syntax

public  XMLCDATA();

getNodeName()

Returns the name of the node.

Syntax

public String getNodeName();

getNodeType()

Returns a code representing the type of the underlying object.

Syntax

public short getNodeType();

readExternal()

Reads the information written in the compressed stream by writeExternal() method and restores the object correspondingly. Throws the following exceptions:

Syntax

public void readExternal( java.io.ObjectInput in);

Parameter Description
in

The ObjectInput stream used for reading the compressed stream.


writeExternal()

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 compressed stream.

Syntax

public void writeExternal( java.io.ObjectOutput out);

Parameter Description
out

The ObjectOutput stream used to write the compressed stream.


XMLComment Class

This class implements the DOM Comment interface. See also Comment, NodeFactory, DOMParser.setNodeFactory().

Syntax

public class XMLComment implements java.io.Externalizable

Table 2-9  Summary of XMLComment
Method Description

XMLComment()

Default constructor. Note that this constructor is used only during deserialization/decompression of this DOM node.

addText()

Adds the comment text.

getNodeName()

Returns a name of the node.

getNodeType()

Returns a code representing the type of the underlying object.

readExternal()

Reads the information in the compressed stream and restores the object correspondingly.

reportSAXEvents()

Reports SAX Events from a DOM Tree.

writeExternal()

Saves the state of the object by creating a binary compressed stream with information about this object.


XMLComment()

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.

Syntax

public  XMLComment();

addText()

Adds the comment text.

Syntax

public XMLNode addText( String str);

Parameter Description
str

The comment text.


getNodeName()

Returns a name of the node.

Syntax

public String getNodeName();

getNodeType()

Returns a code representing the type of the underlying object.

Syntax

public short getNodeType();

readExternal()

Reads the information written in the compressed stream by writeExternal() method and restores the object correspondingly. Throws the following exceptions:

Syntax

public void readExternal( java.io.ObjectInput in);

Parameter Description
in

The ObjectInput stream used for reading the compressed stream.


reportSAXEvents()

Reports SAX Events from a DOM Tree. Throws SAXException.

Syntax

public void reportSAXEvents( org.xml.sax.ContentHandler cntHandler);

Parameter Description
cntHandler

Content handler.


writeExternal()

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 compressed stream.

Syntax

public void writeExternal( java.io.ObjectOutput out);

Parameter Description
out

The ObjectOutput stream used to write the compressed stream.


XMLDeclPI Class

This class implements the XML Decl Processing Instruction. See also XMLPI Class.

Syntax

public class XMLDeclPI extends oracle.xml.parser.v2.XMLPI implements 
java.io.Externalizable

Table 2-10  Summary of Methods of XMLDeclPI
Method Description

XMLDeclPI()

Creates a new instance of XMLDeclPI.

cloneNode()

Returns a duplicate of this node; serves as a generic copy constructor.

getData()

Returns the fully constructed string 'version=1.0....'.

getEncoding()

Returns the character encoding information, or the encoding information stored in the <?xml...?> tag or the user-defined output encoding if it has been more recently set.

getNodeValue()

Returns the value of this node.

getStandalone()

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

getVersion()

Retrieves the version information, or the version number stored in the <?xml...?> tag.

readExternal()

Reads the information written in the compressed stream by writeExternal method and restores the object correspondingly. Throws the following exceptions:

setEncoding()

Sets the character encoding for output.

setStandalone()

Sets the standalone information stored in the <?xml...?> tag

setVersion()

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

writeExternal()

Saves the state of the object by creating a binary compressed stream with information about this object.


XMLDeclPI()

Creates a new instance of XMLDeclPI. The options are described in the following table.

Syntax Description
public XMLDeclPI();

Creates a new instance of XMLDeclPI; default constructor.

public XMLDeclPI(
     String version,
     String encoding,
     String standalone,
     boolean textDecl)

Creates a new instance of XMLDeclP using version, encoding, standalone, and textDecl information.


Parameter Description
version

The version used in creating a new XMLDeclPI.

encoding

The encoding used in creating a new XMLDeclPI.

standaolone

Specifies if the new XMLDeclPI is standalone.

textDecl

the text declaration of the new XMLDeclPI.


cloneNode()

Returns a duplicate of this node; serves as a generic copy constructor.

Syntax

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

Parameter Description
deep

If true, recursively clone the subtree under the specified node; if false, clone only the node itself (and its attributes, if it is an Element).


getData()

Returns the fully constructed string 'version=1.0....' Throws DOMException:

Syntax

public String getData();

getEncoding()

Returns the character encoding information, or the encoding information stored in the <?xml...?> tag or the user-defined output encoding if it has been more recently set.

Syntax

public final String getEncoding();

getNodeValue()

Returns the value of this node. Throws DOMException:

Syntax

public String getNodeValue();

getStandalone()

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

Syntax

public final String getStandalone();

getVersion()

Retrieves the version information, or the version number stored in the <?xml...?> tag.

Syntax

public final String getVersion();

readExternal()

Reads the information written in the compressed stream by writeExternal method and restores the object correspondingly. Throws the following exceptions:

Syntax

public void readExternal( java.io.ObjectInput in);

Parameter Description
in

The ObjectInput stream used for reading the compressed stream.


setEncoding()

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.

Syntax

public final void setEncoding( String encoding);

Parameter Description
encoding

The character encoding to set.


setStandalone()

Sets the standalone information stored in the <?xml...?> tag

Syntax

public final boolean setStandalone( String value);

Parameter Description
value

Specifies if the XMLDeclPI class is standalone: TRUE for yes or FALSE for no.


setVersion()

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

Syntax

public final void setVersion( String version);

Parameter Description
version

The version information to set.


writeExternal()

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 compressed stream.

Syntax

public void writeExternal( java.io.ObjectOutput out);

Parameter Description
out

The ObjectOutput stream used to write the compressed stream.


XMLDocument Class

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.

Syntax

public class XMLDocument implements java.io.Externalizable

Table 2-11  Summary of Methods of XMLDocument
Method Description

XMLDocument()

Creates an empty document.

addID()

Adds an ID Element associated with this document.

adoptNode()

Adopts a node from another document to this document.

appendChild()

Appends a new node to the document. T

cloneNode()

Returns a duplicate of this node; serves as a generic copy constructor for nodes

createAttribute()

Creates an Attr of the given name.

createAttributeNS()

Creates an attribute with the given qualified name and namespace URI.

createCDATASection()

Creates a CDATASection node whose value is the specified string.

createComment()

Creates a Comment node given the specified string.

createDocumentFragment()

Creates an empty DocumentFragment object.

createElement()

Creates an element of the type specified.

createElementNS()

Creates an element of the given qualified name and namespace URI.

createEntityReference()

Creates an EntityReference object.

createEvent()

Creates an event object of the specified type.

createMutationEvent()

Creates a Mutation Event object of specified type.

createNodeIterator()

Creates a Node Iterator with specified root, flag which governs what type of nodes it should include in logical view, filter for filtering nodes, flag determining whether entity references and its descendants could be included.

createProcessingInstruction()

Creates a ProcessingInstruction node given the specified name and data strings. Throws DOMException:

createRange()

Creates a new Document Range Object, with Start and End Boundary points at the beginning of the document.

createRangeEvent()

Creates a Range Event object of specified type.

createTextNode()

Creates a Text node given the specified string.

createTraversalEvent()

Creates a Traversal Event object of specified type.

createTreeWalker()

Creates a Node Iterator with specified root, flag which governs what type of nodes it should include in logical view, filter for filtering nodes, flag determining whether entity references and its descendants could be included.

expectedElements()

Returns vector of element names that can be appended to the element.

getColumnNumber()

Returns column number debug information.

getDebugMode()

Returns the debug flag.

getDoctype()

Returns the Document Type Declaration (DTD) associated with this document.

getDocumentElement()

Accesses the child node that is the root element of the document.

getElementById()

Returns the Element whose ID is given by elementId.

getElementsByTagName()

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.

getElementsByTagNameNS()

Returns a NodeList of all the Elements with a given local name and namespace URI in the order in which they are encountered in a preorder traversal of the Document tree.

getEncoding()

Returns the character encoding information stored in the <?xml...?> tag or the user-defined output encoding if it has been more recently set.

getIDHashtable()

Returns the ID element hashtable in the XML DOM Tree.

getImplementation()

Returns the DOMImplementation object that handles this document.

getLineNumber()

Returns line number debug information.

getNodeType()

Returns a code representing the type of the underlying object.

getOwnerDocument()

Returns the Document object associated with this node.

getStandalone()

Retrieves the standalone information; this is the standalone attribute stored in the <?xml...?> tag.

getSystemId()

Returns the system id of the entity contain this node.

getText()

Returns the non-marked-up text contained by this element.

getVersion()

Retrieves the version information stored in the <?xml...?> tag.

importNode()

Imports a node from another document to this document.

insertBefore()

Inserts the node newChild before the existing child node refChild.

print()

Writes the contents of this document to the given output.

printExternalDTD()

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

readExternal()

Reads the information written in the compressed stream by writeExternal method and restores the object correspondingly.

removeChild()

Removes the elem from this documents list of child nodes.

replaceChild()

Replaces the child node oldChild with newChild in the list of children, and returns the oldChild node.

reportSAXEvents()

Reports SAX Events from a DOM Tree.

setDoctype()

Sets the doctype URI for the document.

setEncoding()

Sets the character encoding for output.

setLocale()

Sets the locale for error reporting.

setNodeContext()

Sets node context.

setParsedDoctype()

Sets the doctype object by parsing sysid.

setStandalone()

Sets the standalone information stored in the <?xml...?> tag.

setVersion()

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

validateElementContent()

Validates the content of a element node.

writeExternal()

Saves the state of the object by creating a binary compressed stream with information about this object.


XMLDocument()

Creates an empty document.

Syntax

public  XMLDocument();

addID()

Adds an ID Element associated with this document.

Syntax

public void addID( String name,
                   XMLElement e);

Parameter Description
id

The id value.

e

XMLElement associated with id.


adoptNode()

Adopts a node from another document to this document. The returned node has no parent; parentNode is null. The source node is removed from the original document. Throws DOMException

Syntax

public org.w3c.dom.Node adoptNode( org.w3c.dom.Node srcNode);

Parameter Description
srcNode

Node to be adopted.


appendChild()

Appends a new node to the document. Throws DOMException:

Syntax

public org.w3c.dom.Node appendChild( org.w3c.dom.Node newNode);

Parameter Description
newNode

The new node to be added.


cloneNode()

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.

Syntax

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

Parameter Description
deep

If true, recursively clone the subtree under the specified node; if false, clone only the node itself (and its attributes, if it is an Element).


createAttribute()

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

Syntax

public org.w3c.dom.Attr createAttribute( String name);

Parameter Description
name

The name of the new attribute.


createAttributeNS()

Creates an attribute with the given qualified name and namespace URI. Throws DOMException:

Syntax

public org.w3c.dom.Attr createAttributeNS( String namespaceURI,
                                           String qualifiedName);

Parameter Description
namespaceURI 

Namespace of the attribute/element to be created.

qualifiedName

Qualified name of the attribute/element to be created.


createCDATASection()

Creates a CDATASection node whose value is the specified string. Throws DOMException.

Syntax

public org.w3c.dom.CDATASection createCDATASection( String data);

Parameter Description
data

The data for the CDATASection contents.


createComment()

Creates a Comment node given the specified string.

Syntax

public org.w3c.dom.Comment createComment( String data);

Parameter Description
data

The data for the node.


createDocumentFragment()

Creates an empty DocumentFragment object.

Syntax

public org.w3c.dom.DocumentFragment createDocumentFragment();

createElement()

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. Throws DOMException:

Syntax

public org.w3c.dom.Element createElement( String tagName);

Parameter Description
tagName

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


createElementNS()

Creates an element of the given qualified name and namespace URI. Throws DOMException:

Syntax

public org.w3c.dom.Element createElementNS( String namespaceURI,
                                            String qualifiedName);

Parameter Description
namespaceURI

Namespace of the attribute/element to be created.

qualifiedName

Qualified name of the attribute/element to be created.


createEntityReference()

Creates an EntityReference object. Throws DOMException:

Syntax

public org.w3c.dom.EntityReference createEntityReference( String name);

Parameter Description
name

The name of the entity to reference.


createEvent()

Creates an event object of the specified type.

Syntax

public org.w3c.dom.events.Event createEvent( String type);

Parameter Description
type

The type of the event.


createMutationEvent()

Creates a Mutation Event object of specified type.

Syntax

public org.w3c.dom.events.MutationEvent createMutationEvent( String type);

Parameter Description
type

The type of the mutation event.


createNodeIterator()

Creates a Node Iterator with specified root, flag which governs what type of nodes it should include in logical view, filter for filtering nodes, flag determining whether entity references and its descendants could be included. Throws DOMException:

Syntax

public org.w3c.dom.traversal.NodeIterator createNodeIterator(
                           org.w3c.dom.Node root,
                           int whatToShow,
                           org.w3c.dom.traversal.NodeFilter filter,
                           boolean expandEntityReferences);

Parameter Description
root

Root node of the iterator.

whatToShow 

Flag indicating what type of nodes will be included in the iterator/tree walker.

filter 

NodeFilter to filter unwanted nodes from the iterator/tree walker.

expandEntityReference 

Flag to indicate traversal of entity references.


createProcessingInstruction()

Creates a ProcessingInstruction node given the specified name and data strings. Throws DOMException:

Syntax

public org.w3c.dom.ProcessingInstruction createProcessingInstruction( 
                      String target,
                      String data);

Parameter Description
target 

The target part of the processing instruction.

data

The data for the node.


createRange()

Creates a new Document Range Object, with Start and End Boundary points at the beginning of the document.

Syntax

public org.w3c.dom.ranges.Range createRange();

createRangeEvent()

Creates a Range Event object of specified type.

Syntax

public org.w3c.dom.events.Event createRangeEvent( String type);

Parameter Description
type

The type of the Range event.


createTextNode()

Creates a Text node given the specified string.

Syntax

public org.w3c.dom.Text createTextNode( String data);

Parameter Description
data

The data of the node.


createTraversalEvent()

Creates a Traversal Event object of specified type.

Syntax

public org.w3c.dom.events.Event createTraversalEvent( String type);

Parameter Description
type

The type of the traversal event.


createTreeWalker()

Creates a Node Iterator with specified root, flag which governs what type of nodes it should include in logical view, filter for filtering nodes, flag determining whether entity references and its descendants could be included. Throws DOMException:

Syntax

public org.w3c.dom.traversal.TreeWalker createTreeWalker(
                           org.w3c.dom.Node root,
                           int whatToShow,
                           org.w3c.dom.traversal.NodeFilter filter,
                           boolean expandEntityReferences);

Parameter Description
root

Root node of the iterator.

whatToShow 

Flag indicating what type of nodes will be included in the iterator/tree walker.

filter

NodeFilter to filter unwanted nodes from the iterator/tree walker.

expandEntityReference

Flag to indicate traversal of entity references.


expectedElements()

Returns vector of element names that can be appended to the element.

Syntax

public java.util.Vector expectedElements( org.w3c.dom.Element e);

Parameter Description
e

Element


getColumnNumber()

Returns column number debug information.

Syntax

public int getColumnNumber();

getDebugMode()

Returns the debug flag.

Syntax

public boolean getDebugMode();

getDoctype()

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

Syntax

public org.w3c.dom.DocumentType getDoctype();

getDocumentElement()

Accesses the child node that is the root element of the document.

Syntax

public org.w3c.dom.Element getDocumentElement();

getElementById()

Returns the Element whose ID is given by elementId. If no such element exists, returns null. Behavior is not defined if more than one element has this ID.

Syntax

public org.w3c.dom.Element getElementById( String elementId);

Parameter Description
elementId

The elementId used to get the matching Id Element.


getElementsByTagName()

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.

Syntax

public org.w3c.dom.NodeList getElementsByTagName( String tagname);

Parameter Description
tagname

The name of the tag to match on. The special value "*" matches all tags.


getElementsByTagNameNS()

Returns a NodeList of all the Elements with a given local name and namespace URI in the order in which they are encountered in a preorder traversal of the Document tree.

Syntax

public org.w3c.dom.NodeList getElementsByTagNameNS( String namespaceURI,
                                                    String localName);

Parameter Description
namespaceURI

Namespace of the elements requested.

localName 

Local name of the element requested.


getEncoding()

Returns the character encoding information stored in the <?xml...?> tag or the user-defined output encoding if it has been more recently set.

Syntax

public final String getEncoding();

getIDHashtable()

Returns the ID element hashtable in the XML DOM Tree.

Syntax

public java.util.Hashtable getIDHashtable();

getImplementation()

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

Syntax

public org.w3c.dom.DOMImplementation getImplementation();

getLineNumber()

Returns line number debug information.

Syntax

public int getLineNumber();

getNodeType()

Returns a code representing the type of the underlying object.

Syntax

public short getNodeType();

getOwnerDocument()

Returns the Document object associated with this node. Since this node is a Document, this is null.

Syntax

public org.w3c.dom.Document getOwnerDocument();

getStandalone()

Retrieves the standalone information; this is the standalone attribute stored in the <?xml...?> tag.

Syntax

public final String getStandalone();

getSystemId()

Returns the system id of the entity contain this node.

Syntax

public String getSystemId();

getText()

Returns the non-marked-up text contained by this element. For text elements, this is the raw data. For elements with child nodes, this method traverses the entire subtree and appends the text for each terminal text element, effectively stripping out the XML markup for the subtree. For example, if the XML document contains "William Shakespeare", XMLDocument.getText returns "William Shakespeare".

Syntax

public String getText();

getVersion()

Retrieves the version information stored in the <?xml...?> tag.

Syntax

public final String getVersion();

importNode()

Imports a node from another document to this document. The returned node has no parent; (parentNode is null). The source node is not altered or removed from the original document. For all nodes, importing a node creates a node object owned by the importing document, with attribute values identical to the source node's nodeName and nodeType, plus the attributes related to namespaces (prefix, localName, and namespaceURI). Throws DOMException:

Syntax

public org.w3c.dom.Node importNode( org.w3c.dom.Node importedNode,
                                    boolean deep);

Parameter Description
importedNode

Node to be imported.

deep

Indicates whether the descen.dants of this node are to be imported.


insertBefore()

Inserts the node newChild before the existing child node refChild. If refChild is null, insert newChild at the end of the list of children. If newChild is a DocumentFragment object, all of its children are inserted, in the same order, before refChild. If the newChild is already in the tree, it is first removed. Throws DOMException:

Syntax

public org.w3c.dom.Node insertBefore( org.w3c.dom.Node newChild,
                                      org.w3c.dom.Node refChild);

Parameter Description
newChild

The node to insert.

refChild

The reference node, or the node before which the new node must be inserted.


print()

Writes the contents of this document to the given output. Throws IOException. The options are described in the following table.

Syntax Description
public void print(
     java.io.OutputStream out);

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

public void print(
     java.io.OutputStream out,
     String enc);

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

public void print(
     java.io.PrintWriter out);

Writes the contents of this document to the given print writer.

public void print(
    PrintDriver pd);

Writes the contents of this document to the given print driver.


Parameter Description
out

Output to write to.

enc

Encoding to use for the output.

pd

PrintDriver used to write each node.


printExternalDTD()

Writes the contents of this document to the given output stream. Throws IOException. The options are described in the following table.

Syntax Description
public void printExternalDTD(
     java.io.OutputStream out);

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

public void printExternalDTD(
     java.io.OutputStream out,
     String enc);

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

public void printExternalDTD(
     java.io.PrintWriter out);

Writes the contents of this document to the given print writer.


Parameter Description
out 

the output to write to.

enc 

Encoding to use for the output.


readExternal()

Reads the information written in the compressed stream by writeExternal method and restores the object correspondingly. Throws the following exceptions:

Syntax

public void readExternal( java.io.ObjectInput in);

Parameter Description
in

The ObjectInput stream used for reading the compressed stream.


removeChild()

Removes the elem from this documents list of child nodes. Throws DOMException:

Syntax

public org.w3c.dom.Node removeChild( org.w3c.dom.Node elem);

Parameter Description
elem

The element to be removed.


replaceChild()

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. Throws DOMException:

Syntax

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

Parameter Description
newChild

The new node to put in the child list.

oldChild

he node being replaced in the list.


reportSAXEvents()

Reports SAX Events from a DOM Tree. Throws a SAXException.

Syntax

public void reportSAXEvents( org.xml.sax.ContentHandler cntHandler);

Parameter Description
cntHandler

The content handler.


setDoctype()

Sets the doctype URI for the document.

Syntax

public void setDoctype( String rootname,
                        String sysid,
                        String pubid);

Parameter Description
root

The name of the root element.

sysid 

The system id of the doctype.

pubid 

The public id of the doctype (can be null).


setEncoding()

Sets the character encoding for output. Eventually it sets the ENCODING stored in the <?xml...?> tag, but not until the document is saved. This method should not be called until the Document has been loaded.

Syntax

public final void setEncoding( String encoding);

Parameter Description
encoding

The character encoding to set.


setLocale()

Sets the locale for error reporting.

Syntax

public final void setLocale( java.util.Locale locale);

Parameter Description
locale

Locale for error reporting.


setNodeContext()

Sets node context.

Syntax

public void setNodeContext( oracle.xml.util.NodeContext nctx);

Parameter Description
nctx

The context to set.


setParsedDoctype()

Sets the doctype object by parsing sysid.

Syntax

public void setParsedDoctype( String rootname,
                              String sysid,
                              String pubid);

Parameter Description
root 

The name of the root element.

sysid

The system id of the doctype.

pubid

The public id of the doctype (can be null),.


setStandalone()

Sets the standalone information stored in the <?xml...?> tag.

Syntax

public final void setStandalone( String value);

Parameter Description
value

The attribute value.


setVersion()

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

Syntax

public final void setVersion( String version);

Parameter Description
version

The version information to set.


validateElementContent()

Validates the content of a element node. Returns TRUE if valid, FALSE otherwise.

Syntax

public boolean validateElementContent( org.w3c.dom.Element elem);

Parameter Description
elem

Element to be validated.


writeExternal()

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.

Syntax

public void writeExternal( java.io.ObjectOutput out);

Parameter Description
out

The ObjectOutput stream used to write the serialized/ compressed stream.


XMLDocumentFragment Class

This class implements the DOM DocumentFragment interface. Extends XMLElement rather than XMLNode so it can be handled as an element. See also DocumentFragment, NodeFactory, DOMParser.setNodeFactory().

Syntax

public class XMLDocumentFragment implements java.io.Serializable

Table 2-12 Summary of Methods of XMLDocumentFragment
Method Description

getAttributes()

Returns the attributes of the XMLDocumentFragment.

getNodeType()

Returns a code representing the type of the underlying object.

getParentNode()

Returns the parent of this node.


getAttributes()

Returns the attributes of the XMLDocumentFragment - an empty NamedNodeMap.

Syntax

public org.w3c.dom.NamedNodeMap getAttributes();

getNodeType()

Returns a code representing the type of the underlying object.

Syntax

public short getNodeType();

getParentNode()

Returns the parent of this node.

Syntax

public org.w3c.dom.Node getParentNode();

XMLDOMException Class

This class is used to throw DOM exceptions.

Syntax

public class XMLDOMException


XMLDOMException()

Constructs an XMLDOMException exception. The options are described in the following table.

Syntax Description
public XMLDOMException(
    short code);

Constructs an XMLDOMException exception with a specified code.

public XMLDOMException(
     short code,
     String mess);

Constructs an XMLDOMException exception with a specified message and an error code.


Parameter Description
code

Code indicated in DOM interface, uses default message

mess

Message used in constructing the XMLDOMException


XMLDOMImplementation

This class implements the DOMImplementation

Syntax

public class XMLDOMImplementation implements java.io.Serializable

Table 2-13  Summary of Methods of XMLDOMImplementation
Method Description

XMLDOMImplementation()

Creates a new instance of XMLDOMImplementation.

createDocument()

Creates an XMLDocument object containing the specified DocumentType Node and a root element with the specified names and the empty DocumentType node.

createDocumentType()

Creates an empty DocumentType node with root element name and system/public identifier.

hasFeature()

Tests if the DOM implementation implements a specific feature.

setFeature()

Sets a specified feature.


XMLDOMImplementation()

Creates a new instance of XMLDOMImplementation.

Syntax

public  XMLDOMImplementation();

createDocument()

Creates an XMLDocument object containing the specified DocumentType Node and a root element with the specified names and the empty DocumentType node. Throws DOMException:

Syntax

public org.w3c.dom.Document createDocument( String namespaceURI,
                                            String qualifiedName,
                                            org.w3c.dom.DocumentType doctype);

Parameter Description
namespaceURI

Namespace of the root element in the document.

qualifiedName

Qualified name of the root element in the document.

doctype

DocumentType (DTD) associated with the document.


createDocumentType()

Creates an empty DocumentType node with root element name and system/public identifier. Returns the DocumentType object created. Throws DOMException:

Syntax

public org.w3c.dom.DocumentType createDocumentType( String qualifiedName,
                                                    String publicId,
                                                    String systemId);

Parameter Description
qualifiedName 

Qualified name of the root element.

systemid

System identifier of the DocumentType node.

publicid

Public identifier of the DocumentType node.


hasFeature()

Tests if the DOM implementation implements a specific feature. Returns TRUE if the feature is implemented, FALSE otherwise.

Syntax

public boolean hasFeature( String feature,
                           String version);

Parameter Description
feature

The feature being tested.

version

The version of the feature being tested.


setFeature()

Sets a specified feature. Throws a DOMException if the feature could not be set.

Syntax

public void setFeature( String feature);

Parameter Description
feature

The DOM feature.


XMLElement Class

This class implements the DOM Element Interface.

Syntax

public class XMLElement implements oracle.xml.parser.v2.NSName, 
oracle.xml.parser.v2.NSResolver, java.io.Externalizable

Table 2-14  Summary of Methods of XMLElement
Method Description

XMLElement()

Default constructor.

cloneNode()

Returns a duplicate of this node; serves as a generic copy constructor for nodes.

getAttribute()

Returns an attribute value by name; if that attribute does not have a specified or default value, returns an empty string.

getAttributeNode()

Returns an Attr node by name, or NULL if there is no such attribute.

getAttributeNodeNS()

Returns attribute with the given namespaceURI and localName if it exists; otherwise, returns NULL.

getAttributeNS()

Returns the value of the attribute with namespace URI and localName, if it exists; threshed, returns NULL.

getAttributes()

Returns a NamedNodeMap containing the attributes of this node (if it is an Element) or null otherwise.

getChildrenByTagName()

Returns a NodeList of all immediate children with a given tag name. The options are described in the following table.

getElementsByTagName()

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.

getElementsByTagNameNS()

Returns a NodeList of all the descendant Elements with a given local name and namespace URI in the order in which they are encountered in a preorder traversal of this Element tree.

getExpandedName()

Returns the fully resolved name for this element.

getFirstAttribute()

Retrieves the first Attr node, or NULL if there is no attribute.

getLocalName()

Returns the local Name for this element.

getNamespaceURI()

Returns the name space URI of this element.

getNodeType()

Returns a code representing the type of the underlying object.

getPrefix()

Returns the namespace prefix for this element.

getQualifiedName()

Returns the qualified name for this element.

getTagName()

Returns the name of the element.

hasAttribute()

Returns TRUE when an attribute with a given name is specified on this element or has a default value.

hasAttributeNS()

Returns TRUE when an attribute with a given local name and namespace URI is specified on this element or has a default value.

hasAttributes()

Returns TRUE if this node has any attributes.

readExternal()

Restores the information written by writeExternal() by reading the input stream and regenerating the objects according to the information of the input stream.

removeAttribute()

Removes an attribute by name.

removeAttributeNode()

Removes and returns the specified attribute.

removeAttributeNS()

Removes an attribute by local name and namespace URI.

reportSAXEvents()

Reports SAX Events from a DOM Tree.

resolveNamespacePrefix()

Finds the namespace definition in scope in this element, given a namespace prefix.

setAttribute()

Adds a new attribute.

setAttributeNode()

Adds a new attribute node.

setAttributeNodeNS()

Adds a new namespace aware attribute node.

validateContent()

Validates the content of a element node.

writeExternal()

Saves the state of the object by creating a binary compressed stream with information about this object.


XMLElement()

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. For all normal XMLElement creation use createElement() of XMLDocument.

Syntax

public  XMLElement();

cloneNode()

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.

Syntax

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

Parameter Description
true

If true, recursively clone the subtree under the specified node; if false, clone only the node itself (and its attributes, if it is an Element).


getAttribute()

Returns an attribute value by name; if that attribute does not have a specified or default value, returns an empty string.

Syntax

public String getAttribute( String name);

Parameter Description
name

The name of the attribute to retrieve.


getAttributeNode()

Returns an Attr node by name, or NULL if there is no such attribute.

Syntax

public org.w3c.dom.Attr getAttributeNode( String name);

Parameter Description
name

The name of the attribute node to retrieve.


getAttributeNodeNS()

Returns attribute with the given namespaceURI and localName if it exists; otherwise, returns NULL.

Syntax

public org.w3c.dom.Attr getAttributeNodeNS( String namespaceURI,
                                            String localName);

Parameter Description
namespaceURI 

Namespace of the attribute node requested.

localName

Local name of the attribute node requested.


getAttributeNS()

Returns the value of the attribute with namespace URI and localName, if it exists; threshed, returns NULL.

Syntax

public String getAttributeNS( String namespaceURI,
                              String localName);

Parameter Description
namespaceURI 

Namespace of the attribute requested.

localName

Local name of the attribute requested.


getAttributes()

Returns a NamedNodeMap containing the attributes of this node (if it is an Element) or null otherwise.

Syntax

public org.w3c.dom.NamedNodeMap getAttributes();

getChildrenByTagName()

Returns a NodeList of all immediate children with a given tag name. The options are described in the following table.

Syntax Description
public org.w3c.dom.NodeList
getChildrenByTagName(
     String name);

Returns a NodeList of all immediate children with a given tag name.

public org.w3c.dom.NodeList
getChildrenByTagName(
    String name,
    String ns);

Returns a NodeList of all immediate children with a given tag name and namespace.


Parameter Description
name 

The name of the tag to match on (should be local name).

ns

The name space.


getElementsByTagName()

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.

Syntax

public org.w3c.dom.NodeList getElementsByTagName( String tagname);

Parameter Description
tagname

The name of the tag to match on. The special value "*" matches all tags.


getElementsByTagNameNS()

Returns a NodeList of all the descendant Elements with a given local name and namespace URI in the order in which they are encountered in a preorder traversal of this Element tree.

Syntax

public org.w3c.dom.NodeList getElementsByTagNameNS( String namespaceURI,
                                                    String localName);

Parameter Description
namespaceURI

The namespace of the element.

localName 

The local name of the element.


getExpandedName()

Returns the fully resolved name for this element.

Syntax

public String getExpandedName();

getFirstAttribute()

Retrieves the first Attr node, or NULL if there is no attribute.

Syntax

public XMLNode getFirstAttribute();

getLocalName()

Returns the local Name for this element.

Syntax

public String getLocalName();

getNamespaceURI()

Returns the name space URI of this element.

Syntax

public String getNamespaceURI();

getNodeType()

Returns a code representing the type of the underlying object.

Syntax

public short getNodeType();

getPrefix()

Returns the namespace prefix for this element.

Syntax

public String getPrefix();

getQualifiedName()

Returns the qualified name for this element.

Syntax

public String getQualifiedName();

getTagName()

Returns the name of the element. For example, in: <elementExample id="demo">... </elementExample>, tagName has the value elementExample. Note that this is case-preserving in XML, as are all of the operations of the DOM. The HTML DOM returns the tagName of an HTML element in the canonical uppercase form, regardless of the case in the source HTML document.

Syntax

public String getTagName();

hasAttribute()

Returns TRUE when an attribute with a given name is specified on this element or has a default value, FALSE otherwise.

Syntax

public boolean hasAttribute( String name);

Parameter Description
name

Name of the attribute whose presence is checked


hasAttributeNS()

Returns TRUE when an attribute with a given local name and namespace URI is specified on this element or has a default value; returns FALSE otherwise.

Syntax

public boolean hasAttributeNS( String namespaceURI,
                               String localName);

Parameter Description
namespaceURI

Namespace of the attribute whose presence is checked.

localName

Local name of the attribute whose presence is checked.


hasAttributes()

Returns TRUE if this node has any attributes, FALSE otherwise.

Syntax

public boolean hasAttributes();

readExternal()

Restores the information written by writeExternal by reading the input stream and regenerating the objects according to the information of the input stream. Throws the following exceptions:

Syntax

public void readExternal( java.io.ObjectInput in);

Parameter Description
in

ObjectInput stream used to read the compressed stream.


removeAttribute()

Removes an attribute by name. If the removed attribute has a default value it is immediately replaced. Throws DOMException:

Syntax

public void removeAttribute( String name);

Parameter Description
name

Name of the attribute to remove.


removeAttributeNode()

Removes and returns the specified attribute. Throws DOMException:

Syntax

public org.w3c.dom.Attr removeAttributeNode( org.w3c.dom.Attr oldAttr);

Parameter Description
oldAttr 

The Attr node to remove from the attribute list. If the removed Attr has a default value it is immediately replaced.


removeAttributeNS()

Removes an attribute by local name and namespace URI. Throws DOMEXception:

Syntax

public void removeAttributeNS( String namespaceURI,
                               String localName);

Parameter Description
namespaceURI

Namespace of the attribute to be removed.

localName

Local name of the attribute to be removed.


reportSAXEvents()

Report SAX Events from a DOM Tree. Throws SAXException.

Syntax

public void reportSAXEvents( org.xml.sax.ContentHandler cntHandler);

Parameter Description
cntHandler

The Content Handler.


resolveNamespacePrefix()

Finds the namespace definition in scope in this element, given a namespace prefix.

Syntax

public String resolveNamespacePrefix( String prefix);

Parameter Description
prefix

Namespace prefix to be resolved if the prefix; if default, returns the default namespace


setAttribute()

Adds a new attribute. If an attribute with that name is already present in the element, its value is changed to be that of the value parameter. This value is a simple string, it is not parsed as it is being set. So any markup (such as syntax to be recognized as an entity reference) is treated as literal text, and needs to be appropriately escaped by the implementation when it is written out. In order to assign an attribute value that contains entity references, the user must create an Attr node plus any Text and EntityReference nodes, build the appropriate subtree, and use setAttributeNode to assign it as the value of an attribute. This method is namespace unaware and hence wont result in update of namespace table if a new attr is added through this method. Throws DOMException:

Syntax

public void setAttribute( String name,
                          String value);

Parameter Description
name

The name of the attribute to create or alter.

value

Value to set in string form.


setAttributeNode()

Adds a new attribute. If an attribute with that name is already present in the element, it is replaced by the new one. If the newAttr attribute replaces an existing attribute with the same name, the previously existing Attr node is returned, otherwise null is returned. Throws DOMException:

Syntax

public org.w3c.dom.Attr setAttributeNode ( org.w3c.dom.Attr newAttr);

Parameter Description
newAttr

Attribute to be added to the attribute list.


setAttributeNodeNS()

Adds a new attribute. Throws DOMException:

The options are described in the following table.

Syntax Description
public org.w3c.dom.Attr  
setAttributeNodeNS(
     org.w3c.dom.Attr newAttr);

Adds and returns a new attribute node. If an attribute with that local name and that namespace URI is already present in the element, it is replaced by the new one.

public void setAttributeNS(
     String namespaceURI, 
     String qualifiedName, 
     String value);

Constructs a new attribute node from nemespaceURI, qualifiedName, and value, and adds it. If an attribute with the same local name and namespace URI is already present on the element, its prefix is changed to be the prefix part of the qualifiedName, and its value is changed to be the value parameter. This value is a simple string; it is not parsed as it is being set. Therefore, any markup (such as syntax to be recognized as an entity reference) is treated as literal text, and needs to be appropriately escaped by the implementation when it is written out.


Parameter Description
newAttr

Attribute to be added to the attribute list.

namespaceURI

Namespace of the attribute to be added.

localName 

Local name of the attribute to be added.

value

Value of the attribute to be added.


validateContent()

Validates the content of a element node. Returns TRUE if valid, FALSE otherwise. The options are described in the following table.

Syntax Description
public boolean validateContent(
     DTD dtd);

Validates the content of a element node using the DTD.

public boolean validateContent(
      oracle.xml.parser.schema.XMLSchema schema);

Validates the content of the element node against given XML Schema param schema.

public boolean validateContent(
      oracle.xml.parser.schema.XMLSchema schema,
      String mode);

Validates the content of the element against given XML Schema in the given mode.


Parameter Description
dtd

The DTD object used to validate the element.

schema

The XMLSchema object used to validate the element.

mode

The validation mode.


writeExternal()

Saves the state of the object by creating a binary compressed stream with information about this object.

Syntax

public void writeExternal( java.io.ObjectOutput out);

Parameter Description
out

The ObjectOutput stream used to write the serialized/compressed


XMLEntity Class

This class implements the DOM Entity interface and represents an XML internal or external entity as defined in the XML Document Type Definition (DTD).

Syntax

public class XMLEntity implements java.io.Externalizable

Table 2-15  Summary of Methods of XMLEntity
Method Description

XMLEntity()

Default constructor.

cloneNode()

Returns a duplicate of this node; serves as a generic copy constructor for nodes.

getNodeType()

Returns a code representing the type of the underlying object.

getNodeValue()

Returns the value of this node, depending on its type.

getNotationName()

Returns the name of the notation for an unparsed the entity. For parsed entities, this is null.

getPublicId()

Returns the public identifier.

getSystemId()

Returns the system identifier.

readExternal()

Reads the information written in the compressed stream by writeExternal() method and restores the object correspondingly.

setNodeValue()

Sets the value of entity.

writeExternal()

Saves the state of the object by creating a binary compressed stream with information about this object.


XMLEntity()

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.

Syntax

public  XMLEntity();

cloneNode()

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.

Syntax

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

Parameter Description
deep

If TRUE, recursively clones the subtree under the specified node; if FALSE, clones only the node itself (and its attributes, if it is an Element).


getNodeType()

Returns a code representing the type of the underlying object.

Syntax

public short getNodeType();

getNodeValue()

Returns the value of this node, depending on its type. Throws DOMException:

Syntax

public String getNodeValue();

getNotationName()

Returns the name of the notation for an unparsed the entity. For parsed entities, this is null.

Syntax

public String getNotationName();

getPublicId()

Returns the public identifier associated with the entity, if specified. If the public identifier was not specified, this is null.

Syntax

public String getPublicId();

getSystemId()

Returns the system identifier associated with the entity, if specified. If the system identifier was not specified, this is null.

Syntax

public String getSystemId();

readExternal()

Reads the information written in the compressed stream by writeExternal() method and restores the object correspondingly. Throws the following exceptions:

Syntax

public void readExternal( java.io.ObjectInput in);

Parameter Description
in

The ObjectInput stream used for reading the compressed stream.


setNodeValue()

Sets the value of entity.

Syntax

public void setNodeValue( String arg);

Parameter Description
arg

The new value of the entity.


writeExternal()

Saves the state of the object by creating a binary compressed stream with information about this object. Throws IOException.

Syntax

public void writeExternal( java.io.ObjectOutput out);

Parameter Description
out

The ObjectOutput stream used to write the serialized/ compressed stream.


XMLEntityReference Class

This class implements DOM EntityReference interface.

Syntax

public class XMLEntityReference implements java.lang.Cloneable, 
java.io.Externalizable

Table 2-16  Summary of Methods of XMLEntityReference
Method Description

XMLEntityReference()

Default constructor.

getNodeType()

Returns a code representing the type of the underlying object.

readExternal()

Reads the information written in the compressed stream by writeExternal() method and restores the object correspondingly.

writeExternal()

Saves the state of the object by creating a binary compressed stream with information about this object.


XMLEntityReference()

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.

Syntax

public  XMLEntityReference();

getNodeType()

Returns a code representing the type of the underlying object.

Syntax

public short getNodeType();

readExternal()

Reads the information written in the compressed stream by writeExternal() method and restores the object correspondingly. Throws the following exceptions:

Syntax

public void readExternal( java.io.ObjectInput in);

Parameter Description
in

The ObjectInput stream used for reading the compressed stream


writeExternal()

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 compressed stream.

Syntax

public void writeExternal( java.io.ObjectOutput out);

Parameter Description
out

The ObjectOutput stream used to write the compressed stream.


XMLNode Class

Implements the DOM Node interface and serves as the primary datatype for the entire Document Object Model. It represents a single node in the document tree.

The attributes nodeName, nodeValue and attributes are included as a mechanism to get at node information without casting down to the specific derived instance. In cases where there is no obvious mapping of these attributes for a specific nodeType (for example, nodeValue for an Element or attributes for a Comment), this returns null. Note that the derived classes may contain additional and more convenient mechanisms to get and set the relevant information. This DOM Nodes extending XMLNode instead of XMLNSNode have fixed Nodename defined by DOM specification. Also only node that cannot have child nodes extend this class.

Syntax

public abstract class XMLNode implements java.lang.Cloneable, 
java.io.Externalizable

Table 2-17  Fields of XMLNode
Field Syntax Description
ATTRDECL
public static final short
     ATTRDECL

An attribute declaration node.

Auto_Events
public static final String
     Auto_Events

Flag to set Auto EVENTS.

capturing
public static final String
     capturing

Can be handled by one of the event's target's ancestors before being handled by the event's target.

DOMAttrModified
public static final String
     DOMAttrModified

Attr has been modified on a node.

DOMCharacterDataModified
public static final String
     DOMCharacterDataModified

Characterized within a node has been modified.

DOMNodeInserted
public static final String
     DOMNodeInserted

Node has been added as a child of another node.

DOMNodeInsertedIntoDocument
public static final String
     DOMNodeInsertedIntoDocument

Node is being inserted into a document, either through direct insertion of the Node or insertion of a subtree in which it is contained.

DOMNodeRemoved
public static final String
     DOMNodeRemoved

Node is being removed from its parent node.

DOMNodeRemovedFromDocument
public static final String
     DOMNodeRemovedFromDocument

Node is being removed from a document, either through direct removal of the Node or removal of a subtree in which it is contained.

DOMSubtreeModified
public static final String
     DOMSubtreeModified

General event for notification of all changes to the document. Can be used instead of the more specific events.

ELEMENTDECL
public static final short
     ELEMENTDECL

An element declaration.

noncapturing
public static final String
     noncapturing

Handled by the event's target without being handled by one of the event's target's ancestors first.

RANGE_DELETE_EVENT
public static final String
     RANGE_DELETE_EVENT

Flag to delete range event.

RANGE_DELETETEXT_EVENT
public static final String
     RANGE_DELETETEXT_EVENT

Flag to set range delete text event

RANGE_INSERT_EVENT
public static final String
     RANGE_INSERT_EVENT

Flag to set range event

RANGE_INSERTTEXT_EVENT
public static final String
     RANGE_INSERTTEXT_EVENT

Flag to set range insert text event

RANGE_REPLACE_EVENT
public static final String
     RANGE_REPLACE_EVENT

Flag to replace range event

RANGE_SETTEXT_EVENT
public static final String
     RANGE_SETTEXT_EVENT

Flag to set range text event

TRAVERSAL_DELETE_EVENT
public static final String
     TRAVERSAL_DELETE_EVENT

Flag to set traversal delete event

TRAVERSAL_REPLACE_EVENT
public static final String
     TRAVERSAL_REPLACE_EVENT

Flag to set traversal replace event

XMLDECL_NODE
public static final short 
    XMLDECL_NODE

A attribute declaration node

Table 2-18  Summary of Methods of XMLNode
Method Description

XMLNode()

Constructs a new XMLNode.

addEventListener()

Registers event listeners on the event target (node).

appendChild()

Adds the node newChild to the end of the list of children of this node, and returns the new node.

cloneNode()

Returns a duplicate of this node; serves as a generic copy constructor for nodes.

dispatchEvent()

Dispatches events into the implementations event model.

getAttributes()

Returns a NamedNodeMap containing the attributes of this node.

getChildNodes()

Returns all children of this node in a NodeList.

getColumnNumber()

Returns the column number debug information.

getDebugMode()

Returns the debug information mode.

getFirstChild()

Returns the first child of this node.

getLastChild()

Returns the last child of this node.

getLineNumber()

Returns the line number debug information.

getLocalName()

Returns the Local Name of this node overrided by node types for which namespace is meaningful.

getNamespaceURI()

Returns the namespace URI of this node, overrided by node types for which namespace is meaningful.

getNextSibling()

Returns the node immediately following this node.

getNodeName()

Returns the name of the node.

getNodeType()

Returns the type of the node.

getNodeValue()

Returns the value of this node, depending on its type.

getOwnerDocument()

Returns the Document object associated with this node.

getParentNode()

Returns the parent of this node.

getPrefix()

Returns the prefix of this node overrided by node types for which namespace is meaningful.

getPreviousSibling()

Returns the node immediately preceding this node. I

getProperty()

Returns the value of a property of the node.

getSystemId()

Returns the system id of the entity containing this node.

getText()

Returns the non-marked-up text contained by this element.

hasAttributes()

Determines whether this node (if it is an element) has any attributes.

hasChildNodes()

Determines whether a node has any children.

insertBefore()

Inserts the node newChild before the existing child node refChild.

isNodeFlag()

Returns TRUE if the node flag information is set.

isSupported()

Tests whether the DOM implementation implements a specific feature and that feature is supported by this node.

print()

Writes the contents of this node into output.

readExternal()

Reads the information written in the compressed stream by writeExternal method and restores the object correspondingly.

removeChild()

Removes the child node indicated by oldChild from the list of children.

removeEventListener()

Removes event listeners from the event target (node).

replaceChild()

Replaces the child node oldChild with newChild in the list of children, and returns the replaced node.

reportSAXEvents()

Reports SAX Events from a DOM Tree. Throws SAXException.

resetNodeFlag()

Resets the node flag information.

selectNodes()

Returns nodes from the tree which match the given pattern, as a NodeList.

selectSingleNode()

Returns the first node from the tree that matches the given pattern.

setDebugInfo()

Sets debug information in the node.

setNodeFlag()

Sets the node flag information.

setNodeValue()

Sets the value of this node, depending on its type.

setPrefix()

Sets the prefix of this node overrided by node types for which namespace is meaningful.

setProperty()

Sets a property of the node.

transformNode()

Transforms a node in the tree using the given stylesheet, and returns the resulting DocumentFragment.

valueOf()

Selects the value of the first node from tree that matches the pattern.

writeExternal()

Saves the state of the object by creating a binary compressed stream with information about this object.


XMLNode()

Constructs a new XMLNode.

Syntax

protected  XMLNode();

Parameter Description
tag

Name of the node.


addEventListener()

Registers event listeners on the event target (node).

Syntax

public void addEventListener( String type,
                              org.w3c.dom.events.EventListener listener,
                              boolean useCapture);

Parameter Description
type

Type of event for which the listener is registered.

listener

The listener object.

useCapture

Fag to indicate if the listener wants to initiate capture.


appendChild()

Adds the node newChild to the end of the list of children of this node, and returns the new node. If the newChild is already in the tree, it is first removed. Throws DOMException:

Syntax

public org.w3c.dom.Node appendChild( org.w3c.dom.Node newChild);

Parameter Description
newChild

The node to add. If it is a DocumentFragment object, the entire contents of the document fragment are moved into the child list of this node.


cloneNode()

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.

Syntax

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

Parameter Description
deep

If TRUE, recursively clone the subtree under the specified node; if FALSE, clone only the node itself (and its attributes, if it is an Element).


dispatchEvent()

Dispatches the events into the implementations event model. Throws an exception of value UNSPECIFIED_EVENT_TYPE if the Event's type was not specified by initializing the event before dispatchEvent was called.

Syntax

public boolean dispatchEvent(org.w3c.dom.events.Event evt);

Parameter Description
evt

Indicates whether preventDefault() or stopPropogation() was called.


getAttributes()

Returns a NamedNodeMap containing the attributes of this node (if it is an Element) or null otherwise.

Syntax

public org.w3c.dom.NamedNodeMap getAttributes();

getChildNodes()

Returns all children of this node in a NodeList. 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.

Syntax

public org.w3c.dom.NodeList getChildNodes();

getColumnNumber()

Returns the column number debug information.

Syntax

public int getColumnNumber();

getDebugMode()

Returns the debug information mode.

Syntax

public boolean getDebugMode();

getFirstChild()

Returns the first child of this node. If there is no such node, this returns null.

Syntax

public org.w3c.dom.Node getFirstChild();

getLastChild()

Returns the last child of this node. If there is no such node, this returns null.

Syntax

public org.w3c.dom.Node getLastChild();

getLineNumber()

Returns the line number debug information.

Syntax

public int getLineNumber();

getLocalName()

Returns the Local Name of this node overrided by node types for which namespace is meaningful.

Syntax

public String getLocalName();

getNamespaceURI()

Returns the namespace URI of this node, overrided by node types for which namespace is meaningful.

Syntax

public String getNamespaceURI();

getNextSibling()

Returns the node immediately following this node. If there is no such node, this returns null.

Syntax

public org.w3c.dom.Node getNextSibling();

getNodeName()

Returns the name of the node.

Syntax

public String getNodeName();

getNodeType()

Returns the type of the node.

Syntax

public short getNodeType();

getNodeValue()

Returns the value of this node, depending on its type. Throws DOMException:

Syntax

public String getNodeValue();

getOwnerDocument()

Returns the Document object associated with this node. This is also the Document object used to create new nodes. When this node is a Document this is null.

Syntax

public org.w3c.dom.Document getOwnerDocument();

getParentNode()

Returns the parent of this node. All nodes, except Document, DocumentFragment, and Attr may have a parent. However, if a node has just been created and not yet added to the tree, or if it has been removed from the tree, this is null.

Syntax

public org.w3c.dom.Node getParentNode();

getPrefix()

Returns the prefix of this node overrided by node types for which namespace is meaningful.

Syntax

public String getPrefix();

getPreviousSibling()

Returns the node immediately preceding this node. If there is no such node, this returns null.

Syntax

public org.w3c.dom.Node getPreviousSibling();

getProperty()

Returns the value of a property of the node.

Syntax

public Object getProperty( String propName);

Parameter Description
propName

Name of the property.


getSystemId()

Returns the system id of the entity containing this node.

Syntax

public String getSystemId();

getText()

Returns the non-marked-up text contained by this element. For text elements, this is the raw data. For elements with child nodes, this method traverses the entire subtree and appends the text for each terminal text element, effectively stripping out the XML markup for the subtree.

Syntax

public String getText();

hasAttributes()

Determines whether this node (if it is an element) has any attributes. Returns TRUE if this node has any attributes, FALSE otherwise.

Syntax

public boolean hasAttributes();

hasChildNodes()

Determines whether a node has any children. Returns TRUE if the node has any children, FALSE if the node has no children.

Syntax

public boolean hasChildNodes();

insertBefore()

Inserts the node newChild before the existing child node refChild, and returns this node. If refChild is null, insert newChild at the end of the list of children. If newChild is a DocumentFragment object, all of its children are inserted, in the same order, before refChild. If the newChild is already in the tree, it is first removed. Throws DOMException:

Syntax

public org.w3c.dom.Node insertBefore( org.w3c.dom.Node newChild,
                                      org.w3c.dom.Node refChild);

Parameter Description
newChild 

The node to insert.

refChild 

The reference node, the node before which the new node must be inserted.


isNodeFlag()

Returns TRUE if the node flag information is set.

Syntax

public boolean isNodeFlag( int flag);

Parameter Description
flag

The flag.


isSupported()

Tests whether the DOM implementation implements a specific feature and that feature is supported by this node. Returns TRUE if the feature is supported, FALSE otherwise.

Syntax

public boolean isSupported( String feature, String version);

Parameter Description
feature

The feature being tested.

version

The version of the feature being tested.


print()

Writes the contents of this node into output. Throws IOException. The options are described in the following table.

Syntax Description
public void print(
     java.io.OutputStream out);

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

public void print(
     java.io.OutputStream out,
     String enc);

Writes the contents of this node to the given encoded output stream.

public void print(
     java.io.PrintWriter out);

Writes the contents of this node using the given print writer.


Parameter Description
out

The output.

enc

Encoding to use for the output.


readExternal()

Reads the information written in the compressed stream by writeExternal method and restores the object correspondingly. Throws the following exceptions:

Syntax

public void readExternal( java.io.ObjectInput in);

Parameter Description
in

The ObjectInput stream used for reading the compressed stream.


removeChild()

Removes the child node indicated by oldChild from the list of children, and returns it. Throws DOMException:

Syntax

public org.w3c.dom.Node removeChild( org.w3c.dom.Node oldChild);

Parameter Description
oldChild

The node being removed.


removeEventListener()

Removes event listeners from the event target (node).

Syntax

public void removeEventListener( String type,
                                 org.w3c.dom.events.EventListener listener,
                                 boolean useCapture);

Parameter Description
type

Type of event for which the listener is registered.

listener

The listener object.

useCapture

The flag to indicate if the listener wants to initiate capture.


replaceChild()

Replaces the child node oldChild with newChild in the list of children, and returns the replaced node. If the newChild is already in the tree, it is first removed. Throws DOMException:

Syntax

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

Parameter Description
newChild

The new node to put in the child list.

oldChild 

The node being replaced in the list.


reportSAXEvents()

Report SAX Events from a DOM Tree. Throws SAXException.

Syntax

public void reportSAXEvents( org.xml.sax.ContentHandler cntHandler);

Parameter Description
cntHandler

The content handler.


resetNodeFlag()

Resets the node flag information.

Syntax

public void resetNodeFlag( int flag);

Parameter Description
flag

The node flag.


selectNodes()

Returns nodes from the tree which match the given pattern, as a NodeList. This method assumes that the pattern does not contain namespace prefixes. Throws XSLException if there is an error while doing the match. The options are described in the following table.

Syntax Description
public org.w3c.dom.NodeList selectNodes(
     String pattern);

Matches using the pattern.

public org.w3c.dom.NodeList selectNodes(
     String pattern,
     NSResolver nsr);

Matches using the pattern and the namespace resolver.


Parameter Description
pattern

XSL pattern to match.

nsr

NSResolver to resolve any prefixes that occur in given pattern.


selectSingleNode()

Returns the first node from the tree that matches the given pattern. Throws XSLException if there is an error while doing the match. The options are described in the following table.

Syntax Description
public org.w3c.dom.Node selectSingleNode(
     String pattern);

Matches using the pattern.

public org.w3c.dom.Node selectSingleNode(
     String pattern,
     NSResolver nsr);

Matches using the pattern and the namespace resolver.


Parameter Description
pattern

XSL pattern to match.

nsr

NSResolver to resolve any prefixes that occur in given pattern.


setDebugInfo()

Sets debug information in the node.

Syntax

public void setDebugInfo( int line, 
                          int col,
                          String sysid);

Parameter Description
line

The line number.

col

The column number.

sysid

The system id.


setNodeFlag()

Sets the node flag information.

Syntax

public void setNodeFlag( int flag);

Parameter Description
flag

The node flag.


setNodeValue()

Sets the value of this node, depending on its type. Throws DOMException:

Syntax

public void setNodeValue( String nodeValue);

Parameter Description
nodeValue

The node value to set.


setPrefix()

Sets the prefix of this node overrided by node types for which namespace is meaningful. Throws DOMException.

Syntax

public void setPrefix( String prefix);

Parameter Description

prefix

The prefix to set.



setProperty()

Sets a property of the node.

Syntax

public void setProperty( String propName,
                         Object propValue);

Parameter Description
propName

Name of the property.

propValue

Value of the property.


transformNode()

Transforms a node in the tree using the given stylesheet, and returns the resulting DocumentFragment. Throws XSLException.

Syntax

public org.w3c.dom.DocumentFragment transformNode( XSLStylesheet xsl);

Parameter Description
xsl

The XSLStylesheet to be used for transformation.


valueOf()

Selects the value of the first node from tree that matches the pattern. The options are described in the following table. Throws XSLException if there is an error while doing the match.

Syntax Description
public String valueOf(
     String pattern);

Matches using the pattern.

public String valueOf(
     String pattern,
     NSResolver nsr);

Matches using the pattern and namespace resolver.


Parameter Description
pattern

XSL pattern to match

nsr

NSResolver to resolve any prefixes that occur in given pattern


writeExternal()

Saves the state of the object by creating a binary compressed stream with information about this object. Throws IOException.

Syntax

public void writeExternal( java.io.ObjectOutput out);

Parameter Description
out

The ObjectOutput stream used to write the serialized/ compressed stream.


XMLNotation Class

This class implements the DOM Notation interface and represents a notation declared in the Document Type Definition.

Syntax

public class XMLNotation implements java.io.Externalizable

Table 2-19  Summary of Methods of XMLNotation
Method Description

XMLNotation()

Default constructor.

cloneNode()

Returns a duplicate of this node; serves as a generic copy constructor for nodes.

getNodeName()

Returns the name of the Notation.

getNodeType()

Returns a code representing the type of the underlying object.

getPublicId()

Returns the Public identifier; if not specified, then null.

getSystemId()

Returns the System identifier; if not specified, then null.

readExternal()

Reads the information written in the compressed stream by writeExternal method and restores the object correspondingly.

setPublicId()

Sets the Public Identifier.

setSystemId()

Sets the System Identifier.

writeExternal()

Saves the state of the object by creating a binary compressed stream with information about this object.


XMLNotation()

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. For all normal XMLElement creation use XMLNotation().

Syntax

public  XMLNotation();

cloneNode()

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.

Syntax

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

Parameter Description
deep

If TRUE, recursively clones the subtree under the specified node; if FALSE, clones only the node itself and its attributes


getNodeName()

Returns the name of the Notation

Syntax

public String getNodeName();

getNodeType()

Returns a code representing the type of the underlying object.

Syntax

public short getNodeType();

getPublicId()

Returns the Public identifier; if not specified, then null.

Syntax

public String getPublicId();

getSystemId()

Returns the System identifier; if not specified, then null.

Syntax

public String getSystemId();

readExternal()

Reads the information written in the compressed stream by writeExternal method and restores the object correspondingly. Throws the following exceptions:

Syntax

public void readExternal( java.io.ObjectInput inArg);

Parameter Description
in

The ObjectInput stream used for reading the compressed stream.


setPublicId()

Sets the Public Identifier.

Syntax

public void setPublicId( String pubid);

Parameter Description
pubid

Public Identifier to set.


setSystemId()

Sets the System Identifier.

Syntax

public void setSystemId( String url);

Parameter Description
url

System identifier to set.


writeExternal()

Saves the state of the object by creating a binary compressed stream with information about this object. Throws IOException.

Syntax

public void writeExternal( java.io.ObjectOutput out);

Parameter Description
out

The ObjectOutput stream used to write the serialized/ compressed stream.


XMLNSNode Class

Extends XMLNode to add support for Namespace names and children

Syntax

public class XMLNSNode extends oracle.xml.parser.v2.XMLNode implements 
java.lang.Cloneable java.io.Externalizable,

Table 2-20  Summary of Methods XMLNSNode
Method Description

XMLNSNode()

Constructs a new XMLNSNode.

addText()

Adds text to this node, or appends it to the last child if the last child is a text node.

appendChild()

Adds the node newChild to the end of the list of children of this node.

getChildNodes()

Returns all children of this node as a NodeList.

getFirstChild()

Returns the first child of this node.

getLastChild()

Returns the last child of this node.

getLocalName()

Returns the Local Name of this node overrided by node types for which namespace is meaningful.

getNamespaceURI()

Returns the namespace URI of this node overrided by node types for which namespace is meaningful.

getNodeName()

Returns the name of this node, depending on its type.

getPrefix()

Returns the prefix of this node overrided by node types for which namespace is meaningful.

getText()

Returns the non-marked-up text contained by this element.

hasChildNodes()

Determines whether a node has any children.

insertBefore()

Inserts the child node before an existing child node.

normalize()

Puts all Text nodes in the full depth of the sub-tree underneath this Node, including attribute nodes, into "normal" form where only structure separates Text nodes.

removeChild()

Removes the child node indicated by oldChild from the list of children.

replaceChild()

Replaces the child node oldChild with newChild in the list of children.

setPrefix()

Sets the prefix of this node overrided by node types for which namespace is meaningful.


XMLNSNode()

Constructs a new XMLNSNode.

Syntax

protected  XMLNSNode( String tag);

Parameter Description
tag

Name of the node.


addText()

Adds text to this node, or appends it to the last child if the last child is a text node. Throws XMLDOMException if text can't be added to this node. The options are described in the following table.

Syntax Description
public void addText(
     char[] ch,
     int start,
     int length);

Adds text from a Char array.

public XMLNode addText(
     String str);

Adds text from a String.


Parameter Description
ch

Char array to add.

start

Start index in the char array.

length

Number of chars to be added.

str

Text to add.


appendChild()

Adds the node newChild to the end of the list of children of this node, and returns that node. If the newChild is already in the tree, it is first removed. Throws DOMException:

Syntax

public org.w3c.dom.Node appendChild( org.w3c.dom.Node newChild);

Parameter Description
newChild

The node to add. If it is a DocumentFragment object, the entire contents of the document fragment are moved into the child list of this node.


getChildNodes()

Returns all children of this node as a NodeList. 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.

Syntax

public org.w3c.dom.NodeList getChildNodes();

getFirstChild()

Returns the first child of this node. If there is no such node, this returns null.

Syntax

public org.w3c.dom.Node getFirstChild();

getLastChild()

Returns the last child of this node. If there is no such node, this returns null.

Syntax

public org.w3c.dom.Node getLastChild();

getLocalName()

Returns the Local Name of this node overrided by node types for which namespace is meaningful.

Syntax

public String getLocalName();

getNamespaceURI()

Returns the namespace URI of this node. overrided by node types for which namespace is meaningful.

Syntax

public String getNamespaceURI();

getNodeName()

Returns the name of this node, depending on its type

Syntax

public String getNodeName();

getPrefix()

Returns the prefix of this node overrided by node types for which namespace is meaningful.

Syntax

public String getPrefix();

getText()

Returns the non-marked-up text contained by this element. For text elements, this is the raw data. For elements with child nodes, this method traverses the entire subtree and appends the text for each terminal text element, effectively stripping out the XML markup for the subtree. For example, if the XML document contains "William Shakespeare", XMLDocument.getText returns "William Shakespeare".

Syntax

public String getText();

hasChildNodes()

This is a convenience method to allow easy determination of whether a node has any children. Returns TRUE if the node has any children, FALSE otherwise.

Syntax

public boolean hasChildNodes();

insertBefore()

Inserts the node newChild before the existing child node refChild, and returns the node being inserted. If refChild is null, insert newChild at the end of the list of children. If newChild is a DocumentFragment object, all of its children are inserted, in the same order, before refChild. If the newChild is already in the tree, it is first removed. Throws DOMException:

Syntax

public org.w3c.dom.Node insertBefore( org.w3c.dom.Node newChild,
                                      org.w3c.dom.Node refChild);

Parameter Description
newChild 

The new node to put in the child list.

refChild

The reference node, or the node before which the new node must be inserted.


normalize()

Puts all Text nodes in the full depth of the sub-tree underneath this Node, including attribute nodes, into "normal" form where only structure (for example, elements, comments, processing instructions, CDATA sections, and entity references) separates Text nodes; there are neither adjacent Text nodes nor empty Text nodes. This can be used to ensure that the DOM view of a document is the same as if it were saved and re-loaded, and is useful when operations (such as XPointer lookups) that depend on a particular document tree structure are to be used.

Syntax

public void normalize();

removeChild()

Removes the child node indicated by oldChild from the list of children, and returns it. Throws DOMException:

Syntax

public org.w3c.dom.Node removeChild( org.w3c.dom.Node oldChild);

Parameter Description
oldChild 

The node being removed.


replaceChild()

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. Throws DOMException:

Syntax

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

Parameter Description
newChild 

The new node to put in the child list.

oldChild 

The node being replaced in the list.


setPrefix()

Sets the prefix of this node overrided by node types for which namespace is meaningful.

Syntax

public void setPrefix( String prefix);

Parameter Description
prefix

The prefix of the node.


XMLOutputStream Class

This class writes output stream and can handle XML encoding.

Syntax

public class XMLOutputStream extends java.lang.Object

Table 2-21 Fields of XMLOutputStream
Field Syntax Description
COMPACT
public static int COMPACT

No extra indentation and new lines.

DEFAULT
public static int DEFAULT

No extra indentation and new lines.

PRETTY
public static int PRETTY

Adds indentation and new lines for readability.

Table 2-22  Summary of Methods of XMLOutputStream
Method Description

XMLOutputStream()

Builds an ASCII output.

addIndent()

Sets indenting level for output.

close()

Closes the output stream.

flush()

Flushes the output stream.

getOutputStyle()

Returns the current output style.

setEncoding()

Sets the output character encoding.

setOutputStyle()

Sets the Output the style.

write()

Outputs character according to type of the output stream.

writeChars()

Writes string to the output.

writeIndent()

Writes an indentation.

writeNewLine()

Writes a new line.

writeQuotedString()

Writes string with surrounding quotes.


XMLOutputStream()

Builds an ASCII output. The options are described in the following table.

Syntax Description
public XMLOutputStream(
     java.io.OutputStream out);

Builds the output using OutputStream.

public XMLOutputStream(
     java.io.PrintWriter out);

Builds the output using PrintWriter.


Parameter Description
out

The output.


addIndent()

Sets indenting level for output.

Syntax

public void addIndent( int offset);

Parameter Description
offset

The indenting level.


close()

Closes the output stream. Throws IOException if there is any error.

Syntax

public void close();

flush()

Flushes the output stream. Throws IOException if there is any error.

Syntax

public void flush();

getOutputStyle()

Returns the current output style.

Syntax

public int getOutputStyle();

setEncoding()

Sets the output character encoding. Throws IOException if error in setting the encoding type.

Syntax

public void setEncoding( String encoding,
                         boolean lendian, 
                         boolean byteOrderMark);

Parameter Description
encoding

The encoding of the stream.

lendian

The flag to indicate if the encoding is of type little endian.

byteOrderMark

The flag to indicate if byte order mark is set.


setOutputStyle()

Sets the Output the style.

Syntax

public void setOutputStyle( int style);

Parameter Description
s

The output style


write()

Outputs character according to type of the output stream. Throws IOException if there is any error in writing the character.

Syntax

public void write( int c);

Parameter Description
c

The character written.


writeChars()

Writes string to the output. Throws IOException if there is any error in writing the string.

Syntax

public void writeChars( String str);

Parameter Description
str

The string that is written to the output stream.


writeIndent()

Writes an indentation. Throws IOException if there is any error in writing the string.

Syntax

public void writeIndent();

writeNewLine()

Writes a new line. Throws IOException if there is any error in writing the string.

Syntax

public void writeNewLine();

writeQuotedString()

Writes string with surrounding quotes. Throws IOException if there is any error in writing the string.

Syntax

public void writeQuotedString( String str);

Parameter Description
str

The string that is written to the output stream.


XMLPI Class

This class implements the DOM Processing Instruction interface. See also ProcessingInstruction, NodeFactory, DOMParser.setNodeFactory().

Syntax

public class XMLPI implements java.io.Externalizable

Table 2-23  Summary of Methods of XMLPI
Method Description

XMLPI()

Creates a new instance of XMLPI.

addText()

Adds text string to the node, and returns the updated node.

getNodeName()

Returns the name of the PI Node.

getNodeType()

Returns the type of node of the underlying object.

getTarget()

Returns the target of this PI.

readExternal()

Reads the information written in the compressed stream by writeExternal method and restores the object correspondingly.

reportSAXEvents()

Reports SAX Events from a DOM Tree.

writeExternal()

Saves the state of the object by creating a binary compressed stream with information about this object.


XMLPI()

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.

Syntax

public  XMLPI();

addText()

Adds text string to the node, and returns the updated node.

Syntax

public XMLNode addText( String str);

Parameter Description
str

The Text string to be added.


getNodeName()

Returns the name of the PI Node.

Syntax

public String getNodeName();

getNodeType()

Returns the type of node of the underlying object

Syntax

public short getNodeType();

getTarget()

Returns the target of this PI. XML defines this as the first token following markup that begins the processing instruction.

Syntax

public String getTarget();

readExternal()

Reads the information written in the compressed stream by writeExternal method and restores the object correspondingly. Throws the following exceptions:

Syntax

public void readExternal( java.io.ObjectInput in);

Parameter Description
in

The ObjectInput stream used for reading the compressed stream.


reportSAXEvents()

Reports SAX Events from a DOM Tree. Throws SAXException.

Syntax

public void reportSAXEvents( org.xml.sax.ContentHandler cntHandler);

Parameter Description
cntHandler

Content handler.


writeExternal()

Saves the state of the object by creating a binary compressed stream with information about this object. Throws the IOException when there is an exception while writing the compressed stream.

Syntax

public void writeExternal( java.io.ObjectOutput out);

Parameter Description
out

ObjectOutput stream used to write the compressed stream.


XMLPrintDriver Class

The XMLPrintDriver implements PrintDriver interface.

Syntax

public class XMLPrintDriver extends Object implements 
oracle.xml.parser.v2.PrintDriver

Table 2-24 Fields of XMLPrintDriver
Field Syntax Description
out
protected XMLOutputStream out

XMLOutputStream object

Table 2-25  Summary of Methods of XMLPrintDriver
Method Description

XMLPrintDriver()

Creates an instance of XMLPrintDriver.

close()

Closes the output stream or print writer

flush()

Flushes the output stream or print writer.

printAttribute()

Prints an XMLAttr node.

printAttributeNodes()

Calls print method for each attribute of the XMLElement.

printCDATASection()

Prints an XMLCDATA node.

printChildNodes()

Calls print method for each child of the XMLNode.

printComment()

Prints an XMLComment node.

printDoctype()

Prints a DTD.

printDocument()

Prints an XMLDocument.

printDocumentFragment()

Prints an empty XMLDocumentFragment object.

printElement()

Prints an XMLElement.

printEntityReference()

Prints an XMLEntityReference node

printProcessingInstruction()

Prints an XMLPI node.

printTextNode()

Prints an XMLText node.

setEncoding()

Sets the encoding of the print driver.


XMLPrintDriver()

Creates an instance of XMLPrintDriver. The options are described in the following table.

Syntax Description
public XMLPrintDriver(
     OutputStream os);

Creates an instance of XMLPrintDriver from an OutputStream.

public XMLPrintDriver(
     PrintWriter pw);

Creates an instance of XMLPrintDriver from a PrintWriter.


Parameter Description
os

The OutputStream.

pw

The PrintWriter.


close()

Closes the output stream or print writer

Syntax

public void close();

flush()

Flushes the output stream or print writer.

Syntax

public void flush();

printAttribute()

Prints an XMLAttr node.

Syntax

public void printAttribute( XMLAttr attr);

Parameter Description
attr

The XMLAttr Node.


printAttributeNodes()

Calls print method for each attribute of the XMLElement.

Syntax

public final void printAttributeNodes( XMLElement elem);

Parameter Description
elem

The elem whose attributes are to be printed


printCDATASection()

Prints an XMLCDATA node.

Syntax

public void printCDATASection( XMLCDATA cdata);

Parameter Description
cdata

The XMLCDATA node


printChildNodes()

Calls print method for each child of the XMLNode.

Syntax

public final void printChildNodes( XMLNode node);

Parameter Description
node

The node whose children are to be printed.


printComment()

Prints an XMLComment node.

Syntax

public void printComment( XMLComment comment);

Parameter Description
comment

The comment node.


printDoctype()

Prints an DTD.

Syntax

public void printDoctype( DTD dtd);

Parameter Description
dtd

The DTD to be printed.


printDocument()

Prints an XMLDocument.

Syntax

public void printDocument( XMLDocument doc);

Parameter Description
doc

The document to be printed


printDocumentFragment()

Prints an empty XMLDocumentFragment object.

Syntax

public void printDocumentFragment( XMLDocumentFragment dfrag);

Parameter Description
dfrag

The document fragment to be printed.


printElement()

Prints an XMLElement.

Syntax

public void printElement( XMLElement elem);

Parameter Description
elem

The element to be printed.


printEntityReference()

Prints an XMLEntityReference node

Syntax

public void printEntityReference( XMLEntityReference en);

Parameter Description
en

The XMLEntityReference node.


printProcessingInstruction()

Prints an XMLPI node

Syntax

public void printProcessingInstruction( XMLPI pi);

Parameter Description
pi

The XMLPI node.


printTextNode()

Prints an XMLText node.

Syntax

public void printTextNode( XMLText text);

Parameter Description
text

The text node.


setEncoding()

Sets the encoding of the print driver.

Syntax

public void setEncoding( String enc);

Parameter Description
enc

The encoding of the document being printed.


XMLRangeException Class

This class customizes the RangeException.

Syntax

public class XMLRangeException


XMLRangeException()

Generates an XMLRangeException instance.

Syntax

public  XMLRangeException(short code);

Parameter Description
code


XMLText Class

This class implements the DOM Text interface. See also Text, NodeFactory, DOMParser.setNodeFactory().

Syntax

public class XMLText implements java.io.Serializable, java.io.Externalizable
 
Table 2-26  Summary of Methods of XMLText
Method Description

XMLText()

Creates an instance of XMLText.

addText()

Adds text to the data of the text node.

getData()

Returns the character data of the node that implements this interface.

getNodeName()

Returns the name of the XMLText Node.

getNodeType()

Returns a type of node representing the type of the underlying object.

getNodeValue()

Returns String value of this text node.

isWhiteSpaceNode()

Checks if the text node is a whitespace node.

readExternal()

Reads the information written in the compressed stream by writeExternal method and restores the object correspondingly.

reportSAXEvents()

Reports SAX Events from a DOM Tree.

splitText()

Breaks Text node into two Text nodes at specified offset.

writeExternal()

Saves the state of the object by creating a binary compressed stream with information about this object.


XMLText()

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.

Syntax

public  XMLText();

addText()

Adds text to the data of the text node, similar to appendData.

Syntax

public void addText( char[] ch,
                     int start,
                     int length);

Parameter Description
ch 

char array to be appended

start

start index

length

length of the char array


getData()

Returns the character data of the node that implements this interface. The DOM implementation may not put arbitrary limits on the amount of data that may be stored in a Text node. However, implementation limits may mean that the entirety of a node's data may not fit into a single DOMString. In such cases, the user may call substringData to retrieve the data in appropriately sized pieces.

Throws DOMException:

Syntax

public String getData();

getNodeName()

Returns the name of the XMLText Node.

Syntax

public String getNodeName();

getNodeType()

Returns a type of node representing the type of the underlying object.

Syntax

public short getNodeType();

getNodeValue()

Returns String value of this text node. Throws DOMException if any error occurs when retrieving the value.

Syntax

public String getNodeValue();

isWhiteSpaceNode()

Checks if the text node is a whitespace node.

Syntax

public boolean isWhiteSpaceNode();

readExternal()

Reads the information written in the compressed stream by writeExternal method and restores the object correspondingly. This method is called if XMLText object is deserialized (or read) as an independent node and not called from some other DOM nodeThrows the following exceptions:

Syntax

public void readExternal( java.io.ObjectInput in);

Parameter Description
in

The ObjectInput stream used for reading the compressed stream


reportSAXEvents()

Reports SAX Events from a DOM Tree. Throws SAXException.

Syntax

public void reportSAXEvents(org.xml.sax.ContentHandler cntHandler);

Parameter Description
cntHandler

Content handler.


splitText()

Breaks Text node into two Text nodes at specified offset, so they are both siblings, and the node only contains content up to the offset. Returns the new Text node. New node inserted as next sibling contains all content at and after the offset point.

Throws DOMException:

Syntax

public org.w3c.dom.Text splitText( int offset);

Parameter Description
offset

Offset at which to split, starting from 0


writeExternal()

Saves the state of the object by creating a binary compressed stream with information about this object. Throws IOException.

Syntax

public void writeExternal( java.io.ObjectOutput out);

Parameter Description
out

The ObjectOutput stream used to write the compressed stream.


Go to previous page Go to next page
Oracle
Copyright © 2001, 2003 Oracle Corporation.

All Rights Reserved.
Go To Documentation Library
Home
Go To Product List
Solution Area
Go To Table Of Contents
Contents
Go To Index
Index