"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.)
appendChild
public 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.
- appendChild in interface DomNode
createAttribute
public Attr createAttribute(String name)
DOM L1
Returns a newly created attribute with the specified name.
createAttributeNS
public Attr createAttributeNS(String namespaceURI,
String name)
DOM L2
Returns a newly created attribute with the specified name
and namespace information.
createCDATASection
public CDATASection createCDATASection(char[] buf,
int off,
int len)
Returns a newly created CDATA section node with the specified value.
createCDATASection
public CDATASection createCDATASection(String value)
DOM L1
Returns a newly created CDATA section node with the specified value.
createComment
public Comment createComment(String value)
DOM L1
Returns a newly created comment node with the specified value.
createDocumentFragment
public DocumentFragment createDocumentFragment()
DOM L1
Returns a newly created document fragment.
createElement
public Element createElement(String name)
DOM L1
Returns a newly created element with the specified name.
createElementNS
public Element createElementNS(String namespaceURI,
String name)
DOM L2
Returns a newly created element with the specified name
and namespace information.
createEntityReference
public EntityReference createEntityReference(String name)
DOM L1
Returns a newly created reference to the specified entity.
The caller should populate this with the appropriate children
and then mark it as readonly.
createExpression
public XPathExpression createExpression(String expression,
XPathNSResolver resolver)
throws XPathException,
DOMException
createNodeIterator
public NodeIterator createNodeIterator(Node root,
int whatToShow,
NodeFilter filter,
boolean expandEntities)
DOM L2 (Traversal)
Returns a newly created node iterator. Don't forget to detach
this iterator when you're done using it!
createTextNode
public Text createTextNode(char[] buf,
int off,
int len)
Returns a newly created text node with the specified value.
createTextNode
public Text createTextNode(String value)
DOM L1
Returns a newly created text node with the specified value.
createTreeWalker
public TreeWalker createTreeWalker(Node root,
int whatToShow,
NodeFilter filter,
boolean expandEntities)
evaluate
public Object evaluate(String expression,
Node contextNode,
XPathNSResolver resolver,
short type,
Object result)
throws XPathException,
DOMException
getDoctype
public final DocumentType getDoctype()
DOM L1
Returns the document's DocumentType, or null.
getDocumentElement
public final Element getDocumentElement()
DOM L1
Returns the document's root element, or null.
getElementById
public Element getElementById(String id)
DOM L1 (relocated in DOM L2)
Returns the element with the specified "ID" attribute, or null.
Returns null unless
Consumer
was used to populate internal
DTD declaration information, using package-private APIs. If that
internal DTD information is available, the document may be searched for
the element with that ID.
getImplementation
public final DOMImplementation getImplementation()
DOM L1
Returns the document's DOMImplementation.
importNode
public Node importNode(Node src,
boolean deep)
DOM L2
Makes a copy of the specified node, with all nodes "owned" by
this document and with children optionally copied. This type
of standard utility has become, well, a standard utility.
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.
insertBefore
public 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.
- insertBefore in interface DomNode
replaceChild
public 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.
- replaceChild in interface DomNode
setBuilding
public void setBuilding(boolean flag)
Sets the building
flag.
Mutation events in the document are not reported.
setCheckWellformedness
public void setCheckWellformedness(boolean flag)
Sets whether to check for document well-formedness.
If true, an exception will be raised if a second doctype or root
element node is added to the document.
setCheckingCharacters
public void setCheckingCharacters(boolean flag)
Sets whether to check for document characters.
verifyXmlName
public static void verifyXmlName(String name)
This method is deprecated and may be removed in future
versions of GNU JAXP
Throws a DOM exception if the specified name is not a legal XML 1.0
Name.
DomDocument.java --
Copyright (C) 1999,2000,2001,2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version.