org.apache.xerces.dom
public class ElementImpl extends ParentNode implements Element, TypeInfo
Elements may have Attributes associated with them; the API for this is defined in Node, but the function is implemented here. In general, XML applications should retrive Attributes as Nodes, since they may contain entity references and hence be a fairly complex sub-tree. HTML users will be dealing with simple string values, and convenience methods are provided to work in terms of Strings.
ElementImpl does not support Namespaces. ElementNSImpl, which inherits from it, does.
Since: PR-DOM-Level-1-19980818.
Version: $Id: ElementImpl.java,v 1.71 2005/06/21 14:06:57 nddelima Exp $
See Also:
INTERNAL:
Field Summary | |
---|---|
protected AttributeMap | attributes Attributes. |
protected String | name Element name. |
Constructor Summary | |
---|---|
ElementImpl(CoreDocumentImpl ownerDoc, String name) Factory constructor. | |
protected | ElementImpl() |
Method Summary | |
---|---|
Node | cloneNode(boolean deep)
Return a duplicate copy of this Element. |
String | getAttribute(String name)
Look up a single Attribute by name. |
Attr | getAttributeNode(String name)
Look up a single Attribute by name. |
Attr | getAttributeNodeNS(String namespaceURI, String localName)
Retrieves an Attr node by local name and namespace URI.
|
String | getAttributeNS(String namespaceURI, String localName)
Introduced in DOM Level 2. |
NamedNodeMap | getAttributes()
Retrieve all the Attributes as a set. |
String | getBaseURI()
DOM Level 3 WD - Experimental.
|
protected NamedNodeMapImpl | getDefaultAttributes() Get the default attributes. |
NodeList | getElementsByTagName(String tagname)
Returns a NodeList of all descendent nodes (children,
grandchildren, and so on) which are Elements and which have the
specified tag name.
|
NodeList | getElementsByTagNameNS(String namespaceURI, String localName)
Introduced in DOM Level 2. |
String | getNodeName()
Returns the element name |
short | getNodeType()
A short integer indicating what type of node this is. |
TypeInfo | getSchemaTypeInfo()
Method getSchemaTypeInfo. |
String | getTagName()
Returns the name of the Element. |
String | getTypeName() |
String | getTypeNamespace() |
protected int | getXercesAttribute(String namespaceURI, String localName)
NON-DOM: get inded of an attribute |
boolean | hasAttribute(String name)
Introduced in DOM Level 2. |
boolean | hasAttributeNS(String namespaceURI, String localName)
Introduced in DOM Level 2. |
boolean | hasAttributes()
Introduced in DOM Level 2. |
boolean | isDerivedFrom(String typeNamespaceArg, String typeNameArg, int derivationMethod)
Introduced in DOM Level 3. |
boolean | isEqualNode(Node arg)
DOM Level 3 WD- Experimental.
|
void | normalize()
In "normal form" (as read from a source file), there will never be two
Text children in succession. |
protected void | reconcileDefaultAttributes() Reconcile default attributes. |
void | removeAttribute(String name)
Remove the named attribute from this Element. |
Attr | removeAttributeNode(Attr oldAttr)
Remove the specified attribute/value pair. |
void | removeAttributeNS(String namespaceURI, String localName)
Introduced in DOM Level 2. |
void | setAttribute(String name, String value)
Add a new name/value pair, or replace the value of the existing
attribute having that name.
|
Attr | setAttributeNode(Attr newAttr)
Add a new attribute/value pair, or replace the value of the
existing attribute with that name.
|
Attr | setAttributeNodeNS(Attr newAttr)
Introduced in DOM Level 2. |
void | setAttributeNS(String namespaceURI, String qualifiedName, String value)
Introduced in DOM Level 2. |
void | setIdAttribute(String name, boolean makeId)
DOM Level 3: register the given attribute node as an ID attribute |
void | setIdAttributeNode(Attr at, boolean makeId)
DOM Level 3: register the given attribute node as an ID attribute |
void | setIdAttributeNS(String namespaceURI, String localName, boolean makeId)
DOM Level 3: register the given attribute node as an ID attribute |
void | setReadOnly(boolean readOnly, boolean deep)
NON-DOM: Subclassed to flip the attributes' readonly switch as well. |
protected void | setupDefaultAttributes() Setup the default attributes. |
protected int | setXercesAttributeNode(Attr attr)
NON-DOM: sets attribute node for this element |
protected void | synchronizeData() Synchronizes the data (name and value) for fast nodes. |
See Also: org.w3c.dom.Node#cloneNode(boolean)
Note: Attributes may contain complex node trees. This method returns the "flattened" string obtained from Attribute.getValue(). If you need the structure information, see getAttributeNode().
If no matching attribute is available, returns null.
Parameters: namespaceURI The namespace URI of the attribute to retrieve. localName The local name of the attribute to retrieve.
Returns: Attr The Attr node with the specified attribute local name and namespace URI or null if there is no such attribute.
Since: WD-DOM-Level-2-19990923
Retrieves an attribute value by local name and namespace URI.
Parameters: namespaceURI The namespace URI of the attribute to retrieve. localName The local name of the attribute to retrieve.
Returns: String The Attr value as a string, or empty string if that attribute does not have a specified or default value.
Since: WD-DOM-Level-2-19990923
Note: NodeList is a "live" view of the DOM. Its contents will change as the DOM changes, and alterations made to the NodeList will be reflected in the DOM.
Parameters: tagname The type of element to gather. To obtain a list of all elements no matter what their names, use the wild-card tag name "*".
See Also: DeepNodeListImpl
Returns a NodeList of all the Elements with a given local name and namespace URI in the order in which they would be encountered in a preorder traversal of the Document tree, starting from this node.
Parameters: namespaceURI The namespace URI of the elements to match on. The special value "*" matches all namespaces. When it is null or an empty string, this method behaves like getElementsByTagName. localName The local name of the elements to match on. The special value "*" matches all local names.
Returns: NodeList A new NodeList object containing all the matched Elements.
Since: WD-DOM-Level-2-19990923
Returns: TypeInfo
This is case-preserving in XML. HTML should uppercasify it on the way in.
See Also: org.w3c.dom.TypeInfo#getTypeName()
See Also: org.w3c.dom.TypeInfo#getTypeNamespace()
Checks if a type is derived from another by restriction. See: http://www.w3.org/TR/DOM-Level-3-Core/core.html#TypeInfo-isDerivedFrom
Parameters: ancestorNS The namspace of the ancestor type declaration ancestorName The name of the ancestor type declaration type The reference type definition
Returns: boolean True if the type is derived by restriciton for the reference type
To normalize a Document, normalize its top-level Element child.
As of PR-DOM-Level-1-19980818, CDATA -- despite being a subclass of Text -- is considered "markup" and will _not_ be merged either with normal Text or with other CDATASections.
The default logic is actually implemented in NamedNodeMapImpl. PR-DOM-Level-1-19980818 doesn't fully address the DTD, so some of this behavior is likely to change in future versions. ?????
Note that this call "succeeds" even if no attribute by this name existed -- unlike removeAttributeNode, which will throw a not-found exception in that case.
Throws: DOMException(NO_MODIFICATION_ALLOWED_ERR) if the node is readonly.
NOTE: Specifically removes THIS NODE -- not the node with this name, nor the node with these contents. If the specific Attribute object passed in is not stored in this Element, we throw a DOMException. If you really want to remove an attribute by name, use removeAttribute().
Returns: the Attribute object that was removed.
Throws: DOMException(NOT_FOUND_ERR) if oldattr is not an attribute of this Element. DOMException(NO_MODIFICATION_ALLOWED_ERR) if the node is readonly.
Removes an attribute by local name and namespace URI. If the removed attribute has a default value it is immediately replaced. The replacing attribute has the same namespace URI and local name, as well as the original prefix.
Parameters: namespaceURI The namespace URI of the attribute to remove. localName The local name of the attribute to remove.
Throws: NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
Since: WD-DOM-Level-2-19990923
Throws: DOMException(INVALID_NAME_ERR) if the name is not acceptable. (Attribute factory will do that test for us.) DOMException(NO_MODIFICATION_ALLOWED_ERR) if the node is readonly.
This method allows you to add an Attribute that has already been constructed, and hence avoids the limitations of the simple setAttribute() call. It can handle attribute values that have arbitrarily complex tree structure -- in particular, those which had entity references mixed into their text.
Throws: DOMException(INUSE_ATTRIBUTE_ERR) if the Attribute object has already been assigned to another Element.
Adds a new attribute. If an attribute with that local name and namespace URI is already present in the element, it is replaced by the new one.
Parameters: Attr The Attr node to add to the attribute list. When the Node has no namespaceURI, this method behaves like setAttributeNode.
Returns: Attr If the newAttr attribute replaces an existing attribute with the same local name and namespace URI, the * previously existing Attr node is returned, otherwise null is returned.
Throws: WRONG_DOCUMENT_ERR: Raised if newAttr was created from a different document than the one that created the element. NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. INUSE_ATTRIBUTE_ERR: Raised if newAttr is already an attribute of another Element object. The DOM user must explicitly clone Attr nodes to re-use them in other elements.
Since: WD-DOM-Level-2-19990923
Adds a new attribute. If the given namespaceURI is null or an empty string and the qualifiedName has a prefix that is "xml", the new attribute is bound to the predefined namespace "http://www.w3.org/XML/1998/namespace" [Namespaces]. If an attribute with the same local name and namespace URI is already present on the element, its prefix is changed to be the prefix part of the qualifiedName, and its value is changed to be the value parameter. This value is a simple string, it is not parsed as it is being set. So any markup (such as syntax to be recognized as an entity reference) is treated as literal text, and needs to be appropriately escaped by the implementation when it is written out. In order to assign an attribute value that contains entity references, the user must create an Attr node plus any Text and EntityReference nodes, build the appropriate subtree, and use setAttributeNodeNS or setAttributeNode to assign it as the value of an attribute.
Parameters: namespaceURI The namespace URI of the attribute to create or alter. qualifiedName The qualified name of the attribute to create or alter. value The value to set in string form.
Throws: INVALID_CHARACTER_ERR: Raised if the specified name contains an invalid character. NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. NAMESPACE_ERR: Raised if the qualifiedName has a prefix that is "xml" and the namespaceURI is neither null nor an empty string nor "http://www.w3.org/XML/1998/namespace", or if the qualifiedName has a prefix that is "xmlns" but the namespaceURI is neither null nor an empty string, or if if the qualifiedName has a prefix different from "xml" and "xmlns" and the namespaceURI is null or an empty string.
Since: WD-DOM-Level-2-19990923
See Also: NodeImpl