net.sf.saxon.tree

Class ElementImpl

Implemented Interfaces:
FingerprintedNode, Item, NodeInfo, Source, PullEvent, SourceLocator, ValueRepresentation
Known Direct Subclasses:
ElementWithAttributes

public class ElementImpl
extends net.sf.saxon.tree.ParentNodeImpl

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

protected int
nameCode
protected DocumentImpl
root

Fields inherited from class net.sf.saxon.tree.ParentNodeImpl

sequence

Fields inherited from class net.sf.saxon.tree.NodeImpl

NODE_LETTER, index, 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

ElementImpl()
Construct an empty ElementImpl

Method Summary

void
copy(Receiver out, int whichNamespaces, boolean copyAnnotations, int locationId)
Copy this node to a given outputter (supporting xsl:copy-of)
void
generateId(FastStringBuffer buffer)
Get a character string that uniquely identifies this node
AttributeCollection
getAttributeList()
Get the attribute list for this element.
String
getBaseURI()
Get the base URI of this element node.
int[]
getDeclaredNamespaces(int[] buffer)
Get all namespace undeclarations and undeclarations defined on this element.
DocumentInfo
getDocumentRoot()
Get the root document node
int
getLineNumber()
Get the line number of the node within its source document entity
int
getNameCode()
Get the nameCode of the node.
int
getNodeKind()
Return the type of node.
NodeInfo
getRoot()
Get the root node
String
getSystemId()
Get the system ID of the entity containing this element node.
void
initialise(int nameCode, AttributeCollectionImpl atts, NodeInfo parent, String baseURI, int lineNumber, int sequenceNumber)
Initialise a new ElementImpl with an element name
void
setLineNumber(int line)
Set the line number of the element within its source document entity
void
setNameCode(int nameCode)
Set the name code.
void
setSystemId(String uri)
Set the system ID of this node.

Methods inherited from class net.sf.saxon.tree.ParentNodeImpl

addChild, compact, enumerateChildren, getFirstChild, getLastChild, getNthChild, getSequenceNumber, getStringValue, getStringValueCS, hasChildNodes, useChildrenArray

Methods inherited from class net.sf.saxon.tree.NodeImpl

atomize, compareOrder, equals, generateId, getAttributeValue, getBaseURI, getColumnNumber, getConfiguration, getDeclaredNamespaces, getDisplayName, getDocumentNumber, getDocumentRoot, getFingerprint, getFirstChild, getLastChild, getLineNumber, getLocalPart, getNameCode, getNamePool, getNextInDocument, getNextSibling, getParent, getPrefix, getPreviousInDocument, getPreviousSibling, getPublicId, getRoot, getSequenceNumber, getStringValueCS, getSystemId, getTypeAnnotation, getTypedValue, getURI, hasChildNodes, hashCode, isSameNodeInfo, iterateAxis, iterateAxis, setSystemId

Field Details

nameCode

protected int nameCode

root

protected DocumentImpl root

Constructor Details

ElementImpl

public ElementImpl()
Construct an empty ElementImpl

Method Details

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)
Specified by:
copy in interface NodeInfo
Parameters:
out - The outputter
whichNamespaces - indicates which namespaces should be output: all, none, or local namespaces only (those not declared on the parent element)

generateId

public void generateId(FastStringBuffer buffer)
Get a character string that uniquely identifies this node
Specified by:
generateId in interface NodeInfo
Overrides:
generateId in interface NodeImpl
Parameters:
buffer - to contain the generated ID

getAttributeList

public AttributeCollection 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

getBaseURI

public String 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:
getBaseURI in interface NodeInfo
Overrides:
getBaseURI in interface NodeImpl

getDeclaredNamespaces

public int[] getDeclaredNamespaces(int[] buffer)
Get all namespace undeclarations and undeclarations defined on this element.
Specified by:
getDeclaredNamespaces in interface NodeInfo
Overrides:
getDeclaredNamespaces in interface NodeImpl
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.


getDocumentRoot

public DocumentInfo getDocumentRoot()
Get the root document node
Specified by:
getDocumentRoot in interface NodeInfo
Overrides:
getDocumentRoot in interface NodeImpl

getLineNumber

public int getLineNumber()
Get the line number of the node within its source document entity
Specified by:
getLineNumber in interface NodeInfo
Overrides:
getLineNumber in interface NodeImpl

getNameCode

public int getNameCode()
Get the nameCode of the node. This is used to locate the name in the NamePool
Specified by:
getNameCode in interface NodeInfo
Overrides:
getNameCode in interface NodeImpl

getNodeKind

public final int getNodeKind()
Return the type of node.
Specified by:
getNodeKind in interface NodeInfo
Returns:
Type.ELEMENT

getRoot

public NodeInfo getRoot()
Get the root node
Specified by:
getRoot in interface NodeInfo
Overrides:
getRoot in interface NodeImpl

getSystemId

public final String getSystemId()
Get the system ID of the entity containing this element node.
Specified by:
getSystemId in interface NodeInfo
Overrides:
getSystemId in interface NodeImpl

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 resolved
atts - The attribute list: always null
parent - The parent node
baseURI - The base URI of the new element
lineNumber - The line number of the element in the source document
sequenceNumber - Integer identifying this element within the document

setLineNumber

public void setLineNumber(int line)
Set the line number of the element within its source document entity
Parameters:
line - the line number

setNameCode

public void setNameCode(int nameCode)
Set the name code. Used when creating a dummy element in the Stripper
Parameters:
nameCode - the integer name code representing the element name

setSystemId

public void setSystemId(String uri)
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
Overrides:
setSystemId in interface NodeImpl