This class is an implementation of the DOM Element class that wraps a Saxon NodeInfo
representation of an element node.
The class provides read-only access to the tree; methods that request updates all fail
with an UnsupportedOperationException.
Note that contrary to the DOM specification, this implementation does not expose namespace
declarations as attributes.
getAttribute
public String getAttribute(String name)
Retrieves an attribute value by name.
This implementation does not expose namespace nodes as attributes.
name - The QName of the attribute to retrieve.
- The
Attr value as a string, or the empty string if
that attribute does not have a specified or default value.
getAttributeNS
public String getAttributeNS(String namespaceURI,
String localName) Retrieves an attribute value by local name and namespace URI.
This implementation does not expose namespace nodes as attributes.
namespaceURI - The namespace URI of the attribute to retrieve.localName - The local name of the attribute to retrieve.
- The
Attr value as a string, or the empty string if
that attribute does not have a specified or default value.
getAttributeNode
public Attr getAttributeNode(String name)
Retrieves an attribute node by name.
This implementation does not expose namespace nodes as attributes.
To retrieve an attribute node by qualified name and namespace URI,
use the getAttributeNodeNS method.
name - The name (nodeName ) of the attribute to
retrieve.
- The
Attr node with the specified name (
nodeName ) or null if there is no such
attribute.
getAttributeNodeNS
public Attr getAttributeNodeNS(String namespaceURI,
String localName) Retrieves an Attr node by local name and namespace URI.
This implementation does not expose namespace nodes as attributes.
namespaceURI - The namespace URI of the attribute to retrieve.localName - The local name of the attribute to retrieve.
- The
Attr node with the specified attribute local
name and namespace URI or null if there is no such
attribute.
getElementsByTagName
public NodeList getElementsByTagName(String name)
Returns a NodeList of all descendant Elements
with a given tag name, in document order.
name - The name of the tag to match on. The special value "*"
matches all tags.
- A list of matching
Element nodes.
getElementsByTagNameNS
public NodeList getElementsByTagNameNS(String namespaceURI,
String localName)
throws DOMException Returns a NodeList of all the descendant
Elements with a given local name and namespace URI in
document order.
namespaceURI - The namespace URI of the elements to match on. The
special value "*" matches all namespaces.localName - The local name of the elements to match on. The
special value "*" matches all local names.
- A new
NodeList object containing all the matched
Elements.
getSchemaTypeInfo
public TypeInfo getSchemaTypeInfo()
Get the schema type information for this node.
- the type information. Returns null for an untyped node.
getTagName
public String getTagName()
The name of the element (DOM interface).
hasAttribute
public boolean hasAttribute(String name)
Returns true when an attribute with a given name is
specified on this element or has a default value, false
otherwise.
This implementation does not expose namespace nodes as attributes.
name - The name of the attribute to look for.
true if an attribute with the given name is
specified on this element or has a default value, false
otherwise.
hasAttributeNS
public boolean hasAttributeNS(String namespaceURI,
String localName) Returns true when an attribute with a given local name
and namespace URI is specified on this element or has a default value,
false otherwise.
This implementation does not expose namespace nodes as attributes.
namespaceURI - The namespace URI of the attribute to look for.localName - The local name of the attribute to look for.
true if an attribute with the given local name and
namespace URI is specified or has a default value on this element,
false otherwise.
removeAttribute
public void removeAttribute(String oldAttr)
throws DOMException Removes the specified attribute. Always fails
removeAttributeNS
public void removeAttributeNS(String namespaceURI,
String localName)
throws DOMException Removes an attribute by local name and namespace URI. Always fails
removeAttributeNode
public Attr removeAttributeNode(Attr oldAttr)
throws DOMException Removes the specified attribute node. Always fails
setAttribute
public void setAttribute(String name,
String value)
throws DOMException Adds a new attribute. Always fails
name - The name of the attribute to create or alter.value - Value to set in string form.
setAttributeNS
public void setAttributeNS(String namespaceURI,
String qualifiedName,
String value)
throws DOMException Adds a new attribute. Always fails.
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.
setAttributeNode
public Attr setAttributeNode(Attr newAttr)
throws DOMException Adds a new attribute node. Always fails
setAttributeNodeNS
public Attr setAttributeNodeNS(Attr newAttr)
throws DOMException Add a new attribute. Always fails.
newAttr - The Attr node to add to the attribute list.
- If the
newAttr attribute replaces an existing
attribute with the same local name and namespace URI , the
replaced Attr node is returned, otherwise
null is returned.
setIdAttribute
public void setIdAttribute(String name,
boolean isId)
throws DOMException Mark an attribute as an ID. Always fails.
setIdAttributeNS
public void setIdAttributeNS(String namespaceURI,
String localName,
boolean isId)
throws DOMException Mark an attribute as an ID. Always fails.
setIdAttributeNode
public void setIdAttributeNode(Attr idAttr,
boolean isId)
throws DOMException Mark an attribute as an ID. Always fails.