Package net.sf.saxon.tree
Class AttributeImpl
java.lang.Object
net.sf.saxon.tree.NodeImpl
net.sf.saxon.tree.AttributeImpl
- All Implemented Interfaces:
Source
,SourceLocator
,ExtendedNodeInfo
,FingerprintedNode
,Item
,NodeInfo
,ValueRepresentation
A node in the XML parse tree representing an attribute. Note that this is
generated only "on demand", when the attribute is selected by a select pattern.
- Author:
- Michael H. Kay
-
Field Summary
Fields inherited from class net.sf.saxon.tree.NodeImpl
index, NODE_LETTER, parent
Fields inherited from interface net.sf.saxon.om.NodeInfo
ALL_NAMESPACES, EMPTY_NAMESPACE_LIST, IS_DTD_TYPE, IS_NILLED, LOCAL_NAMESPACES, NO_NAMESPACES
Fields inherited from interface net.sf.saxon.om.ValueRepresentation
EMPTY_VALUE_ARRAY
-
Constructor Summary
ConstructorsConstructorDescriptionAttributeImpl
(ElementImpl element, int index) Construct an Attribute node for the n'th attribute of a given element -
Method Summary
Modifier and TypeMethodDescriptionvoid
Copy this node to a given outputtervoid
generateId
(FastStringBuffer buffer) Get sequential key.int
Get the name code, which enables the name to be located in the name poolgetNextInDocument
(NodeImpl anchor) Get the next node in document order (skipping attributes)Get next sibling - not defined for attributesfinal int
Return the type of node.Get the previous node in document order (skipping attributes)Get previous sibling - not defined for attributesprotected long
Get the node sequence number (in document order).Return the character value of the node.int
Get the type annotation of this node, if anyint
hashCode()
The hashCode() method obeys the contract for hashCode(): that is, if two objects are equal (represent the same node) then they must have the same hashCode()boolean
isId()
Determine whether this node has the is-id propertyboolean
isIdref()
Determine whether this node has the is-idref propertyboolean
isNilled()
Determine whether the node has the is-nilled propertyboolean
isSameNodeInfo
(NodeInfo other) Determine whether this is the same node as another nodeMethods inherited from class net.sf.saxon.tree.NodeImpl
atomize, compareOrder, equals, getAttributeValue, getBaseURI, getColumnNumber, getConfiguration, getDeclaredNamespaces, getDisplayName, getDocumentNumber, getDocumentRoot, getFingerprint, getFirstChild, getLastChild, getLineNumber, getLocalPart, getNamePool, getParent, getPrefix, getPublicId, getRoot, getStringValueCS, getSystemId, getTypedValue, getURI, hasChildNodes, iterateAxis, iterateAxis, sendNamespaceDeclarations, setSystemId
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.sf.saxon.om.Item
getStringValueCS, getTypedValue
Methods inherited from interface net.sf.saxon.om.NodeInfo
atomize, compareOrder, equals, getAttributeValue, getBaseURI, getConfiguration, getDeclaredNamespaces, getDisplayName, getDocumentNumber, getDocumentRoot, getFingerprint, getLineNumber, getLocalPart, getNamePool, getParent, getPrefix, getRoot, getSystemId, getURI, hasChildNodes, iterateAxis, iterateAxis, sendNamespaceDeclarations
Methods inherited from interface javax.xml.transform.Source
isEmpty, setSystemId
-
Constructor Details
-
AttributeImpl
Construct an Attribute node for the n'th attribute of a given element- Parameters:
element
- The element containing the relevant attributeindex
- The index position of the attribute starting at zero
-
-
Method Details
-
getNameCode
public int getNameCode()Get the name code, which enables the name to be located in the name pool- Specified by:
getNameCode
in interfaceNodeInfo
- Overrides:
getNameCode
in classNodeImpl
- Returns:
- an integer name code, which may be used to obtain the actual node name from the name pool. For unnamed nodes (text nodes, comments, document nodes, and namespace nodes for the default namespace), returns -1.
- See Also:
-
getTypeAnnotation
public int getTypeAnnotation()Get the type annotation of this node, if any- Specified by:
getTypeAnnotation
in interfaceNodeInfo
- Overrides:
getTypeAnnotation
in classNodeImpl
- Returns:
- the type annotation of the node, under the mask NamePool.FP_MASK, and optionally the
bit setting IS_DTD_TYPE in the case of a DTD-derived ID or IDREF/S type (which is treated
as untypedAtomic for the purposes of obtaining the typed value).
The result is undefined for nodes other than elements and attributes.
-
isId
public boolean isId()Determine whether this node has the is-id property- Specified by:
isId
in interfaceExtendedNodeInfo
- Returns:
- true if the node is an ID
-
isIdref
public boolean isIdref()Determine whether this node has the is-idref property- Specified by:
isIdref
in interfaceExtendedNodeInfo
- Returns:
- true if the node is an IDREF or IDREFS element or attribute
-
isNilled
public boolean isNilled()Determine whether the node has the is-nilled property- Specified by:
isNilled
in interfaceExtendedNodeInfo
- Returns:
- true if the node has the is-nilled property
-
isSameNodeInfo
Determine whether this is the same node as another node- Specified by:
isSameNodeInfo
in interfaceNodeInfo
- Overrides:
isSameNodeInfo
in classNodeImpl
- Parameters:
other
- the node to be compared with this node- Returns:
- true if this Node object and the supplied Node object represent the same node in the tree.
-
hashCode
public int hashCode()The hashCode() method obeys the contract for hashCode(): that is, if two objects are equal (represent the same node) then they must have the same hashCode()- Specified by:
hashCode
in interfaceNodeInfo
- Overrides:
hashCode
in classNodeImpl
- Since:
- 8.7 Previously, the effect of the equals() and hashCode() methods was not defined. Callers should therefore be aware that third party implementations of the NodeInfo interface may not implement the correct semantics.
-
getSequenceNumber
protected long getSequenceNumber()Get the node sequence number (in document order). Sequence numbers are monotonic but not consecutive. In the current implementation, parent nodes (elements and roots) have a zero least-significant word, while namespaces, attributes, text nodes, comments, and PIs have the top word the same as their owner and the bottom half reflecting their relative position.- Overrides:
getSequenceNumber
in classNodeImpl
-
getNodeKind
public final int getNodeKind()Return the type of node.- Specified by:
getNodeKind
in interfaceNodeInfo
- Returns:
- Node.ATTRIBUTE
- See Also:
-
getStringValue
Return the character value of the node.- Specified by:
getStringValue
in interfaceItem
- Specified by:
getStringValue
in interfaceNodeInfo
- Specified by:
getStringValue
in interfaceValueRepresentation
- Returns:
- the attribute value
- See Also:
-
getNextSibling
Get next sibling - not defined for attributes- Overrides:
getNextSibling
in classNodeImpl
- Returns:
- The next sibling node of the required type. Returns null if the current node is the last child of its parent.
-
getPreviousSibling
Get previous sibling - not defined for attributes- Overrides:
getPreviousSibling
in classNodeImpl
- Returns:
- The previous sibling node. Returns null if the current node is the first child of its parent.
-
getPreviousInDocument
Get the previous node in document order (skipping attributes)- Overrides:
getPreviousInDocument
in classNodeImpl
- Returns:
- the previous node in the document, or null if there is no such node
-
getNextInDocument
Get the next node in document order (skipping attributes)- Overrides:
getNextInDocument
in classNodeImpl
- Parameters:
anchor
- the scan stops when it reaches a node that is not a descendant of the specified anchor node- Returns:
- the next node in the document, or null if there is no such node
-
generateId
Get sequential key. Returns key of owning element with the attribute index as a suffix- Specified by:
generateId
in interfaceNodeInfo
- Overrides:
generateId
in classNodeImpl
- Parameters:
buffer
-
-
copy
public void copy(Receiver out, int whichNamespaces, boolean copyAnnotations, int locationId) throws XPathException Copy this node to a given outputter- Specified by:
copy
in interfaceNodeInfo
- Parameters:
out
- the Receiver to which the node should be copiedwhichNamespaces
- in the case of an element, controls which namespace nodes should be copied. Values areNodeInfo.NO_NAMESPACES
,NodeInfo.LOCAL_NAMESPACES
,NodeInfo.ALL_NAMESPACES
copyAnnotations
- indicates whether the type annotations of element and attribute nodes should be copiedlocationId
- If non-zero, identifies the location of the instruction that requested this copy. If zero, indicates that the location information for the original node is to be copied; in this case the Receiver must be a LocationCopier- Throws:
XPathException
-