|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--oracle.xml.parser.v2.XMLNode | +--oracle.xml.parser.v2.XMLNSNode | +--oracle.xml.parser.v2.XMLElement | +--oracle.xml.parser.v2.XMLDocument
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.
Fields inherited from interface oracle.xml.comp.CXMLConstants |
ATTR_DEF,
ATTR_TOKEN,
ATTRDECL_DEF,
CDATA_DEF,
CHAR_DEF,
COMMENT_DEF,
CXML_VERSION,
cXMLFILE,
cXMLFILE_LEN,
DEBUG,
DTD_DEF,
ELEMENTDECL_DEF,
END,
ENTITY_DEF,
ENTITYREF_DEF,
META_ID_MAX,
names,
NOTATION_DEF,
NS_DEF,
NULLSTR,
PI_DEF,
PREFIX_DEF,
TAG_DEF,
TAG_TOKEN,
TOKEN_ONLY,
XMLDECL_DEF |
Fields inherited from interface org.w3c.dom.Node |
ATTRIBUTE_NODE,
CDATA_SECTION_NODE,
COMMENT_NODE,
DOCUMENT_FRAGMENT_NODE,
DOCUMENT_NODE,
DOCUMENT_TYPE_NODE,
ELEMENT_NODE,
ENTITY_NODE,
ENTITY_REFERENCE_NODE,
NOTATION_NODE,
PROCESSING_INSTRUCTION_NODE,
TEXT_NODE |
Constructor Summary |
XMLDocument()
Creates an empty document. |
Method Summary |
Type | Method |
---|---|
void |
addID(java.lang.String name,
XMLElement e)
Add a ID Element associated with this document |
Node |
adoptNode(Node srcNode)
|
Node |
appendChild(Node elem)
Appends a new node to the document |
Node |
cloneNode(boolean deep)
Returns a duplicate of this node, i.e., serves as a generic copy constructor for nodes. |
Attr |
createAttribute(java.lang.String name)
Creates an Attr of the given name. |
Attr |
createAttributeNS(java.lang.String namespaceURI,
java.lang.String qualifiedName)
Creates an attribute of the given qualified name and namespace URI. |
CDATASection |
createCDATASection(java.lang.String data)
Creates a CDATASection node whose value is the specified
string. |
Comment |
createComment(java.lang.String data)
Creates a Comment node given the specified string. |
DocumentFragment |
createDocumentFragment()
Creates an empty DocumentFragment object. |
Element |
createElement(java.lang.String tagName)
Creates an element of the type specified. |
Element |
createElementNS(java.lang.String namespaceURI,
java.lang.String qualifiedName)
Creates an element of the given qualified name and namespace URI. |
EntityReference |
createEntityReference(java.lang.String name)
Creates an EntityReference object. |
Event |
createEvent(java.lang.String type)
Creates an event object of the specified type |
MutationEvent |
createMutationEvent(java.lang.String type)
|
NodeIterator |
createNodeIterator(Node root,
int whatToShow,
NodeFilter filter,
boolean expandEntityReferences)
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 |
ProcessingInstruction |
createProcessingInstruction(java.lang.String target,
java.lang.String data)
Creates a ProcessingInstruction node given the specified
name and data strings. |
Range |
createRange()
Create a new Document Range Object ,with Start and End Boundary points at the begining of the document. |
Event |
createRangeEvent(java.lang.String type)
|
Text |
createTextNode(java.lang.String data)
Creates a Text node given the specified string. |
Event |
createTraversalEvent(java.lang.String type)
|
TreeWalker |
createTreeWalker(Node root,
int whatToShow,
NodeFilter filter,
boolean expandEntityReferences)
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 |
java.util.Vector |
expectedElements(Element e)
Returns vector of element names that can be appended to the element. |
NamedNodeMap |
getAttributes()
A NamedNodeMap containing the attributes of this node (if
it is an Element ) or null otherwise. |
int |
getColumnNumber()
Get column number debug information |
boolean |
getDebugMode()
Get the debug flag |
DocumentType |
getDoctype()
The Document Type Declaration (DTD) associated with this document. |
Element |
getDocumentElement()
This is a convenience attribute that allows direct access to the child node that is the root element of the document. |
Element |
getElementById(java.lang.String elementId)
Returns the Element whose ID is given by
elementId . |
NodeList |
getElementsByTagName(java.lang.String tagname)
Returns a NodeList of all the Element s with a
given tag name in the order in which they would be encountered in a
preorder traversal of the Document tree. |
NodeList |
getElementsByTagNameNS(java.lang.String namespaceURI,
java.lang.String localName)
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. |
java.lang.String |
getEncoding()
Retrieves the character encoding information. |
XMLElement |
getIDElement(java.lang.String idValue)
Deprecated. As of DOM 2 |
java.util.Hashtable |
getIDHashtable()
Get the ID element hashtable in the XML DOM Tree |
DOMImplementation |
getImplementation()
The DOMImplementation object that handles this document. |
int |
getLineNumber()
Get line number debug information |
java.lang.String |
getLocalName()
Gets the local Name for this element. |
java.lang.String |
getNamespaceURI()
The namespace URI of this node, or null if it is
unspecified. |
short |
getNodeType()
Gets a code representing the type of the underlying object |
Document |
getOwnerDocument()
The Document object associated with this node. |
java.lang.String |
getStandalone()
Retrieves the standalone information. |
java.lang.String |
getSystemId()
Get the system id of the entity contain this node |
java.lang.String |
getText()
Returns the non-marked-up text contained by this element. |
java.lang.String |
getVersion()
Retrieves the version information. |
Node |
importNode(Node importedNode,
boolean deep)
Imports a node from another document to this document. |
Node |
insertBefore(Node newChild,
Node refChild)
Inserts the node newChild before the existing child node
refChild . |
void |
print(java.io.OutputStream out)
Writes the contents of this document to the given output stream. |
void |
print(java.io.OutputStream out,
java.lang.String enc)
Writes the contents of this document to the given output stream. |
void |
print(PrintDriver pd)
Writes the contents of this document to the given output stream. |
void |
print(java.io.PrintWriter out)
Writes the contents of this document to the given output stream. |
void |
printExternalDTD(java.io.OutputStream out)
Writes the contents of this document to the given output stream. |
void |
printExternalDTD(java.io.OutputStream out,
java.lang.String enc)
Writes the contents of the external DTD to the given output stream. |
void |
printExternalDTD(java.io.PrintWriter out)
Writes the contents of this document to the given output stream. |
void |
readExternal(java.io.ObjectInput inArg)
This method reads the information written in the compressed stream by writeExternal method and restores the object correspondingly. |
void |
readExternal(oracle.xml.io.XMLObjectInput in,
oracle.xml.comp.CXMLContext cxmlContext)
This method restores the information written by writeExternal by reading the input stream and regenerating the objects as per the information of the input stream. |
Node |
removeChild(Node elem)
removes the elem from this documents list of child nodes |
Node |
replaceChild(Node newChild,
Node oldChild)
Replaces the child node oldChild with newChild
in the list of children, and returns the oldChild node. |
void |
reportSAXEvents(ContentHandler cntHandler)
Report SAX Events from a DOM Tree |
void |
setDoctype(java.lang.String rootname,
java.lang.String sysid,
java.lang.String pubid)
Sets the doctype URI for the document |
void |
setEncoding(java.lang.String encoding)
Sets the character encoding for output. |
void |
setLocale(java.util.Locale locale)
Sets the locale for error reporting |
void |
setNodeContext(oracle.xml.util.NodeContext nctx)
|
void |
setParsedDoctype(java.lang.String rootname,
java.lang.String sysid,
java.lang.String pubid)
Sets the doctype object by parsing sysid |
void |
setStandalone(java.lang.String value)
Sets the standalone information stored in the <?xml ...?> tag. |
void |
setVersion(java.lang.String version)
Sets the version number stored in the <?xml ...?> tag. |
boolean |
validateElementContent(Element e)
Validates the content of a element node. |
void |
writeExternal(java.io.ObjectOutput outArg)
This method saves the state of the object by creating a binray compressed stream with information about this object. |
void |
writeExternal(oracle.xml.io.XMLObjectOutput out,
oracle.xml.comp.CXMLContext cxmlContext)
This method saves the state of the object by writing the object information in a binary compressed stream. |
Methods inherited from class oracle.xml.parser.v2.XMLNSNode |
addText,
addText,
getChildNodes,
getFirstChild,
getLastChild,
getNodeLocalName,
getNodeName,
getNodePrefix,
hasChildNodes,
setPrefix |
Methods inherited from class oracle.xml.parser.v2.XMLNode |
addEventListener,
dispatchEvent,
getNextSibling,
getNodeValue,
getParentNode,
getPreviousSibling,
getProperty,
isNodeFlag,
isSupported,
readChildNodes,
removeEventListener,
resetNodeFlag,
selectNodes,
selectNodes,
selectNodes,
selectSingleNode,
selectSingleNode,
setDebugInfo,
setNodeFlag,
setNodeValue,
setProperty,
supports,
transformNode,
valueOf,
valueOf |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Constructor Detail |
public XMLDocument()
Method Detail |
public java.lang.String getNamespaceURI()
null
if it is
unspecified.
ELEMENT_NODE
and
ATTRIBUTE_NODE
and nodes created with a DOM Level 1
method, such as createElement
from the
Document
interface, this is always null
.Per
the Namespaces in XML Specification an attribute does not inherit
its namespace from the element it is attached to. If an attribute is
not explicitly given a namespace, it simply has no namespace.public java.lang.String getLocalName()
public NamedNodeMap getAttributes()
NamedNodeMap
containing the attributes of this node (if
it is an Element
) or null
otherwise.public DocumentType getDoctype()
null
.
Note that the DOM Level 1 specification does not support editing the
DTD.DocumentType
public short getNodeType()
public DOMImplementation getImplementation()
DOMImplementation
object that handles this document. A
DOM application may use objects from multiple implementations.public Element getDocumentElement()
public Document getOwnerDocument()
Document
object associated with this node. Since this
node is a Document
this is null
.null
public void setNodeContext(oracle.xml.util.NodeContext nctx)
public Element createElement(java.lang.String tagName) throws DOMException
tagName
- The name of the element type to instantiate. The name is
treated as case-sensitive.Element
object.public DocumentFragment createDocumentFragment()
DocumentFragment
object.DocumentFragment
.public Text createTextNode(java.lang.String data)
Text
node given the specified string.data
- The data for the node.Text
object.public Comment createComment(java.lang.String data)
Comment
node given the specified string.data
- The data for the node.Comment
object.public CDATASection createCDATASection(java.lang.String data) throws DOMException
CDATASection
node whose value is the specified
string.data
- The data for the CDATASection
contents.CDATASection
object.DOMException
could be thrown.public ProcessingInstruction createProcessingInstruction(java.lang.String target, java.lang.String data) throws DOMException
ProcessingInstruction
node given the specified
name and data strings.target
- The target part of the processing instruction.data
- The data for the node.ProcessingInstruction
object.public Attr createAttribute(java.lang.String name) throws DOMException
Attr
of the given name. Note that the
Attr
instance can then be set on an Element
using the setAttribute
method.name
- The name of the attribute.Attr
object.public EntityReference createEntityReference(java.lang.String name) throws DOMException
name
- The name of the entity to reference.EntityReference
object.public NodeList getElementsByTagName(java.lang.String tagname)
NodeList
of all the Element
s with a
given tag name in the order in which they would be encountered in a
preorder traversal of the Document
tree.tagname
- The name of the tag to match on. The special value "*"
matches all tags.NodeList
object containing all the matched
Element
s.public Node appendChild(Node elem) throws DOMException
the
- new node to be addedelem
node.
elem
was created
from a different document than this one.public Node replaceChild(Node newChild, Node oldChild) throws DOMException
oldChild
with newChild
in the list of children, and returns the oldChild
node. If
the newChild
is already in the tree, it is first removed.
This is an override of the XMLNode.removeChild
methodnewChild
- The new node to put in the child list.oldChild
- The node being replaced in the list.newChild
node.
newChild
was created
from a different document than this one.
oldChild
is not a child of
this node.public Node removeChild(Node elem) throws DOMException
the
- node to be removedoldChild
is not a child of
this node.public Node insertBefore(Node newChild, Node refChild) throws DOMException
newChild
before the existing child node
refChild
. If refChild
is null
,
insert newChild
at the end of the list of children.
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.newChild
- The node to insert.refChild
- The reference node, i.e., the node before which the new
node must be inserted.newChild
node, or if
the node to insert is one of this node's ancestors.
newChild
was created
from a different document than the one that created this node.
refChild
is not a child of
this node.public Node cloneNode(boolean deep)
parentNode
returns null
.).
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.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
).public void setParsedDoctype(java.lang.String rootname, java.lang.String sysid, java.lang.String pubid) throws DOMException
root
- The name of the root elementsysid
- The system id of the doctypepubid
- The public id of the doctype (can be null)public void setDoctype(java.lang.String rootname, java.lang.String sysid, java.lang.String pubid)
root
- The name of the root elementsysid
- The system id of the doctypepubid
- The public id of the doctype (can be null)public void addID(java.lang.String name, XMLElement e)
id
- String - id valuee
- XMLElement associated with idpublic XMLElement getIDElement(java.lang.String idValue)
idvalue
- Get the element in the XML DOM Tree with a given ID
public java.util.Hashtable getIDHashtable()
public java.lang.String getText()
XMLDocument.getText
returns "William Shakespeare".
public void print(java.io.PrintWriter out) throws java.io.IOException
out
- PrintWriter
to write topublic void print(java.io.OutputStream out) throws java.io.IOException
out
- OutputStream
to write topublic void print(java.io.OutputStream out, java.lang.String enc) throws java.io.IOException
out
- OutputStream
to write toenc
- Encoding to use for the outputpublic void print(PrintDriver pd) throws java.io.IOException
pd
- PrintDriver
used to write each nodepublic void printExternalDTD(java.io.PrintWriter out) throws java.io.IOException
out
- PrintWriter
to write topublic void printExternalDTD(java.io.OutputStream out) throws java.io.IOException
out
- OutputStream
to write topublic void printExternalDTD(java.io.OutputStream out, java.lang.String enc) throws java.io.IOException
out
- OutputStream
to write toenc
- Encoding to use for the outputpublic void reportSAXEvents(ContentHandler cntHandler) throws SAXException
ContentHandler
- cntHandlerpublic boolean validateElementContent(Element e)
e
- Element to be validatedpublic final void setLocale(java.util.Locale locale)
locale
- Locale for error reporting.public java.util.Vector expectedElements(Element e)
e
- Elementpublic final java.lang.String getVersion()
public final void setVersion(java.lang.String version)
version
- The version information to set.public final java.lang.String getEncoding()
public final void setEncoding(java.lang.String encoding)
encoding
- The character encoding to setpublic final java.lang.String getStandalone()
public final void setStandalone(java.lang.String value)
value
- The attribute value ('yes' or 'no').public boolean getDebugMode()
public int getLineNumber()
public int getColumnNumber()
public java.lang.String getSystemId()
public Node adoptNode(Node srcNode) throws DOMException
Node
- to be adoptedpublic Node importNode(Node importedNode, boolean deep) throws DOMException
parentNode
is null
).
The source node is not altered or removed from the original document;
this method creates a new copy of the source node.
nodeName
and nodeType
, plus the
attributes related to namespaces (prefix
,
localName
, and namespaceURI
). As in the
cloneNode
operation on a Node
, the source
node is not altered.
nodeType
, attempting to mirror the behavior expected if
a fragment of XML or HTML source was copied from one document to
another, recognizing that the two documents may have different DTDs
in the XML case. The following list describes the specifics for each
type of node.
ownerElement
attribute
is set to null
and the specified
flag is
set to true
on the generated Attr
. The
descendants of the source Attr
are recursively imported
and the resulting nodes reassembled to form the corresponding subtree.
Note that the deep
parameter has no effect on
Attr
nodes; they always carry their children with them
when imported.deep
option
was set to true
, the descendants of the source element
are recursively imported and the resulting nodes reassembled to form
the corresponding subtree. Otherwise, this simply generates an empty
DocumentFragment
.Document
nodes cannot be imported.DocumentType
nodes cannot be imported.Attr
nodes are attached to the generated Element
. Default
attributes are not copied, though if the document being imported into
defines default attributes for this element name, those are assigned.
If the importNode
deep
parameter was set to
true
, the descendants of the source element are
recursively imported and the resulting nodes reassembled to form the
corresponding subtree.Entity
nodes can be
imported, however in the current release of the DOM the
DocumentType
is readonly. Ability to add these imported
nodes to a DocumentType
will be considered for addition
to a future release of the DOM.On import, the publicId
,
systemId
, and notationName
attributes are
copied. If a deep
import is requested, the descendants
of the the source Entity
are recursively imported and
the resulting nodes reassembled to form the corresponding subtree.EntityReference
itself is
copied, even if a deep
import is requested, since the
source and destination documents might have defined the entity
differently. If the document being imported into provides a
definition for this entity name, its value is assigned.Notation
nodes can be imported, however in the current
release of the DOM the DocumentType
is readonly. Ability
to add these imported nodes to a DocumentType
will be
considered for addition to a future release of the DOM.On import, the
publicId
and systemId
attributes are copied.
Note that the deep
parameter has no effect on
Notation
nodes since they never have any children.target
and data
values from those of the
source node.CharacterData
copy their
data
and length
attributes from those of
the source node.Node
- to be imported ,boolean variable indicating whether the
descendants of this node are to be importedpublic Element createElementNS(java.lang.String namespaceURI, java.lang.String qualifiedName) throws DOMException
String
- namespace URI , String qualified name for the element
to be createdpublic Attr createAttributeNS(java.lang.String namespaceURI, java.lang.String qualifiedName) throws DOMException
String
- namespace URI , String qualified name for the attribute
to be createdpublic NodeList getElementsByTagNameNS(java.lang.String namespaceURI, java.lang.String localName)
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.String
- namespaceURI,String localName that should match for the returned elementspublic Element getElementById(java.lang.String elementId)
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
. The DOM implementation must have
information that says which attributes are of type ID. Attributes
with the name "ID" are not of type ID unless so defined.
Implementations that do not know whether attributes are of type ID or
not are expected to return null
.String
- elementId used to get the matching Id Elementpublic NodeIterator createNodeIterator(Node root, int whatToShow, NodeFilter filter, boolean expandEntityReferences) throws DOMException
Node
- root ,int whatToShow, NodeFilter filter,boolean expandEntityReferencespublic TreeWalker createTreeWalker(Node root, int whatToShow, NodeFilter filter, boolean expandEntityReferences) throws DOMException
Node
- root ,int whatToShow, NodeFilter filter,boolean expandEntityReferencespublic Range createRange()
public Event createEvent(java.lang.String type)
String
- type the type of the eventpublic MutationEvent createMutationEvent(java.lang.String type)
public Event createRangeEvent(java.lang.String type)
public Event createTraversalEvent(java.lang.String type)
public void writeExternal(java.io.ObjectOutput outArg) throws java.io.IOException
out
- The ObjectOutput stream used to write the serialized/
compressed stream.public void writeExternal(oracle.xml.io.XMLObjectOutput out, oracle.xml.comp.CXMLContext cxmlContext) throws java.io.IOException
out
- The ObjectOutput stream used to write the serialized/
comressed stream.cxmlContext
- The context of the output compressed streampublic void readExternal(java.io.ObjectInput inArg) throws java.io.IOException, java.lang.ClassNotFoundException
in
- the ObjectInput stream used for reading the compressed streampublic void readExternal(oracle.xml.io.XMLObjectInput in, oracle.xml.comp.CXMLContext cxmlContext) throws java.io.IOException, java.lang.ClassNotFoundException
in
- is the XMLObjectInput stream used to read the compressed stream
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |