public class ElementWithAttributes extends ElementImpl implements Element, NamedNodeMap
This class is an implementation of NodeInfo
Modifier and Type | Field and Description |
---|---|
protected AttributeCollection |
attributeList |
protected int[] |
namespaceList |
protected int |
sequence |
nameCode, root
emptyArray, index, parent
NODE_LETTER
ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_POSITION_CONTAINED_BY, DOCUMENT_POSITION_CONTAINS, DOCUMENT_POSITION_DISCONNECTED, DOCUMENT_POSITION_FOLLOWING, DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, DOCUMENT_POSITION_PRECEDING, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE
Constructor and Description |
---|
ElementWithAttributes() |
Modifier and Type | Method and Description |
---|---|
void |
addChild(NodeImpl node,
int index)
Add a child node to this node.
|
void |
addNamespaceNodes(ElementImpl owner,
Vector list,
boolean addXML)
Make the set of all namespace nodes associated with this element.
|
void |
compact(int size)
Compact the space used by this node
|
void |
copy(Outputter out,
boolean allNamespaces)
Copy this node to a given outputter (supporting xsl:copy-of)
|
void |
copyStringValue(Outputter out)
Copy the string-value of this node to a given outputter
|
void |
dropChildren()
Drop a branch of the tree.
|
AxisEnumeration |
enumerateChildren(NodeTest test)
Get an enumeration of the children of this node
|
String |
getAttribute(String name)
Retrieves an attribute value by name.
|
AttributeCollection |
getAttributeList()
Get the attribute list for this element.
|
Attr |
getAttributeNode(String name)
Retrieves an attribute node by name.
|
Attr |
getAttributeNodeNS(String namespaceURI,
String localName)
Retrieves an
Attr node by local name and namespace URI. |
String |
getAttributeNS(String namespaceURI,
String localName)
Retrieves an attribute value by local name and namespace URI.
|
NamedNodeMap |
getAttributes()
A
NamedNodeMap containing the attributes of this element. |
String |
getAttributeValue(int fingerprint)
Get the value of a given attribute of this node
|
String |
getAttributeValue(String name)
Find the value of a given attribute of this element.
|
String |
getAttributeValue(String uri,
String localName)
Find the value of a given attribute of this node.
|
NodeList |
getChildNodes()
Return a
NodeList that contains all children of this node. |
Node |
getFirstChild()
Get the first child node of the element
|
Node |
getLastChild()
Get the last child node of the element
|
int |
getLength()
Get number of attributes (DOM NamedNodeMap method).
|
Node |
getNamedItem(String name)
Get named attribute (DOM NamedNodeMap method)
Treats namespace declarations as attributes.
|
Node |
getNamedItemNS(String uri,
String localName)
Get named attribute (DOM NamedNodeMap method)
Treats namespace declarations as attributes.
|
protected int[] |
getNamespaceCodes()
Get the list of in-scope namespaces for this element as an array of
namespace codes.
|
String |
getNodeValue()
Get the node value as defined in the DOM.
|
protected NodeImpl |
getNthChild(int n)
Get the nth child node of the element (numbering from 0)
|
String |
getPrefixForURI(String uri)
Search the NamespaceList for a given URI, returning the corresponding prefix.
|
protected long |
getSequenceNumber()
Get the node sequence number (in document order).
|
String |
getStringValue()
Return the string-value of the node, that is, the concatenation
of the character content of all descendent elements and text nodes.
|
short |
getURICodeForPrefix(String prefix)
Search the NamespaceList for a given prefix, returning the corresponding URI.
|
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. |
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. |
boolean |
hasAttributes()
Returns whether this node (if it is an element) has any attributes.
|
boolean |
hasChildNodes()
Determine if the node has any children.
|
void |
initialise(int nameCode,
AttributeCollection atts,
NodeInfo parent,
String baseURI,
int lineNumber,
int sequenceNumber)
Initialise a new ElementWithAttributes with an element name and attribute list
|
Node |
item(int index)
Get n'th attribute (DOM NamedNodeMap method).
|
void |
outputNamespaceNodes(Outputter out,
boolean includeAncestors)
Output all namespace nodes associated with this element.
|
void |
removeAttribute(String name)
Removes an attribute by name.
|
Attr |
removeAttributeNode(Attr oldAttr)
Removes the specified attribute node.
|
void |
removeAttributeNS(String namespaceURI,
String localName)
Removes an attribute by local name and namespace URI.
|
void |
removeChild(int index)
Remove node at given index.
|
Node |
removeNamedItem(String name)
Remove named attribute (DOM NamedNodeMap method: always fails)
|
Node |
removeNamedItemNS(String uri,
String localName)
Remove named attribute (DOM NamedNodeMap method: always fails)
|
void |
renumberChildren()
Renumber the children of a given parent node.
|
void |
setAttribute(String name,
String value)
Set the value of an attribute on the current element.
|
Attr |
setAttributeNode(Attr newAttr)
Adds a new attribute node.
|
Attr |
setAttributeNodeNS(Attr newAttr)
Add a new attribute.
|
void |
setAttributeNS(String namespaceURI,
String qualifiedName,
String value)
Adds a new attribute.
|
Node |
setNamedItem(Node arg)
Set named attribute (DOM NamedNodeMap method: always fails)
|
Node |
setNamedItemNS(Node arg)
Set named attribute (DOM NamedNodeMap method: always fails)
|
void |
setNamespaceDeclarations(int[] namespaces,
int namespacesUsed)
Set the namespace declarations for the element
|
void |
useChildrenArray(NodeImpl[] array)
Supply an array to be used for the array of children.
|
copy, generateId, getBaseURI, getDocumentRoot, getLineNumber, getNameCode, getNodeType, getSystemId, makeNameCode, setLineNumber, setNameCode, setSystemId
compareOrder, getDisplayName, getDocumentElement, getEnumeration, getFingerprint, getLocalName, getNamePool, getNextInDocument, getNextSibling, getOriginatingNode, getParent, getPrefix, getPreviousInDocument, getPreviousSibling, getURI, isSameNodeInfo, removeNode
appendChild, appendData, cloneNode, compareDocumentPosition, createAttribute, createAttributeNS, createCDATASection, createComment, createDocumentFragment, createElement, createElementNS, createEntityReference, createProcessingInstruction, createTextNode, deleteData, disallowUpdate, getColumnNumber, getData, getDoctype, getElementById, getElementsByTagName, getElementsByTagNameNS, getFeature, getImplementation, getName, getNamespaceURI, getNodeName, getOwnerDocument, getOwnerElement, getParentNode, getPublicId, getSchemaTypeInfo, getSpecified, getTagName, getTextContent, getUserData, getValue, getWholeText, importNode, insertBefore, insertData, isDefaultNamespace, isElementContentWhitespace, isEqualNode, isId, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, normalize, removeChild, replaceChild, replaceData, replaceWholeText, setData, setIdAttribute, setIdAttributeNode, setIdAttributeNS, setNodeValue, setPrefix, setTextContent, setUserData, setValue, splitText, substringData, supports
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getElementsByTagName, getElementsByTagNameNS, getSchemaTypeInfo, getTagName, setIdAttribute, setIdAttributeNode, setIdAttributeNS
appendChild, cloneNode, compareDocumentPosition, getBaseURI, getChildNodes, getFeature, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNodeName, getNodeType, getNodeValue, getOwnerDocument, getParentNode, getPrefix, getPreviousSibling, getTextContent, getUserData, hasChildNodes, insertBefore, isDefaultNamespace, isEqualNode, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, normalize, removeChild, replaceChild, setNodeValue, setPrefix, setTextContent, setUserData
protected AttributeCollection attributeList
protected int[] namespaceList
protected int sequence
public void initialise(int nameCode, AttributeCollection atts, NodeInfo parent, String baseURI, int lineNumber, int sequenceNumber)
initialise
in class ElementImpl
name
- The element name, with namespaces resolvedatts
- The attribute list, after namespace processingparent
- The parent nodepublic void setNamespaceDeclarations(int[] namespaces, int namespacesUsed)
public short getURICodeForPrefix(String prefix) throws NamespaceException
getURICodeForPrefix
in class ElementImpl
prefix
- The prefix to be matched. To find the default namespace, supply ""NamespaceException
- if the prefix has not been declared on this NamespaceList.public String getPrefixForURI(String uri)
getPrefixForURI
in class ElementImpl
uri
- The URI to be matched.public void addNamespaceNodes(ElementImpl owner, Vector list, boolean addXML)
addNamespaceNodes
in class ElementImpl
owner
- The element owning these namespace nodes.list
- a Vector containing NamespaceImpl objects representing the namespaces
in scope for this element; the method appends nodes to this Vector, which should
initially be empty. Note that the returned list will never contain the XML namespace
(to get this, the NamespaceEnumeration class adds it itself). The list WILL include
an entry for the undeclaration xmlns=""; again it is the job of NamespaceEnumeration
to ignore this, since it doesn't represent a true namespace node.addXML
- Add a namespace node for the XML namespacepublic void outputNamespaceNodes(Outputter out, boolean includeAncestors) throws TransformerException
outputNamespaceNodes
in interface NodeInfo
outputNamespaceNodes
in class ElementImpl
out
- The relevant outputterincludeAncestors
- True if namespaces declared on ancestor elements must
be output; false if it is known that these are already on the result treeTransformerException
protected int[] getNamespaceCodes()
public AttributeCollection getAttributeList()
getAttributeList
in class ElementImpl
public boolean hasAttributes()
hasAttributes
in interface Node
hasAttributes
in class NodeImpl
true
if this node has any attributes,
false
otherwise.public String getAttributeValue(String uri, String localName)
getAttributeValue
in interface NodeInfo
getAttributeValue
in class NodeImpl
uri
- the namespace uri of an attributelocalName
- the local name of an attributepublic String getAttributeValue(String name)
getAttributeValue
in class ElementImpl
name
- the name of an attribute. There must be no prefix in the name.public String getAttributeValue(int fingerprint)
getAttributeValue
in interface NodeInfo
getAttributeValue
in class NodeImpl
fingerprint
- The fingerprint of the attribute namepublic void setAttribute(String name, String value) throws DOMException
setAttribute
in interface Element
setAttribute
in class ElementImpl
name
- The name of the attribute to be set. Any prefix is interpreted relative
to the namespaces defined for this element.value
- The new value of the attribute. Set this to null to remove the attribute.DOMException
- (always): Saxon trees are immutable.public void copy(Outputter out, boolean allNamespaces) throws TransformerException
copy
in class ElementImpl
out
- The outputterallNamespaces
- true if namespaces for ancestor nodes must be outputTransformerException
public String getAttribute(String name)
getAttribute
in interface Element
getAttribute
in class AbstractNode
name
- The name of the attribute to retrieve.Attr
value as a string, or the empty string if
that attribute does not have a specified or default value. (Note the
difference from getAttributeValue(), which returns null if there is no
value).public NamedNodeMap getAttributes()
NamedNodeMap
containing the attributes of this element. This
is a DOM method, so the list of attributes includes namespace declarations.getAttributes
in interface Node
getAttributes
in class NodeImpl
public void removeAttribute(String name)
removeAttribute
in interface Element
removeAttribute
in class AbstractNode
name
- The name of the attribute to remove.public Attr getAttributeNode(String name)
getAttributeNodeNS
method.getAttributeNode
in interface Element
getAttributeNode
in class AbstractNode
name
- The name (nodeName
) of the attribute to
retrieve.Attr
node with the specified name (
nodeName
) or null
if there is no such
attribute.public Attr setAttributeNode(Attr newAttr) throws DOMException
setAttributeNode
in interface Element
setAttributeNode
in class AbstractNode
DOMException
- NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.public Attr removeAttributeNode(Attr oldAttr) throws DOMException
removeAttributeNode
in interface Element
removeAttributeNode
in class AbstractNode
DOMException
- NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.public String getAttributeNS(String namespaceURI, String localName)
getAttributeNS
in interface Element
getAttributeNS
in class AbstractNode
namespaceURI
- The namespace URI of the attribute to retrieve.localName
- The local name of the attribute to retrieve.Attr
value as a string, or the empty string if
that attribute does not have a specified or default value.public void setAttributeNS(String namespaceURI, String qualifiedName, String value) throws DOMException
setAttributeNS
in interface Element
setAttributeNS
in class AbstractNode
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.DOMException
- NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.public void removeAttributeNS(String namespaceURI, String localName) throws DOMException
removeAttributeNS
in interface Element
removeAttributeNS
in class AbstractNode
DOMException
- NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.public Attr getAttributeNodeNS(String namespaceURI, String localName)
Attr
node by local name and namespace URI.
DOM method, so namespace declarations count as attributes.getAttributeNodeNS
in interface Element
getAttributeNodeNS
in class AbstractNode
namespaceURI
- The namespace URI of the attribute to retrieve.localName
- The local name of the attribute to retrieve.Attr
node with the specified attribute local
name and namespace URI or null
if there is no such
attribute.public Attr setAttributeNodeNS(Attr newAttr) throws DOMException
setAttributeNodeNS
in interface Element
setAttributeNodeNS
in class AbstractNode
newAttr
- The Attr
node to add to the attribute list.newAttr
attribute replaces an existing
attribute with the same local name and namespace URI , the
replaced Attr
node is returned, otherwise
null
is returned.DOMException
- public boolean hasAttribute(String name)
true
when an attribute with a given name is
specified on this element or has a default value, false
otherwise. Namespace declarations are not included.hasAttribute
in interface Element
hasAttribute
in class AbstractNode
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.public boolean hasAttributeNS(String namespaceURI, String localName)
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 is a DOM method so namespace declarations
are treated as attributes.hasAttributeNS
in interface Element
hasAttributeNS
in class AbstractNode
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.public Node getNamedItem(String name)
getNamedItem
in interface NamedNodeMap
public Node setNamedItem(Node arg) throws DOMException
setNamedItem
in interface NamedNodeMap
DOMException
public Node removeNamedItem(String name) throws DOMException
removeNamedItem
in interface NamedNodeMap
DOMException
public Node item(int index)
item
in interface NamedNodeMap
public int getLength()
getLength
in interface NamedNodeMap
getLength
in class AbstractNode
public Node getNamedItemNS(String uri, String localName)
getNamedItemNS
in interface NamedNodeMap
public Node setNamedItemNS(Node arg) throws DOMException
setNamedItemNS
in interface NamedNodeMap
DOMException
public Node removeNamedItemNS(String uri, String localName) throws DOMException
removeNamedItemNS
in interface NamedNodeMap
DOMException
protected final long getSequenceNumber()
getSequenceNumber
in class NodeImpl
public final boolean hasChildNodes()
hasChildNodes
in interface NodeInfo
hasChildNodes
in interface Node
hasChildNodes
in class NodeImpl
true
if the node has any children,
false
if the node has no children.public final AxisEnumeration enumerateChildren(NodeTest test)
public final Node getFirstChild()
getFirstChild
in interface Node
getFirstChild
in class NodeImpl
public final Node getLastChild()
getLastChild
in interface Node
getLastChild
in class NodeImpl
public final NodeList getChildNodes()
NodeList
that contains all children of this node. If
there are no children, this is a NodeList
containing no
nodes.getChildNodes
in interface Node
getChildNodes
in class NodeImpl
protected final NodeImpl getNthChild(int n)
public String getStringValue()
public void copyStringValue(Outputter out) throws TransformerException
copyStringValue
in interface NodeInfo
copyStringValue
in class AbstractNode
TransformerException
public void useChildrenArray(NodeImpl[] array)
public void addChild(NodeImpl node, int index)
public void removeChild(int index)
public void renumberChildren()
public void dropChildren()
public void compact(int size)
public String getNodeValue()
getNodeValue
in interface Node
getNodeValue
in class AbstractNode