|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Object
|
+--gnu.xml.dom.DomNode
|
+--gnu.xml.dom.DomDocument
"Document" and "DocumentTraversal" implementation.
Note that when this checks names for legality, it uses an approximation of the XML rules, not the real ones. Specifically, it uses Unicode rules, with sufficient tweaks to pass a majority of basic XML conformance tests. (The huge XML character tables are hairy to implement.)
| 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 | |
|
DomDocument()
Constructs a Document node, associating it with an instance of the DomImpl class. |
protected |
DomDocument(DOMImplementation impl)
Constructs a Document node, associating it with the specified implementation. |
| Method Summary | |
Node |
appendChild(Node newChild)
DOM L1 Appends the specified node to this node's list of children, enforcing the constraints that there be only one root element and one document type child. |
Attr |
createAttribute(java.lang.String name)
DOM L1 Returns a newly created attribute with the specified name. |
Attr |
createAttributeNS(java.lang.String namespaceURI,
java.lang.String name)
DOM L2 Returns a newly created attribute with the specified name and namespace information. |
CDATASection |
createCDATASection(java.lang.String value)
DOM L1 Returns a newly created CDATA section node with the specified value. |
Comment |
createComment(java.lang.String value)
DOM L1 Returns a newly created comment node with the specified value. |
DocumentFragment |
createDocumentFragment()
DOM L1 Returns a newly created document fragment. |
Element |
createElement(java.lang.String name)
DOM L1 Returns a newly created element with the specified name. |
Element |
createElementNS(java.lang.String namespaceURI,
java.lang.String name)
DOM L2 Returns a newly created element with the specified name and namespace information. |
EntityReference |
createEntityReference(java.lang.String name)
DOM L1 Returns a newly created reference to the specified entity. |
org.w3c.dom.traversal.NodeIterator |
createNodeIterator(Node root,
int whatToShow,
org.w3c.dom.traversal.NodeFilter filter,
boolean expandEntities)
DOM L2 (Traversal) Returns a newly created node iterator. |
ProcessingInstruction |
createProcessingInstruction(java.lang.String target,
java.lang.String data)
DOM L1 Returns a newly created processing instruction. |
Text |
createTextNode(java.lang.String value)
DOM L1 Returns a newly created text node with the specified value. |
org.w3c.dom.traversal.TreeWalker |
createTreeWalker(Node root,
int whatToShow,
org.w3c.dom.traversal.NodeFilter filter,
boolean entityReferenceExpansion)
Create a new TreeWalker over the subtree rooted at the
specified node. |
DocumentType |
getDoctype()
DOM L1 Returns the document's DocumentType, or null. |
Element |
getDocumentElement()
DOM L1 Returns the document's root element, or null. |
Element |
getElementById(java.lang.String id)
DOM L1 (relocated in DOM L2) Returns the element with the specified "ID" attribute, or null. |
DOMImplementation |
getImplementation()
DOM L1 Returns the document's DOMImplementation. |
java.lang.String |
getNodeName()
DOM L1 Returns the constant "#document". |
Node |
importNode(Node copiedNode,
boolean deep)
DOM L2 Makes a copy of the specified node, with all nodes "owned" by this document and with children optionally copied. |
Node |
insertBefore(Node newChild,
Node refChild)
DOM L1 Inserts the specified node in this node's list of children, enforcing the constraints that there be only one root element and one document type child. |
boolean |
isCheckingCharacters()
Returns true if certain expensive checks are performed. |
Node |
replaceChild(Node newChild,
Node refChild)
DOM L1 Replaces the specified node in this node's list of children, enforcing the constraints that there be only one root element and one document type child. |
void |
setCheckingCharacters(boolean value)
Controls whether certain expensive checks, duplicating those that conformant XML parsers must perform, are made. |
static void |
verifyXmlName(java.lang.String name)
Throws a DOM exception if the specified name is not a legal XML 1.0 name. |
| Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.w3c.dom.Document |
getElementsByTagName, getElementsByTagNameNS |
| Methods inherited from interface org.w3c.dom.Node |
cloneNode, getAttributes, getChildNodes, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNodeType, getNodeValue, getOwnerDocument, getParentNode, getPrefix, getPreviousSibling, hasAttributes, hasChildNodes, isSupported, normalize, removeChild, setNodeValue, setPrefix |
| Constructor Detail |
public DomDocument()
Note that this constructor disables character checking. It is normally used when connecting a DOM to an XML parser, and duplicating such checks is undesirable. When used for purposes other than connecting to a parser, you should re-enable that checking.
setCheckingCharacters(boolean)protected DomDocument(DOMImplementation impl)
Note that this constructor enables character checking; this constructor is not normally used when connecting a DOM to an XML parser, so
DomImpl,
setCheckingCharacters(boolean)| Method Detail |
public final java.lang.String getNodeName()
getNodeName in interface Nodepublic final Element getDocumentElement()
getDocumentElement in interface Documentpublic final DocumentType getDoctype()
getDoctype in interface Documentpublic final DOMImplementation getImplementation()
getImplementation in interface Documentpublic Element getElementById(java.lang.String id)
Since there is no nonproprietary way to associate the "ID" type with attributes (L3 should finally offer this functionality) this returns null unless it is overridden by some subclass accessing proprietary functionality, or (as with the XHTML DOM) hard-wiring such DTD knowledge in software.
getElementById in interface Documentorg.w3c.dom.DocumentelementIdThe - unique id value for an element.public Node appendChild(Node newChild)
appendChild in interface NodeappendChild in class DomNodeorg.w3c.dom.NodenewChildThe - node to add.If it is a DocumentFragment
object, the entire contents of the document fragment are moved
into the child list of this nodeDOMException - HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not
allow children of the type of the newChild node, or if
the node to append is one of this node's ancestors.
newChild was created
from a different document than the one that created this node.
public Node insertBefore(Node newChild,
Node refChild)
insertBefore in interface NodeinsertBefore in class DomNodeorg.w3c.dom.NodenewChildThe - node to insert.refChildThe - reference node, i.e., the node before which the new
node must be inserted.DOMException - HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not
allow children of the type of the 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 replaceChild(Node newChild,
Node refChild)
replaceChild in interface NodereplaceChild in class DomNodeorg.w3c.dom.NodenewChildThe - new node to put in the child list.oldChildThe - node being replaced in the list.DOMException - HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not
allow children of the type of the newChild node, or if
the node to put in is one of this node's ancestors.
newChild was created
from a different document than the one that created this node.
oldChild is not a child of
this node.public static void verifyXmlName(java.lang.String name)
DomException - INVALID_CHARACTER_ERR if the name isn't
legal as an XML name.public final void setCheckingCharacters(boolean value)
public final boolean isCheckingCharacters()
public Element createElement(java.lang.String name)
createElement in interface Documentorg.w3c.dom.DocumenttagNameThe - name of the element type to instantiate. For XML,
this is case-sensitive. For HTML, the tagName
parameter may be provided in any case, but it must be mapped to the
canonical uppercase form by the DOM implementation.Element object with the
nodeName attribute set to tagName, and
localName, prefix, and
namespaceURI set to null.DOMException - INVALID_CHARACTER_ERR: Raised if the specified name contains an
illegal character.
public Element createElementNS(java.lang.String namespaceURI,
java.lang.String name)
createElementNS in interface Documentorg.w3c.dom.DocumentnamespaceURIThe - namespace URI of the element to create.qualifiedNameThe - qualified name of the element type to
instantiate.Element object with the following
attributes:AttributeValueNode.nodeName
qualifiedNameNode.namespaceURI
namespaceURINode.prefixprefix, extracted
from qualifiedName, or null if there is
no prefixNode.localNamelocal name, extracted from
qualifiedNameElement.tagName
qualifiedNameDOMException - INVALID_CHARACTER_ERR: Raised if the specified qualified name
contains an illegal character.
qualifiedName is
malformed, if the qualifiedName has a prefix and the
namespaceURI is null, or if the
qualifiedName has a prefix that is "xml" and the
namespaceURI is different from "
http://www.w3.org/XML/1998/namespace" .public DocumentFragment createDocumentFragment()
createDocumentFragment in interface Documentorg.w3c.dom.DocumentDocumentFragment.public Text createTextNode(java.lang.String value)
createTextNode in interface Documentorg.w3c.dom.DocumentdataThe - data for the node.Text object.public Comment createComment(java.lang.String value)
createComment in interface Documentorg.w3c.dom.DocumentdataThe - data for the node.Comment object.public CDATASection createCDATASection(java.lang.String value)
createCDATASection in interface Documentorg.w3c.dom.DocumentdataThe - data for the CDATASection contents.CDATASection object.DOMException - NOT_SUPPORTED_ERR: Raised if this document is an HTML document.
public ProcessingInstruction createProcessingInstruction(java.lang.String target,
java.lang.String data)
createProcessingInstruction in interface Documentorg.w3c.dom.DocumenttargetThe - target part of the processing instruction.dataThe - data for the node.ProcessingInstruction object.DOMException - INVALID_CHARACTER_ERR: Raised if the specified target contains an
illegal character.
public Attr createAttribute(java.lang.String name)
createAttribute in interface Documentorg.w3c.dom.DocumentnameThe - name of the attribute.Attr object with the nodeName
attribute set to name, and localName,
prefix, and namespaceURI set to
null. The value of the attribute is the empty string.DOMException - INVALID_CHARACTER_ERR: Raised if the specified name contains an
illegal character.
public Attr createAttributeNS(java.lang.String namespaceURI,
java.lang.String name)
createAttributeNS in interface Documentorg.w3c.dom.DocumentnamespaceURIThe - namespace URI of the attribute to create.qualifiedNameThe - qualified name of the attribute to instantiate.Attr object with the following attributes:
AttributeValueNode.nodeNamequalifiedName
Node.namespaceURInamespaceURI
Node.prefixprefix, extracted from
qualifiedName, or null if there is no
prefixNode.localNamelocal name, extracted from
qualifiedNameAttr.name
qualifiedNameNode.nodeValuethe empty
stringDOMException - INVALID_CHARACTER_ERR: Raised if the specified qualified name
contains an illegal character.
qualifiedName is
malformed, if the qualifiedName has a prefix and the
namespaceURI is null, if the
qualifiedName has a prefix that is "xml" and the
namespaceURI is different from "
http://www.w3.org/XML/1998/namespace", or if the
qualifiedName is "xmlns" and the
namespaceURI is different from "
http://www.w3.org/2000/xmlns/".public EntityReference createEntityReference(java.lang.String name)
createEntityReference in interface DocumentDomNode.makeReadonly()
public Node importNode(Node copiedNode,
boolean deep)
Note that EntityReference nodes created through this method (either directly, or recursively) never have children, and that there is no portable way to associate them with such children.
Note also that there is no requirement that the specified node be associated with a different document. This differs from the cloneNode operation in that the node itself is not given an opportunity to participate, so that any information managed by node subclasses will be lost.
importNode in interface Documentorg.w3c.dom.DocumentimportedNodeThe - node to import.deepIf - true, recursively import the subtree under
the specified node; if false, import only the node
itself, as explained above. This has no effect on Attr
, EntityReference, and Notation nodes.Document.DOMException - NOT_SUPPORTED_ERR: Raised if the type of node being imported is not
supported.
public org.w3c.dom.traversal.NodeIterator createNodeIterator(Node root,
int whatToShow,
org.w3c.dom.traversal.NodeFilter filter,
boolean expandEntities)
createNodeIterator in interface org.w3c.dom.traversal.DocumentTraversalDomIterator
public org.w3c.dom.traversal.TreeWalker createTreeWalker(Node root,
int whatToShow,
org.w3c.dom.traversal.NodeFilter filter,
boolean entityReferenceExpansion)
org.w3c.dom.traversal.DocumentTraversalTreeWalker over the subtree rooted at the
specified node.createTreeWalker in interface org.w3c.dom.traversal.DocumentTraversalorg.w3c.dom.traversal.DocumentTraversalrootThe - node which will serve as the root for the
TreeWalker. The whatToShow flags and the
NodeFilter are not considered when setting this value;
any node type will be accepted as the root. The
currentNode of the TreeWalker is
initialized to this node, whether or not it is visible. The
root functions as a stopping point for traversal
methods that look upward in the document structure, such as
parentNode and nextNode. The root must
not be null.whatToShowThis - flag specifies which node types may appear in
the logical view of the tree presented by the tree-walker. See the
description of NodeFilter for the set of possible
SHOW_ values.These flags can be combined using OR.filterThe - NodeFilter to be used with this
TreeWalker, or null to indicate no filter.entityReferenceExpansionIf - this flag is false, the contents of
EntityReference nodes are not presented in the logical
view.TreeWalker.DOMException - NOT_SUPPORTED_ERR: Raised if the specified root is
null.
|
Source code is GPL'd in the JAXP subproject at http://savannah.gnu.org/projects/classpathx |
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||