Class ElementImpl
java.lang.Object
net.sf.saxon.tree.NodeImpl
net.sf.saxon.tree.ParentNodeImpl
net.sf.saxon.tree.ElementImpl
- All Implemented Interfaces:
Source, SourceLocator, FingerprintedNode, Item, NodeInfo, ValueRepresentation
- Direct Known Subclasses:
ElementWithAttributes
ElementImpl implements an element with no attributes or namespace declarations.
This class is an implementation of NodeInfo. For elements with attributes or namespace declarations, class ElementWithAttributes is used.
- Author:
- Michael H. Kay
-
Field Summary
FieldsFields inherited from class ParentNodeImpl
sequenceFields inherited from class NodeImpl
index, NODE_LETTER, parentFields inherited from interface NodeInfo
ALL_NAMESPACES, EMPTY_NAMESPACE_LIST, IS_DTD_TYPE, IS_NILLED, LOCAL_NAMESPACES, NO_NAMESPACESFields inherited from interface ValueRepresentation
EMPTY_VALUE_ARRAY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidCopy this node to a given outputter (supporting xsl:copy-of)voidgenerateId(FastStringBuffer buffer) Get a character string that uniquely identifies this nodeGet the attribute list for this element.Get the base URI of this element node.int[]getDeclaredNamespaces(int[] buffer) Get all namespace undeclarations and undeclarations defined on this element.Get the root document nodeintGet the line number of the node within its source document entityintGet the nameCode of the node.final intReturn the type of node.getRoot()Get the root nodefinal StringGet the system ID of the entity containing this element node.voidinitialise(int nameCode, AttributeCollectionImpl atts, NodeInfo parent, String baseURI, int lineNumber, int sequenceNumber) Initialise a new ElementImpl with an element namevoidsendNamespaceDeclarations(Receiver out, boolean includeAncestors) Output all namespace nodes associated with this element.voidsetLineNumber(int line) Set the line number of the element within its source document entityvoidsetNameCode(int nameCode) Set the name code.voidsetSystemId(String uri) Set the system ID of this node.Methods inherited from class ParentNodeImpl
addChild, compact, enumerateChildren, getFirstChild, getLastChild, getNthChild, getSequenceNumber, getStringValue, getStringValueCS, hasChildNodes, useChildrenArrayMethods inherited from class NodeImpl
atomize, compareOrder, equals, getAttributeValue, getColumnNumber, getConfiguration, getDisplayName, getDocumentNumber, getFingerprint, getLocalPart, getNamePool, getNextInDocument, getNextSibling, getParent, getPrefix, getPreviousInDocument, getPreviousSibling, getPublicId, getTypeAnnotation, getTypedValue, getURI, hashCode, isSameNodeInfo, iterateAxis, iterateAxis
-
Field Details
-
nameCode
protected int nameCode -
root
-
-
Constructor Details
-
ElementImpl
public ElementImpl()Construct an empty ElementImpl
-
-
Method Details
-
setNameCode
public void setNameCode(int nameCode) Set the name code. Used when creating a dummy element in the Stripper -
initialise
public void initialise(int nameCode, AttributeCollectionImpl atts, NodeInfo parent, String baseURI, int lineNumber, int sequenceNumber) Initialise a new ElementImpl with an element name- Parameters:
nameCode- Integer representing the element name, with namespaces resolvedatts- The attribute list: always nullparent- The parent nodebaseURI- The base URI of the new elementlineNumber- The line number of the element in the source documentsequenceNumber- Integer identifying this element within the document
-
setSystemId
Set the system ID of this node. This method is provided so that a NodeInfo implements the javax.xml.transform.Source interface, allowing a node to be used directly as the Source of a transformation- Specified by:
setSystemIdin interfaceSource- Overrides:
setSystemIdin classNodeImpl
-
getRoot
-
getDocumentRoot
Get the root document node- Specified by:
getDocumentRootin interfaceNodeInfo- Overrides:
getDocumentRootin classNodeImpl- Returns:
- the DocumentInfo representing the containing document
-
getSystemId
Get the system ID of the entity containing this element node.- Specified by:
getSystemIdin interfaceNodeInfo- Specified by:
getSystemIdin interfaceSource- Specified by:
getSystemIdin interfaceSourceLocator- Overrides:
getSystemIdin classNodeImpl- Returns:
- the System Identifier of the entity in the source document containing the node, or null if not known or not applicable.
-
getBaseURI
Get the base URI of this element node. This will be the same as the System ID unless xml:base has been used.- Specified by:
getBaseURIin interfaceNodeInfo- Overrides:
getBaseURIin classNodeImpl- Returns:
- the base URI of the node. This may be null if the base URI is unknown.
-
setLineNumber
public void setLineNumber(int line) Set the line number of the element within its source document entity -
getLineNumber
public int getLineNumber()Get the line number of the node within its source document entity- Specified by:
getLineNumberin interfaceNodeInfo- Specified by:
getLineNumberin interfaceSourceLocator- Overrides:
getLineNumberin classNodeImpl- Returns:
- the line number of the node in its original source document; or -1 if not available
-
getNameCode
public int getNameCode()Get the nameCode of the node. This is used to locate the name in the NamePool- Specified by:
getNameCodein interfaceNodeInfo- Overrides:
getNameCodein 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:
-
generateId
Get a character string that uniquely identifies this node- Specified by:
generateIdin interfaceNodeInfo- Overrides:
generateIdin classNodeImpl- Parameters:
buffer- to contain the generated ID
-
sendNamespaceDeclarations
Output all namespace nodes associated with this element.- Specified by:
sendNamespaceDeclarationsin interfaceNodeInfo- Overrides:
sendNamespaceDeclarationsin classNodeImpl- Parameters:
out- The relevant outputterincludeAncestors- True if namespaces declared on ancestor elements must- Throws:
XPathException
-
getDeclaredNamespaces
public int[] getDeclaredNamespaces(int[] buffer) Get all namespace undeclarations and undeclarations defined on this element.- Specified by:
getDeclaredNamespacesin interfaceNodeInfo- Overrides:
getDeclaredNamespacesin classNodeImpl- Parameters:
buffer- If this is non-null, and the result array fits in this buffer, then the result may overwrite the contents of this array, to avoid the cost of allocating a new array on the heap.- Returns:
- An array of integers representing the namespace declarations and undeclarations present on
this element. For a node other than an element, return null. Otherwise, the returned array is a
sequence of namespace codes, whose meaning may be interpreted by reference to the name pool. The
top half word of each namespace code represents the prefix, the bottom half represents the URI.
If the bottom half is zero, then this is a namespace undeclaration rather than a declaration.
The XML namespace is never included in the list. If the supplied array is larger than required,
then the first unused entry will be set to -1.
For a node other than an element, the method returns null.
-
getNodeKind
public final int getNodeKind()Return the type of node.- Returns:
- Type.ELEMENT
- See Also:
-
getAttributeList
Get the attribute list for this element.- Returns:
- The attribute list. This will not include any namespace attributes. The attribute names will be in expanded form, with prefixes replaced by URIs
-
copy
public void copy(Receiver out, int whichNamespaces, boolean copyAnnotations, int locationId) throws XPathException Copy this node to a given outputter (supporting xsl:copy-of)- Parameters:
out- The outputterwhichNamespaces- indicates which namespaces should be output: all, none, or local namespaces only (those not declared on the parent element)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
-