|
|||||||||
Home >> All >> org >> apache >> xerces >> [ tree overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: ![]() ![]() ![]() |
DETAIL: FIELD | CONSTR | METHOD |
org.apache.xerces.tree
Class XmlDocument

java.lang.Objectorg.apache.xerces.tree.NodeBase
org.apache.xerces.tree.ParentNode
org.apache.xerces.tree.XmlDocument
- All Implemented Interfaces:
- org.w3c.dom.Document, DocumentEx, org.w3c.dom.DOMImplementation, ElementFactory, org.w3c.dom.Node, NodeEx, org.w3c.dom.NodeList, XmlReadable, XmlWritable
- public class XmlDocument
- extends ParentNode
- implements DocumentEx, org.w3c.dom.DOMImplementation
- extends ParentNode
This class implements the DOM Document interface, and also provides static factory methods to create document instances. Instances represent the top level of an XML 1.0 document, typically consisting of processing instructions followed by one tree of XML data. These documents may be written out for transfer or storage using a variety of text encodings.
The static factory methods do not offer any customization options. in particular, they do not enforce XML Namespaces when parsing, do not offer customizable element factories, and discard certain information which is not intended to be significant to applications. If your application requires more sophisticated use of DOM, you may need to use SAX directly with an XmlDocumentBuilder.
Instances are factories for their subsidiary nodes, but applications
may provide their own element factory to bind element tags to particular
DOM implementation classes (which must subclass ElementNode). For
example, a factory may use a set of classes which support the HTML DOM
methods, or which support methods associated with XML vocabularies for
specialized problem domains as found within Internet Commerce systems.
For example, an element tag <PurchaseOrder>
could be mapped to a com.startup.commerce.PurchaseOrder
class. The factory can also use XML Namespace information, if desired.
Since DOM requires nodes to be owned exclusively by one document, they can't be moved from one document to another using DOM APIs. This class provides an changeNodeOwner functionality which may be used to change the document associated with a node, and with any of its children.
Only the core DOM model is supported here, not the HTML support. Such support basically adds a set of convenience element types, and so can be implemented through element factories and document subclasses.
- Version:
- $Revision: 1.1.1.1 $
Nested Class Summary | |
(package private) class |
ParentNode.TagList
|
(package private) class |
ParentNode.TagListNS
|
(package private) static class |
XmlDocument.Catalog
|
(package private) static class |
XmlDocument.DocFragNode
|
(package private) static class |
XmlDocument.EntityRefNode
|
(package private) class |
XmlDocument.ExtWriteContext
|
Field Summary | |
(package private) static MessageCatalog |
catalog
|
(package private) static java.lang.String |
eol
|
private ElementFactory |
factory
|
private java.util.Locale |
locale
|
(package private) int |
mutationCount
|
(package private) XmlDocument |
ownerDocument
|
(package private) boolean |
readonly
|
(package private) boolean |
replaceRootElement
|
private java.lang.String |
systemId
|
Constructor Summary | |
XmlDocument()
Constructs an empty document object. |
Method Summary | |
org.w3c.dom.Node |
appendChild(org.w3c.dom.Node n)
DOM: Appends the specified child node to the document. |
void |
changeNodeOwner(org.w3c.dom.Node node)
Changes the "owner document" of the given node, and all child and associated attribute nodes, to be this document. |
(package private) void |
checkChildType(int type)
|
java.util.Locale |
chooseLocale(java.lang.String[] languages)
Chooses a client locale to use for diagnostics, using the first language specified in the list that is supported by this DOM implementation. |
org.w3c.dom.Node |
cloneNode(boolean deep)
DOM: Returns a copy of this document. |
org.w3c.dom.Attr |
createAttribute(java.lang.String name)
DOM: Returns a valueless attribute node with no default value. |
org.w3c.dom.Attr |
createAttributeNS(java.lang.String namespaceURI,
java.lang.String qualifiedName)
DOM2: |
org.w3c.dom.CDATASection |
createCDATASection(java.lang.String text)
DOM: Returns a CDATA section initialized with the given text. |
org.w3c.dom.Comment |
createComment(java.lang.String data)
DOM: creates a comment node. |
(package private) Doctype |
createDoctype(java.lang.String name)
|
org.w3c.dom.Document |
createDocument(java.lang.String namespaceURI,
java.lang.String qualifiedName,
org.w3c.dom.DocumentType doctype)
DOM2: |
org.w3c.dom.DocumentFragment |
createDocumentFragment()
DOM: Creates a new document fragment. |
org.w3c.dom.DocumentType |
createDocumentType(java.lang.String qualifiedName,
java.lang.String publicId,
java.lang.String systemId)
Creates an empty DocumentType node. |
org.w3c.dom.DocumentType |
createDocumentType(java.lang.String qualifiedName,
java.lang.String publicId,
java.lang.String systemId,
java.lang.String internalSubset)
DOM2: |
org.w3c.dom.Element |
createElement(java.lang.String tagName)
DOM: Create a new element, associated with this document, with no children, attributes, or parent, by calling createElementEx. |
ElementEx |
createElementEx(java.lang.String tagName)
Create a new element, associated with this document, with no children, attributes, or parent. |
ElementEx |
createElementEx(java.lang.String uri,
java.lang.String tagName)
Create a new element, associated with this document, with no children, attributes, or parent. |
org.w3c.dom.Element |
createElementNS(java.lang.String namespaceURI,
java.lang.String qualifiedName)
DOM2: |
org.w3c.dom.EntityReference |
createEntityReference(java.lang.String name)
DOM: Creates an entity reference to the named entity. |
org.w3c.dom.ProcessingInstruction |
createProcessingInstruction(java.lang.String target,
java.lang.String instructions)
DOM: Returns a Processing Instruction node for the specified processing target, with the given instructions. |
org.w3c.dom.Text |
createTextNode(java.lang.String text)
DOM: returns a Text node initialized with the given text. |
XmlWriteContext |
createWriteContext(java.io.Writer out)
Returns an XML write context set up not to pretty-print, and which knows about the entities defined for this document. |
XmlWriteContext |
createWriteContext(java.io.Writer out,
int level)
Returns an XML write context which pretty-prints output starting at a specified indent level, and which knows about the entities defined for this document. |
static XmlDocument |
createXmlDocument(org.xml.sax.InputSource in,
boolean validate)
Construct an XML document from the data in the specified input source, optionally validating. |
static XmlDocument |
createXmlDocument(java.io.InputStream in,
boolean doValidate)
Construct an XML document from input stream, optionally validating. |
static XmlDocument |
createXmlDocument(java.lang.String documentURI)
Construct an XML document from the data at the specified URI, using the nonvalidating parser. |
static XmlDocument |
createXmlDocument(java.lang.String documentURI,
boolean doValidate)
Construct an XML document from the data at the specified URI, optionally validating. |
void |
doneChild(NodeEx child,
ParseContext context)
Subclasses may override this method, which is called after each child (text, element, processing instruction) is fully parsed. |
void |
doneParse(ParseContext context)
Subclasses may override this method, which is called shortly after the object is fully parsed. |
org.w3c.dom.NamedNodeMap |
getAttributes()
DOM: returns null. |
org.w3c.dom.NodeList |
getChildNodes()
DOM: Returns an object which permits "live" access to all this node's children. |
org.w3c.dom.DocumentType |
getDoctype()
DOM: returns the document type (DTD) |
(package private) ElementNode |
getDocument()
|
org.w3c.dom.Element |
getDocumentElement()
DOM: Returns the content root element. |
org.w3c.dom.Element |
getElementById(java.lang.String elementId)
DOM2: |
ElementEx |
getElementExById(java.lang.String id)
Returns the element whose ID is given by the parameter; or null if no such element exists. |
ElementFactory |
getElementFactory()
Returns the element factory to be used by this document. |
org.w3c.dom.NodeList |
getElementsByTagName(java.lang.String tagname)
DOM: Returns a "live" list view of the elements below this one which have the specified tag name. |
org.w3c.dom.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 document order. |
org.w3c.dom.Node |
getFirstChild()
DOM: Returns the first child of this node, else null if there are no children. |
org.w3c.dom.DOMImplementation |
getImplementation()
DOM: Returns an object describing the features of the DOM implementation used by this document: it supports the XML 1.0 feature set. |
int |
getIndexOf(org.w3c.dom.Node maybeChild)
Returns the index of the node in the list of children, such that item() will return that child. |
java.lang.String |
getInheritedAttribute(java.lang.String name)
Returns the value of a given attribute, tracing up through ancestors if needed. |
java.lang.String |
getInheritedAttribute(java.lang.String namespace,
java.lang.String name)
Returns the value of a given attribute, tracing up through ancestors if needed. |
java.lang.String |
getLanguage()
Returns the language id (value of xml:lang
attribute) applicable to this node, if known. |
org.w3c.dom.Node |
getLastChild()
DOM: Returns the last child of this node, else null if there are no children. |
int |
getLength()
DOM: Returns the number of children |
java.util.Locale |
getLocale()
Returns the locale to be used for diagnostic messages. |
java.lang.String |
getLocalName()
DOM2: returns null. |
(package private) java.lang.String |
getMessage(java.lang.String messageId)
|
(package private) java.lang.String |
getMessage(java.lang.String messageId,
java.lang.Object[] parameters)
|
java.lang.String |
getNamespaceURI()
DOM2: returns null. |
org.w3c.dom.Node |
getNextSibling()
DOM: Returns the node immediately following this node in a breadth first traversal of the tree, or null if there is no such sibling. |
java.lang.String |
getNodeName()
DOM: Returns the string "#document". |
short |
getNodeType()
DOM: Returns the DOCUMENT_NODE node type constant. |
java.lang.String |
getNodeValue()
DOM: Returns null; overridden by subclasses as needed. |
org.w3c.dom.Document |
getOwnerDoc()
DOM: returns null. |
org.w3c.dom.Document |
getOwnerDocument()
DOM: Returns the document to which this node belongs. |
(package private) ParentNode |
getParentImpl()
|
org.w3c.dom.Node |
getParentNode()
DOM: Returns the node's parent. |
java.lang.String |
getPrefix()
DOM2: returns null. |
org.w3c.dom.Node |
getPreviousSibling()
DOM: Returns the node immediately preceding this node in a breadth first traversal of the tree, or null if there is no such sibling. |
java.lang.String |
getSystemId()
Returns system ID associated with the document, or null if this is unknown. |
boolean |
hasChildNodes()
DOM: Returns true if there are children to this node. |
boolean |
hasFeature(java.lang.String feature,
java.lang.String version)
DOM: Reports on features that this document supports |
(package private) static boolean |
hasFeature0(java.lang.String feature,
java.lang.String version)
Reports on features that this implementation supports. |
org.w3c.dom.Node |
importNode(org.w3c.dom.Node importedNode,
boolean deep)
Imports a node from another document to this document, without altering or removing the source node from the original document; this method creates a new copy of the source node. |
org.w3c.dom.Node |
insertBefore(org.w3c.dom.Node n,
org.w3c.dom.Node refNode)
DOM: Inserts the specified child node into the document. |
boolean |
isReadonly()
Method to allow easy determination of whether a node is read only. |
org.w3c.dom.Node |
item(int i)
DOM: Returns the Nth child, or null |
(package private) static java.lang.String |
java2std(java.lang.String encodingName)
|
(package private) TextNode |
newText(char[] buf,
int offset,
int len)
|
void |
normalize()
Puts all Text nodes in the full depth of the sub-tree
underneath this Node , including attribute nodes, into a
"normal" form where only structure (e.g., elements, comments,
processing instructions, CDATA sections, and entity references)
separates Text nodes, i.e., there are neither adjacent
Text nodes nor empty Text nodes. |
(package private) void |
reduceWaste()
|
org.w3c.dom.Node |
removeChild(org.w3c.dom.Node oldChild)
DOM: removes child if present, returning argument. |
int |
removeWhiteSpaces(char[] buf)
|
org.w3c.dom.Node |
replaceChild(org.w3c.dom.Node newChild,
org.w3c.dom.Node refChild)
DOM: Replaces the specified child with the new node, returning the original child or throwing an exception. |
org.w3c.dom.DocumentType |
setDoctype(java.lang.String dtdPublicId,
java.lang.String dtdSystemId,
java.lang.String internalSubset)
Establishes how the document prints its document type. |
void |
setElementFactory(ElementFactory factory)
Assigns the element factory to be used by this document. |
void |
setLocale(java.util.Locale locale)
Assigns the locale to be used for diagnostic messages. |
void |
setNodeValue(java.lang.String value)
DOM: does nothing; overridden by subclasses as needed. |
(package private) void |
setOwnerDocument(XmlDocument doc)
|
(package private) void |
setParentNode(ParentNode arg,
int index)
|
void |
setPrefix(java.lang.String prefix)
DOM2: throws DOMException.NAMESPACE_ERR Overridden by subclasses that support namespaces. |
void |
setReadonly(boolean deep)
Sets the node to be readonly; applies recursively to the children of this node if the parameter is true. |
void |
setSystemId(java.lang.String uri)
Assigns the URI associated with the document, which is its system ID. |
void |
startParse(ParseContext context)
Subclasses may override this method, which is called shortly after the object type is known and before any children are processed. |
boolean |
supports(java.lang.String feature,
java.lang.String version)
DOM2: |
void |
trimToSize()
Called to minimize space utilization. |
void |
write(java.io.OutputStream out)
Writes the document in UTF-8 character encoding, as a well formed XML construct. |
void |
write(java.io.Writer out)
Writes the document as a well formed XML construct. |
void |
write(java.io.Writer out,
java.lang.String encoding)
Writes the document in the specified encoding, and listing that encoding in the XML declaration. |
void |
writeChildrenXml(XmlWriteContext context)
Writes all the child nodes of the document, following each one with the end-of-line string in use in this environment. |
void |
writeXml(XmlWriteContext context)
Writes the document out using the specified context, using an encoding name derived from the stream in the context where that is possible. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.w3c.dom.Document |
adoptNode, getDocumentURI, getDomConfig, getElementsByTagName, getElementsByTagNameNS, getInputEncoding, getStrictErrorChecking, getXmlEncoding, getXmlStandalone, getXmlVersion, normalizeDocument, renameNode, setDocumentURI, setStrictErrorChecking, setXmlStandalone, setXmlVersion |
Methods inherited from interface org.w3c.dom.Node |
compareDocumentPosition, getAttributes, getBaseURI, getChildNodes, getFeature, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNodeValue, getOwnerDocument, getParentNode, getPrefix, getPreviousSibling, getTextContent, getUserData, hasAttributes, hasChildNodes, isDefaultNamespace, isEqualNode, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, normalize, removeChild, setNodeValue, setPrefix, setTextContent, setUserData |
Methods inherited from interface org.apache.xerces.tree.XmlReadable |
doneChild, doneParse, startParse |
Methods inherited from interface org.w3c.dom.DOMImplementation |
getFeature |
Field Detail |
eol
static java.lang.String eol
catalog
static final MessageCatalog catalog
locale
private java.util.Locale locale
systemId
private java.lang.String systemId
factory
private ElementFactory factory
mutationCount
int mutationCount
replaceRootElement
boolean replaceRootElement
ownerDocument
XmlDocument ownerDocument
readonly
boolean readonly
Constructor Detail |
XmlDocument
public XmlDocument()
- Constructs an empty document object.
Method Detail |
createXmlDocument
public static XmlDocument createXmlDocument(java.lang.String documentURI, boolean doValidate) throws java.io.IOException, org.xml.sax.SAXException
- Construct an XML document from the data at the specified URI,
optionally validating. This uses validating parser if
validation is requested, otherwise uses non-validating
parser. XML Namespace conformance is not tested when parsing.
createXmlDocument
public static XmlDocument createXmlDocument(java.lang.String documentURI) throws java.io.IOException, org.xml.sax.SAXException
- Construct an XML document from the data at the specified URI,
using the nonvalidating parser. XML Namespace conformance
is not tested when parsing.
createXmlDocument
public static XmlDocument createXmlDocument(java.io.InputStream in, boolean doValidate) throws java.io.IOException, org.xml.sax.SAXException
- Construct an XML document from input stream, optionally validating.
This document must not require interpretation of relative URLs,
since the base URL is not known. This uses the validating parser
if validation is requested, otherwise uses the non-validating
parser. XML Namespace conformance is not tested when parsing.
createXmlDocument
public static XmlDocument createXmlDocument(org.xml.sax.InputSource in, boolean validate) throws java.io.IOException, org.xml.sax.SAXException
- Construct an XML document from the data in the specified input
source, optionally validating. This uses the validating parser
if validation is requested, otherwise uses the non-validating
parser. XML Namespace conformance is not tested when parsing.
getDocument
ElementNode getDocument()
getLocale
public java.util.Locale getLocale()
- Returns the locale to be used for diagnostic messages.
- Specified by:
getLocale
in interfaceDocumentEx
setLocale
public void setLocale(java.util.Locale locale)
- Assigns the locale to be used for diagnostic messages.
Multi-language applications, such as web servers dealing with
clients from different locales, need the ability to interact
with clients in languages other than the server's default.
When an XmlDocument is created, its locale is the default
locale for the virtual machine.
- Specified by:
setLocale
in interfaceDocumentEx
chooseLocale
public java.util.Locale chooseLocale(java.lang.String[] languages)
- Chooses a client locale to use for diagnostics, using the first
language specified in the list that is supported by this DOM
implementation. That locale is then automatically assigned using setLocale(). Such a list
could be provided by a variety of user preference mechanisms,
including the HTTP Accept-Language header field.
- Specified by:
chooseLocale
in interfaceDocumentEx
write
public void write(java.io.OutputStream out) throws java.io.IOException
- Writes the document in UTF-8 character encoding, as a well formed
XML construct.
write
public void write(java.io.Writer out) throws java.io.IOException
- Writes the document as a well formed XML construct. If the
encoding can be determined from the writer, that is used in
the document's XML declaration. The encoding name may first
be transformed from a Java-internal form to a standard one;
for example, Java's "UTF8" is the standard "UTF-8".
Use of UTF-8 (or UTF-16) OutputStreamWriters is strongly encouraged. All other encodings may lose critical data, since the standard Java output writers substitute characters such as the question mark for data which they can't encode in the current output encoding. The IETF and other organizations strongly encourage the use of UTF-8; also, all XML processors are guaranteed to support it.
java2std
static java.lang.String java2std(java.lang.String encodingName)
write
public void write(java.io.Writer out, java.lang.String encoding) throws java.io.IOException
- Writes the document in the specified encoding, and listing
that encoding in the XML declaration. The document will be
well formed XML; at this time, it will not additionally be
valid XML or standalone, since it includes no document type
declaration.
Note that the document will by default be "pretty printed". Extra whitespace is added to indent children of elements according to their level of nesting, unless those elements have (or inherit) the xml:space='preserve' attribute value. This space will be removed if, when the document is read back with DOM, a call to ElementNode.normalize is made. To avoid this pretty printing, use a write context configured to disable it, or explicitly assign an xml:space='preserve' attribute to the root node of your document.
Also, if a SAX parser was used to construct this tree, data will have been discarded. Most of that will be insignificant in terms of a "logical" view of document data: comments, whitespace outside of the top level element, the exact content of the XML directive, and entity references were expanded. However, if a DOCTYPE declaration was provided, it was also discarded. Such declarations will often be logically significant, due to the attribute value defaulting and normalization they can provide.
In general, DOM does not support "round tripping" data from XML to DOM and back without losing data about physical structures and DTD information. "Logical structure" will be preserved.
createWriteContext
public XmlWriteContext createWriteContext(java.io.Writer out)
- Returns an XML write context set up not to pretty-print,
and which knows about the entities defined for this document.
createWriteContext
public XmlWriteContext createWriteContext(java.io.Writer out, int level)
- Returns an XML write context which pretty-prints output starting
at a specified indent level, and which knows about the entities
defined for this document.
writeXml
public void writeXml(XmlWriteContext context) throws java.io.IOException
- Writes the document out using the specified context, using
an encoding name derived from the stream in the context where
that is possible.
- Specified by:
writeXml
in interfaceXmlWritable
writeChildrenXml
public void writeChildrenXml(XmlWriteContext context) throws java.io.IOException
- Writes all the child nodes of the document, following each one
with the end-of-line string in use in this environment.
- Specified by:
writeChildrenXml
in interfaceXmlWritable
- Overrides:
writeChildrenXml
in classParentNode
checkChildType
void checkChildType(int type) throws org.w3c.dom.DOMException
- Specified by:
checkChildType
in classParentNode
setSystemId
public final void setSystemId(java.lang.String uri)
- Assigns the URI associated with the document, which is its
system ID.
getSystemId
public final java.lang.String getSystemId()
- Returns system ID associated with the document, or null if
this is unknown.
This URI should not be used when interpreting relative URIs, since the document may be partially stored in external parsed entities with different base URIs. Instead, use methods in the XmlReadable interface as the document is being parsed, so that the correct base URI is available.
- Specified by:
getSystemId
in interfaceDocumentEx
appendChild
public org.w3c.dom.Node appendChild(org.w3c.dom.Node n) throws org.w3c.dom.DOMException
- DOM: Appends the specified child node to the document. Only one
element or document type node may be a child of a document.
- Specified by:
appendChild
in interfaceorg.w3c.dom.Node
- Overrides:
appendChild
in classParentNode
insertBefore
public org.w3c.dom.Node insertBefore(org.w3c.dom.Node n, org.w3c.dom.Node refNode) throws org.w3c.dom.DOMException
- DOM: Inserts the specified child node into the document. Only one
element or document type node may be a child of a document.
- Specified by:
insertBefore
in interfaceorg.w3c.dom.Node
- Overrides:
insertBefore
in classParentNode
replaceChild
public org.w3c.dom.Node replaceChild(org.w3c.dom.Node newChild, org.w3c.dom.Node refChild) throws org.w3c.dom.DOMException
- DOM: Replaces the specified child with the new node,
returning the original child or throwing an exception.
The new child must belong to this particular document.
- Specified by:
replaceChild
in interfaceorg.w3c.dom.Node
- Overrides:
replaceChild
in classParentNode
getNodeType
public final short getNodeType()
- DOM: Returns the DOCUMENT_NODE node type constant.
- Specified by:
getNodeType
in interfaceorg.w3c.dom.Node
getDoctype
public final org.w3c.dom.DocumentType getDoctype()
- DOM: returns the document type (DTD)
- Specified by:
getDoctype
in interfaceorg.w3c.dom.Document
createDoctype
Doctype createDoctype(java.lang.String name)
setDoctype
public org.w3c.dom.DocumentType setDoctype(java.lang.String dtdPublicId, java.lang.String dtdSystemId, java.lang.String internalSubset)
- Establishes how the document prints its document type. If a system
ID (URI) is provided, that is used in a SYSTEM (or PUBLIC, if a public
ID is also provided) declaration. If an internal subset is provided,
that will be printed. The root element in the DTD will be what the
document itself provides.
getDocumentElement
public org.w3c.dom.Element getDocumentElement()
- DOM: Returns the content root element.
- Specified by:
getDocumentElement
in interfaceorg.w3c.dom.Document
setElementFactory
public final void setElementFactory(ElementFactory factory)
- Assigns the element factory to be used by this document.
- Specified by:
setElementFactory
in interfaceDocumentEx
getElementFactory
public final ElementFactory getElementFactory()
- Returns the element factory to be used by this document.
- Specified by:
getElementFactory
in interfaceDocumentEx
createElement
public final org.w3c.dom.Element createElement(java.lang.String tagName) throws org.w3c.dom.DOMException
- DOM: Create a new element, associated with this document, with
no children, attributes, or parent, by calling createElementEx.
- Specified by:
createElement
in interfaceorg.w3c.dom.Document
createElementNS
public org.w3c.dom.Element createElementNS(java.lang.String namespaceURI, java.lang.String qualifiedName) throws org.w3c.dom.DOMException
- DOM2:
- Specified by:
createElementNS
in interfaceorg.w3c.dom.Document
- Since:
- DOM Level 2 XXX Does not work with ElementFactory
createElementEx
public final ElementEx createElementEx(java.lang.String tagName) throws org.w3c.dom.DOMException
- Create a new element, associated with this document, with no
children, attributes, or parent. This uses the element factory,
or else directly constructs an ElementNode.
- Specified by:
createElementEx
in interfaceElementFactory
createElementEx
public final ElementEx createElementEx(java.lang.String uri, java.lang.String tagName) throws org.w3c.dom.DOMException
- Create a new element, associated with this document, with no
children, attributes, or parent. This uses the element factory,
or else directly constructs an ElementNode.
- Specified by:
createElementEx
in interfaceElementFactory
createTextNode
public org.w3c.dom.Text createTextNode(java.lang.String text)
- DOM: returns a Text node initialized with the given text.
- Specified by:
createTextNode
in interfaceorg.w3c.dom.Document
createCDATASection
public org.w3c.dom.CDATASection createCDATASection(java.lang.String text)
- DOM: Returns a CDATA section initialized with the given text.
- Specified by:
createCDATASection
in interfaceorg.w3c.dom.Document
newText
TextNode newText(char[] buf, int offset, int len) throws org.xml.sax.SAXException
createProcessingInstruction
public org.w3c.dom.ProcessingInstruction createProcessingInstruction(java.lang.String target, java.lang.String instructions) throws org.w3c.dom.DOMException
- DOM: Returns a Processing Instruction node for the specified
processing target, with the given instructions.
- Specified by:
createProcessingInstruction
in interfaceorg.w3c.dom.Document
createAttribute
public org.w3c.dom.Attr createAttribute(java.lang.String name) throws org.w3c.dom.DOMException
- DOM: Returns a valueless attribute node with no default value.
- Specified by:
createAttribute
in interfaceorg.w3c.dom.Document
createAttributeNS
public org.w3c.dom.Attr createAttributeNS(java.lang.String namespaceURI, java.lang.String qualifiedName) throws org.w3c.dom.DOMException
- DOM2:
- Specified by:
createAttributeNS
in interfaceorg.w3c.dom.Document
- Since:
- DOM Level 2
createComment
public org.w3c.dom.Comment createComment(java.lang.String data)
- DOM: creates a comment node.
- Specified by:
createComment
in interfaceorg.w3c.dom.Document
getOwnerDoc
public org.w3c.dom.Document getOwnerDoc()
- DOM: returns null.
getImplementation
public org.w3c.dom.DOMImplementation getImplementation()
- DOM: Returns an object describing the features of the DOM implementation
used by this document: it supports the XML 1.0 feature set.
- Specified by:
getImplementation
in interfaceorg.w3c.dom.Document
createDocumentFragment
public org.w3c.dom.DocumentFragment createDocumentFragment()
- DOM: Creates a new document fragment.
- Specified by:
createDocumentFragment
in interfaceorg.w3c.dom.Document
createEntityReference
public org.w3c.dom.EntityReference createEntityReference(java.lang.String name) throws org.w3c.dom.DOMException
- DOM: Creates an entity reference to the named entity.
Note that the entity must already be defined in the document
type, and that the name must be a legal entity name.
- Specified by:
createEntityReference
in interfaceorg.w3c.dom.Document
getNodeName
public final java.lang.String getNodeName()
- DOM: Returns the string "#document".
- Specified by:
getNodeName
in interfaceorg.w3c.dom.Node
cloneNode
public org.w3c.dom.Node cloneNode(boolean deep)
- DOM: Returns a copy of this document.
Note: At this time, any element factory or document type associated with this document will not be cloned.
- Specified by:
cloneNode
in interfaceorg.w3c.dom.Node
changeNodeOwner
public final void changeNodeOwner(org.w3c.dom.Node node) throws org.w3c.dom.DOMException
- Changes the "owner document" of the given node, and all child
and associated attribute nodes, to be this document. If the
node has a parent, it is first removed from that parent.
- Specified by:
changeNodeOwner
in interfaceDocumentEx
hasFeature0
static boolean hasFeature0(java.lang.String feature, java.lang.String version)
- Reports on features that this implementation supports. Allows code to
be shared with NodeBase.supports().
hasFeature
public boolean hasFeature(java.lang.String feature, java.lang.String version)
- DOM: Reports on features that this document supports
- Specified by:
hasFeature
in interfaceorg.w3c.dom.DOMImplementation
createDocumentType
public org.w3c.dom.DocumentType createDocumentType(java.lang.String qualifiedName, java.lang.String publicId, java.lang.String systemId, java.lang.String internalSubset)
- DOM2:
- Since:
- DOM Level 2
createDocumentType
public org.w3c.dom.DocumentType createDocumentType(java.lang.String qualifiedName, java.lang.String publicId, java.lang.String systemId)
- Description copied from interface:
org.w3c.dom.DOMImplementation
- Creates an empty
DocumentType
node. Entity declarations and notations are not made available. Entity reference expansions and default attribute additions do not occur..- Specified by:
createDocumentType
in interfaceorg.w3c.dom.DOMImplementation
createDocument
public org.w3c.dom.Document createDocument(java.lang.String namespaceURI, java.lang.String qualifiedName, org.w3c.dom.DocumentType doctype) throws org.w3c.dom.DOMException
- DOM2:
- Specified by:
createDocument
in interfaceorg.w3c.dom.DOMImplementation
- Since:
- DOM Level 2
getElementById
public org.w3c.dom.Element getElementById(java.lang.String elementId)
- DOM2:
- Specified by:
getElementById
in interfaceorg.w3c.dom.Document
- Since:
- DOM Level 2
getElementExById
public ElementEx getElementExById(java.lang.String id)
- Returns the element whose ID is given by the parameter; or null
if no such element exists. This relies on elements to know the
name of their ID attribute, as will be currently be true only if
the document has been parsed from XML text with a DTD using the
XmlDocumentBuilder class, or if it has been constructed
using specialized DOM implementation classes which know the name
of their ID attribute. (XML allows only one ID attribute per
element, and different elements may use different names for their
ID attributes.)
This may be used to implement internal IDREF linkage, as well as some kinds of XPointer linkage as used in current drafts of XLink.
- Specified by:
getElementExById
in interfaceDocumentEx
importNode
public org.w3c.dom.Node importNode(org.w3c.dom.Node importedNode, boolean deep) throws org.w3c.dom.DOMException
- Description copied from interface:
org.w3c.dom.Document
- Imports a node from another document to this document, without altering
or removing the source node from the original document; this method
creates a new copy of the source node. The returned node has no
parent; (
parentNode
isnull
).
For all nodes, importing a node creates a node object owned by the importing document, with attribute values identical to the source node'snodeName
andnodeType
, plus the attributes related to namespaces (prefix
,localName
, andnamespaceURI
). As in thecloneNode
operation, the source node is not altered. User data associated to the imported node is not carried over. However, if anyUserDataHandlers
has been specified along with the associated data these handlers will be called with the appropriate parameters before this method returns.
Additional information is copied as appropriate to thenodeType
, 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.- ATTRIBUTE_NODE
- The
ownerElement
attribute is set tonull
and thespecified
flag is set totrue
on the generatedAttr
. The descendants of the sourceAttr
are recursively imported and the resulting nodes reassembled to form the corresponding subtree. Note that thedeep
parameter has no effect onAttr
nodes; they always carry their children with them when imported. - DOCUMENT_FRAGMENT_NODE
- If the
deep
option was set totrue
, the descendants of the sourceDocumentFragment
are recursively imported and the resulting nodes reassembled under the importedDocumentFragment
to form the corresponding subtree. Otherwise, this simply generates an emptyDocumentFragment
. - DOCUMENT_NODE
Document
nodes cannot be imported.- DOCUMENT_TYPE_NODE
DocumentType
nodes cannot be imported.- ELEMENT_NODE
- Specified attribute nodes of the source element are imported, and the generated
Attr
nodes are attached to the generatedElement
. Default attributes are not copied, though if the document being imported into defines default attributes for this element name, those are assigned. If theimportNode
deep
parameter was set totrue
, the descendants of the source element are recursively imported and the resulting nodes reassembled to form the corresponding subtree. - ENTITY_NODE
Entity
nodes can be imported, however in the current release of the DOM theDocumentType
is readonly. Ability to add these imported nodes to aDocumentType
will be considered for addition to a future release of the DOM.On import, thepublicId
,systemId
, andnotationName
attributes are copied. If adeep
import is requested, the descendants of the the sourceEntity
are recursively imported and the resulting nodes reassembled to form the corresponding subtree.- ENTITY_REFERENCE_NODE
- Only the
EntityReference
itself is copied, even if adeep
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_NODE
-
Notation
nodes can be imported, however in the current release of the DOM theDocumentType
is readonly. Ability to add these imported nodes to aDocumentType
will be considered for addition to a future release of the DOM.On import, thepublicId
andsystemId
attributes are copied. Note that thedeep
parameter has no effect on this type of nodes since they cannot have any children. - PROCESSING_INSTRUCTION_NODE
- The imported node copies its
target
anddata
values from those of the source node.Note that thedeep
parameter has no effect on this type of nodes since they cannot have any children. - TEXT_NODE, CDATA_SECTION_NODE, COMMENT_NODE
- These three types of nodes inheriting
from
CharacterData
copy theirdata
andlength
attributes from those of the source node.Note that thedeep
parameter has no effect on these types of nodes since they cannot have any children.
- Specified by:
importNode
in interfaceorg.w3c.dom.Document
- Since:
- DOM Level 2 XXX Fix to better conform to spec. cloneNode() also needs to be fixed.
trimToSize
public void trimToSize()
- Called to minimize space utilization. Affects only
this node; children must be individually trimmed.
reduceWaste
void reduceWaste()
startParse
public void startParse(ParseContext context) throws org.xml.sax.SAXException
- Subclasses may override this method, which is called shortly after
the object type is known and before any children are processed.
For elements, attributes are known and may be modified; since
parent context is available, inherited attributes can be seen.
The default implementation does nothing.
- Specified by:
startParse
in interfaceXmlReadable
doneChild
public void doneChild(NodeEx child, ParseContext context) throws org.xml.sax.SAXException
- Subclasses may override this method, which is called after each
child (text, element, processing instruction) is fully parsed.
Subclassers may substitute, discard, reorder, modify, or otherwise
process the child. For example, elements which correspond to object
properties may be stored in that way, rather than appended. The
startParse method has always been called before this.
The default implementation does nothing.
- Specified by:
doneChild
in interfaceXmlReadable
doneParse
public void doneParse(ParseContext context) throws org.xml.sax.SAXException
- Subclasses may override this method, which is called shortly after
the object is fully parsed. The startParse method has
always been called before this, and doneChild will have been called
for each child.
The default implementation does nothing.
- Specified by:
doneParse
in interfaceXmlReadable
hasChildNodes
public final boolean hasChildNodes()
- DOM: Returns true if there are children to this node.
- Specified by:
hasChildNodes
in interfaceorg.w3c.dom.Node
- Overrides:
hasChildNodes
in classNodeBase
getFirstChild
public final org.w3c.dom.Node getFirstChild()
- DOM: Returns the first child of this node, else null if there
are no children.
- Specified by:
getFirstChild
in interfaceorg.w3c.dom.Node
- Overrides:
getFirstChild
in classNodeBase
getLastChild
public final org.w3c.dom.Node getLastChild()
- DOM: Returns the last child of this node, else null if there
are no children.
- Specified by:
getLastChild
in interfaceorg.w3c.dom.Node
- Overrides:
getLastChild
in classNodeBase
getLength
public final int getLength()
- DOM: Returns the number of children
- Specified by:
getLength
in interfaceorg.w3c.dom.NodeList
- Overrides:
getLength
in classNodeBase
item
public final org.w3c.dom.Node item(int i)
- DOM: Returns the Nth child, or null
- Specified by:
item
in interfaceorg.w3c.dom.NodeList
- Overrides:
item
in classNodeBase
removeChild
public org.w3c.dom.Node removeChild(org.w3c.dom.Node oldChild) throws org.w3c.dom.DOMException
- DOM: removes child if present, returning argument.
- Specified by:
removeChild
in interfaceorg.w3c.dom.Node
- Overrides:
removeChild
in classNodeBase
getElementsByTagName
public org.w3c.dom.NodeList getElementsByTagName(java.lang.String tagname)
- DOM: Returns a "live" list view of the elements below this
one which have the specified tag name. Because this is "live", this
API is dangerous -- indices are not stable in the face of most tree
updates. Use a TreeWalker instead.
getElementsByTagNameNS
public org.w3c.dom.NodeList getElementsByTagNameNS(java.lang.String namespaceURI, java.lang.String localName)
- Since:
- DOM Level 2
getIndexOf
public final int getIndexOf(org.w3c.dom.Node maybeChild)
- Returns the index of the node in the list of children, such
that item() will return that child.
- Specified by:
getIndexOf
in interfaceNodeEx
- Overrides:
getIndexOf
in classNodeBase
normalize
public void normalize()
- Description copied from class:
NodeBase
- DOM2: noop.
- Specified by:
normalize
in interfaceorg.w3c.dom.Node
- Overrides:
normalize
in classNodeBase
- Since:
- DOM Level 2
In DOM2, normalize() was generalized and got moved to Node.
XXX Comments below are old:
DOM2: Merges all adjacent Text nodes in the tree rooted by this
element. Avoid using this on large blocks of text not separated
by markup such as elements or processing instructions, since it
can require arbitrarily large blocks of contiguous memory.
As a compatible extension to DOM, this normalizes treatment of whitespace except when the xml:space='preserve' attribute value applies to a node. All whitespace is normalized to one space. This ensures that text which is pretty-printed and then reread (and normalized) retains the same content.
removeWhiteSpaces
public int removeWhiteSpaces(char[] buf)
getParentImpl
ParentNode getParentImpl()
isReadonly
public boolean isReadonly()
- Description copied from interface:
NodeEx
- Method to allow easy determination of whether a node is read only.
- Specified by:
isReadonly
in interfaceNodeEx
setReadonly
public void setReadonly(boolean deep)
- Description copied from interface:
NodeEx
- Sets the node to be readonly; applies recursively to the children
of this node if the parameter is true.
- Specified by:
setReadonly
in interfaceNodeEx
getLanguage
public java.lang.String getLanguage()
- Returns the language id (value of
xml:lang
attribute) applicable to this node, if known. Traces up through ancestors as needed.- Specified by:
getLanguage
in interfaceNodeEx
getInheritedAttribute
public java.lang.String getInheritedAttribute(java.lang.String name)
- Returns the value of a given attribute, tracing up through
ancestors if needed. In the XML standard, two attributes are
inherited: xml:lang and xml:space. This
mechanism can also be involved with Cascading Style Sheets (CSS).
The current version of XML Namespaces also uses inheritance.
- Specified by:
getInheritedAttribute
in interfaceNodeEx
getInheritedAttribute
public java.lang.String getInheritedAttribute(java.lang.String namespace, java.lang.String name)
- Returns the value of a given attribute, tracing up through
ancestors if needed. This version accounts for namespaces,
so that the prefix used to identify the namespace of any
particular attribute is ignored when returning its value.
- Specified by:
getInheritedAttribute
in interfaceNodeEx
getParentNode
public org.w3c.dom.Node getParentNode()
- DOM: Returns the node's parent. This will be null in cases such
as newly created or removed nodes, and for attributes, fragments,
and documents.
- Specified by:
getParentNode
in interfaceorg.w3c.dom.Node
setParentNode
void setParentNode(ParentNode arg, int index) throws org.w3c.dom.DOMException
setOwnerDocument
void setOwnerDocument(XmlDocument doc)
getOwnerDocument
public org.w3c.dom.Document getOwnerDocument()
- DOM: Returns the document to which this node belongs.
- Specified by:
getOwnerDocument
in interfaceorg.w3c.dom.Node
setNodeValue
public void setNodeValue(java.lang.String value)
- DOM: does nothing; overridden by subclasses as needed.
- Specified by:
setNodeValue
in interfaceorg.w3c.dom.Node
getNodeValue
public java.lang.String getNodeValue()
- DOM: Returns null; overridden by subclasses as needed.
- Specified by:
getNodeValue
in interfaceorg.w3c.dom.Node
getChildNodes
public org.w3c.dom.NodeList getChildNodes()
- DOM: Returns an object which permits "live" access to all
this node's children.
In this implementation, nodes provide such access without needing another node as an intermediary; "this" is returned.
- Specified by:
getChildNodes
in interfaceorg.w3c.dom.Node
getNextSibling
public org.w3c.dom.Node getNextSibling()
- DOM: Returns the node immediately following this node in a
breadth first traversal of the tree, or null if there is no
such sibling. In this implementation, sibling access from a
node is slower than indexed access from its parent.
- Specified by:
getNextSibling
in interfaceorg.w3c.dom.Node
getPreviousSibling
public org.w3c.dom.Node getPreviousSibling()
- DOM: Returns the node immediately preceding this node in a
breadth first traversal of the tree, or null if there is no
such sibling. In this implementation, sibling access from a
node is slower than indexed access from its parent.
- Specified by:
getPreviousSibling
in interfaceorg.w3c.dom.Node
getAttributes
public org.w3c.dom.NamedNodeMap getAttributes()
- DOM: returns null.
Overridden by the ElementNode subclass.
- Specified by:
getAttributes
in interfaceorg.w3c.dom.Node
supports
public boolean supports(java.lang.String feature, java.lang.String version)
- DOM2:
- Since:
- DOM Level 2
getNamespaceURI
public java.lang.String getNamespaceURI()
- DOM2: returns null.
Overridden by subclasses that support namespaces, ie. ElementNode and
AttributeNode.
- Specified by:
getNamespaceURI
in interfaceorg.w3c.dom.Node
getPrefix
public java.lang.String getPrefix()
- DOM2: returns null.
Overridden by subclasses that support namespaces.
- Specified by:
getPrefix
in interfaceorg.w3c.dom.Node
setPrefix
public void setPrefix(java.lang.String prefix) throws org.w3c.dom.DOMException
- DOM2: throws DOMException.NAMESPACE_ERR
Overridden by subclasses that support namespaces.
- Specified by:
setPrefix
in interfaceorg.w3c.dom.Node
getLocalName
public java.lang.String getLocalName()
- DOM2: returns null.
Overridden by subclasses that support namespaces.
- Specified by:
getLocalName
in interfaceorg.w3c.dom.Node
getMessage
java.lang.String getMessage(java.lang.String messageId)
getMessage
java.lang.String getMessage(java.lang.String messageId, java.lang.Object[] parameters)
|
|||||||||
Home >> All >> org >> apache >> xerces >> [ tree overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: ![]() ![]() ![]() |
DETAIL: FIELD | CONSTR | METHOD |