Class ElementWithAttributes
java.lang.Object
com.icl.saxon.om.AbstractNode
com.icl.saxon.tree.NodeImpl
com.icl.saxon.tree.ParentNodeImpl
com.icl.saxon.tree.ElementImpl
com.icl.saxon.tree.ElementWithAttributes
- All Implemented Interfaces:
NodeInfo, DOMLocator, Source, SourceLocator, Element, NamedNodeMap, Node
- Direct Known Subclasses:
StyleElement
A node in the XML parse tree representing an XML element.
This class is an implementation of NodeInfo
- Version:
- 8 August 2000: separated from ElementImpl
- Author:
- Michael H. Kay
-
Field Summary
FieldsFields inherited from class ElementImpl
nameCode, rootFields inherited from class ParentNodeImpl
sequenceFields inherited from class NodeImpl
emptyArray, index, parentFields inherited from class AbstractNode
NODE_LETTERFields inherited from interface Node
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddNamespaceNodes(ElementImpl owner, Vector list, boolean addXML) Make the set of all namespace nodes associated with this element.voidCopy this node to a given outputter (supporting xsl:copy-of)getAttribute(String name) Retrieves an attribute value by name.Get the attribute list for this element.getAttributeNode(String name) Retrieves an attribute node by name.getAttributeNodeNS(String namespaceURI, String localName) Retrieves anAttrnode by local name and namespace URI.getAttributeNS(String namespaceURI, String localName) Retrieves an attribute value by local name and namespace URI.ANamedNodeMapcontaining the attributes of this element.getAttributeValue(int fingerprint) Get the value of a given attribute of this nodegetAttributeValue(String name) Find the value of a given attribute of this element.getAttributeValue(String uri, String localName) Find the value of a given attribute of this node.intGet number of attributes (DOM NamedNodeMap method).getNamedItem(String name) Get named attribute (DOM NamedNodeMap method) Treats namespace declarations as attributes.getNamedItemNS(String uri, String localName) Get named attribute (DOM NamedNodeMap method) Treats namespace declarations as attributes.protected int[]Get the list of in-scope namespaces for this element as an array of namespace codes.getPrefixForURI(String uri) Search the NamespaceList for a given URI, returning the corresponding prefix.shortgetURICodeForPrefix(String prefix) Search the NamespaceList for a given prefix, returning the corresponding URI.booleanhasAttribute(String name) Returnstruewhen an attribute with a given name is specified on this element or has a default value,falseotherwise.booleanhasAttributeNS(String namespaceURI, String localName) Returnstruewhen an attribute with a given local name and namespace URI is specified on this element or has a default value,falseotherwise.booleanReturns whether this node (if it is an element) has any attributes.voidinitialise(int nameCode, AttributeCollection atts, NodeInfo parent, String baseURI, int lineNumber, int sequenceNumber) Initialise a new ElementWithAttributes with an element name and attribute listitem(int index) Get n'th attribute (DOM NamedNodeMap method).voidoutputNamespaceNodes(Outputter out, boolean includeAncestors) Output all namespace nodes associated with this element.voidremoveAttribute(String name) Removes an attribute by name.removeAttributeNode(Attr oldAttr) Removes the specified attribute node.voidremoveAttributeNS(String namespaceURI, String localName) Removes an attribute by local name and namespace URI.removeNamedItem(String name) Remove named attribute (DOM NamedNodeMap method: always fails)removeNamedItemNS(String uri, String localName) Remove named attribute (DOM NamedNodeMap method: always fails)voidsetAttribute(String name, String value) Set the value of an attribute on the current element.setAttributeNode(Attr newAttr) Adds a new attribute node.setAttributeNodeNS(Attr newAttr) Add a new attribute.voidsetAttributeNS(String namespaceURI, String qualifiedName, String value) Adds a new attribute.setNamedItem(Node arg) Set named attribute (DOM NamedNodeMap method: always fails)setNamedItemNS(Node arg) Set named attribute (DOM NamedNodeMap method: always fails)voidsetNamespaceDeclarations(int[] namespaces, int namespacesUsed) Set the namespace declarations for the elementMethods inherited from class ElementImpl
copy, generateId, getBaseURI, getDocumentRoot, getLineNumber, getNameCode, getNodeType, getSystemId, makeNameCode, setLineNumber, setNameCode, setSystemIdMethods inherited from class ParentNodeImpl
addChild, compact, copyStringValue, dropChildren, enumerateChildren, getChildNodes, getFirstChild, getLastChild, getNodeValue, getNthChild, getSequenceNumber, getStringValue, hasChildNodes, removeChild, renumberChildren, useChildrenArrayMethods inherited from class NodeImpl
compareOrder, getDisplayName, getDocumentElement, getEnumeration, getFingerprint, getLocalName, getNamePool, getNextInDocument, getNextSibling, getOriginatingNode, getParent, getPrefix, getPreviousInDocument, getPreviousSibling, getURI, isSameNodeInfo, removeNodeMethods inherited from class AbstractNode
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, supportsMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Element
getElementsByTagName, getElementsByTagNameNS, getSchemaTypeInfo, getTagName, setIdAttribute, setIdAttributeNode, setIdAttributeNSMethods inherited from interface Node
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
-
Field Details
-
attributeList
-
namespaceList
protected int[] namespaceList
-
-
Constructor Details
-
ElementWithAttributes
public ElementWithAttributes()
-
-
Method Details
-
initialise
public 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- Overrides:
initialisein classElementImpl- Parameters:
atts- The attribute list, after namespace processingparent- The parent nodename- The element name, with namespaces resolved
-
setNamespaceDeclarations
public void setNamespaceDeclarations(int[] namespaces, int namespacesUsed) Set the namespace declarations for the element -
getURICodeForPrefix
Search the NamespaceList for a given prefix, returning the corresponding URI.- Overrides:
getURICodeForPrefixin classElementImpl- Parameters:
prefix- The prefix to be matched. To find the default namespace, supply ""- Returns:
- The URI code corresponding to this namespace. If it is an unnamed default namespace, return Namespace.NULL_CODE.
- Throws:
NamespaceException- if the prefix has not been declared on this NamespaceList.
-
getPrefixForURI
Search the NamespaceList for a given URI, returning the corresponding prefix.- Overrides:
getPrefixForURIin classElementImpl- Parameters:
uri- The URI to be matched.- Returns:
- The prefix corresponding to this URI. If not found, return null. If there is more than one prefix matching the URI, the first one found is returned. If the URI matches the default namespace, return an empty string.
-
addNamespaceNodes
Make the set of all namespace nodes associated with this element.- Overrides:
addNamespaceNodesin classElementImpl- Parameters:
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 namespace
-
outputNamespaceNodes
public void outputNamespaceNodes(Outputter out, boolean includeAncestors) throws TransformerException Output all namespace nodes associated with this element.- Specified by:
outputNamespaceNodesin interfaceNodeInfo- Overrides:
outputNamespaceNodesin classElementImpl- Parameters:
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 tree- Throws:
TransformerException
-
getNamespaceCodes
protected int[] getNamespaceCodes()Get the list of in-scope namespaces for this element as an array of namespace codes. (Used by LiteralResultElement) -
getAttributeList
Get the attribute list for this element.- Overrides:
getAttributeListin classElementImpl- Returns:
- The attribute list. This will not include any namespace attributes. The attribute names will be in expanded form, with prefixes replaced by URIs
-
hasAttributes
public boolean hasAttributes()Returns whether this node (if it is an element) has any attributes.- Specified by:
hasAttributesin interfaceNode- Overrides:
hasAttributesin classNodeImpl- Returns:
trueif this node has any attributes,falseotherwise.- Since:
- DOM Level 2
-
getAttributeValue
Find the value of a given attribute of this node.
This method is defined on all nodes to meet XSL requirements, but for nodes other than elements it will always return null.- Specified by:
getAttributeValuein interfaceNodeInfo- Overrides:
getAttributeValuein classNodeImpl- Parameters:
uri- the namespace uri of an attributelocalName- the local name of an attribute- Returns:
- the value of the attribute, if it exists, otherwise null
-
getAttributeValue
Find the value of a given attribute of this element.
This is a short-cut method; the full capability to examine attributes is offered via the getAttributeList() method.
The attribute may either be one that was present in the original XML document, or one that has been set by the application using setAttribute().- Overrides:
getAttributeValuein classElementImpl- Parameters:
name- the name of an attribute. There must be no prefix in the name.- Returns:
- the value of the attribute, if it exists, otherwise null
-
getAttributeValue
Get the value of a given attribute of this node- Specified by:
getAttributeValuein interfaceNodeInfo- Overrides:
getAttributeValuein classNodeImpl- Parameters:
fingerprint- The fingerprint of the attribute name- Returns:
- the attribute value if it exists or null if not
-
setAttribute
Set the value of an attribute on the current element. This affects subsequent calls of getAttribute() for that element.- Specified by:
setAttributein interfaceElement- Overrides:
setAttributein classElementImpl- Parameters:
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.- Throws:
DOMException- (always): Saxon trees are immutable.
-
copy
Copy this node to a given outputter (supporting xsl:copy-of)- Overrides:
copyin classElementImpl- Parameters:
out- The outputterallNamespaces- true if namespaces for ancestor nodes must be output- Throws:
TransformerException
-
getAttribute
Retrieves an attribute value by name. Namespace declarations are not returned.- Specified by:
getAttributein interfaceElement- Overrides:
getAttributein classAbstractNode- Parameters:
name- The name of the attribute to retrieve.- Returns:
- The
Attrvalue 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).
-
getAttributes
ANamedNodeMapcontaining the attributes of this element. This is a DOM method, so the list of attributes includes namespace declarations.- Specified by:
getAttributesin interfaceNode- Overrides:
getAttributesin classNodeImpl
-
removeAttribute
Removes an attribute by name.- Specified by:
removeAttributein interfaceElement- Overrides:
removeAttributein classAbstractNode- Parameters:
name- The name of the attribute to remove.
-
getAttributeNode
Retrieves an attribute node by name. Namespace declarations are not returned.
To retrieve an attribute node by qualified name and namespace URI, use thegetAttributeNodeNSmethod.- Specified by:
getAttributeNodein interfaceElement- Overrides:
getAttributeNodein classAbstractNode- Parameters:
name- The name (nodeName) of the attribute to retrieve.- Returns:
- The
Attrnode with the specified name (nodeName) ornullif there is no such attribute.
-
setAttributeNode
Adds a new attribute node. Always fails- Specified by:
setAttributeNodein interfaceElement- Overrides:
setAttributeNodein classAbstractNode- Throws:
DOMException- NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
-
removeAttributeNode
Removes the specified attribute node. Always fails- Specified by:
removeAttributeNodein interfaceElement- Overrides:
removeAttributeNodein classAbstractNode- Throws:
DOMException- NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
-
getAttributeNS
Retrieves an attribute value by local name and namespace URI. HTML-only DOM implementations do not need to implement this method.- Specified by:
getAttributeNSin interfaceElement- Overrides:
getAttributeNSin classAbstractNode- Parameters:
namespaceURI- The namespace URI of the attribute to retrieve.localName- The local name of the attribute to retrieve.- Returns:
- The
Attrvalue as a string, or the empty string if that attribute does not have a specified or default value. - Since:
- DOM Level 2
-
setAttributeNS
public void setAttributeNS(String namespaceURI, String qualifiedName, String value) throws DOMException Adds a new attribute. Always fails.- Specified by:
setAttributeNSin interfaceElement- Overrides:
setAttributeNSin classAbstractNode- 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:
DOMException- NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
-
removeAttributeNS
Removes an attribute by local name and namespace URI. Always fails- Specified by:
removeAttributeNSin interfaceElement- Overrides:
removeAttributeNSin classAbstractNode- Throws:
DOMException- NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.- Since:
- DOM Level 2
-
getAttributeNodeNS
Retrieves anAttrnode by local name and namespace URI. DOM method, so namespace declarations count as attributes.- Specified by:
getAttributeNodeNSin interfaceElement- Overrides:
getAttributeNodeNSin classAbstractNode- Parameters:
namespaceURI- The namespace URI of the attribute to retrieve.localName- The local name of the attribute to retrieve.- Returns:
- The
Attrnode with the specified attribute local name and namespace URI ornullif there is no such attribute. - Since:
- DOM Level 2
-
setAttributeNodeNS
Add a new attribute. Always fails.- Specified by:
setAttributeNodeNSin interfaceElement- Overrides:
setAttributeNodeNSin classAbstractNode- Parameters:
newAttr- TheAttrnode to add to the attribute list.- Returns:
- If the
newAttrattribute replaces an existing attribute with the same local name and namespace URI , the replacedAttrnode is returned, otherwisenullis returned. - Throws:
DOMException-
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.- Since:
- DOM Level 2
-
hasAttribute
Returnstruewhen an attribute with a given name is specified on this element or has a default value,falseotherwise. Namespace declarations are not included.- Specified by:
hasAttributein interfaceElement- Overrides:
hasAttributein classAbstractNode- Parameters:
name- The name of the attribute to look for.- Returns:
trueif an attribute with the given name is specified on this element or has a default value,falseotherwise.- Since:
- DOM Level 2
-
hasAttributeNS
Returnstruewhen an attribute with a given local name and namespace URI is specified on this element or has a default value,falseotherwise. This is a DOM method so namespace declarations are treated as attributes.- Specified by:
hasAttributeNSin interfaceElement- Overrides:
hasAttributeNSin classAbstractNode- Parameters:
namespaceURI- The namespace URI of the attribute to look for.localName- The local name of the attribute to look for.- Returns:
trueif an attribute with the given local name and namespace URI is specified or has a default value on this element,falseotherwise.- Since:
- DOM Level 2
-
getNamedItem
Get named attribute (DOM NamedNodeMap method) Treats namespace declarations as attributes.- Specified by:
getNamedItemin interfaceNamedNodeMap
-
setNamedItem
Set named attribute (DOM NamedNodeMap method: always fails)- Specified by:
setNamedItemin interfaceNamedNodeMap- Throws:
DOMException
-
removeNamedItem
Remove named attribute (DOM NamedNodeMap method: always fails)- Specified by:
removeNamedItemin interfaceNamedNodeMap- Throws:
DOMException
-
item
Get n'th attribute (DOM NamedNodeMap method). Namespace declarations are not returned.- Specified by:
itemin interfaceNamedNodeMap
-
getLength
public int getLength()Get number of attributes (DOM NamedNodeMap method). Treats namespace declarations as attributes.- Specified by:
getLengthin interfaceNamedNodeMap- Overrides:
getLengthin classAbstractNode
-
getNamedItemNS
Get named attribute (DOM NamedNodeMap method) Treats namespace declarations as attributes.- Specified by:
getNamedItemNSin interfaceNamedNodeMap
-
setNamedItemNS
Set named attribute (DOM NamedNodeMap method: always fails)- Specified by:
setNamedItemNSin interfaceNamedNodeMap- Throws:
DOMException
-
removeNamedItemNS
Remove named attribute (DOM NamedNodeMap method: always fails)- Specified by:
removeNamedItemNSin interfaceNamedNodeMap- Throws:
DOMException
-