net.sf.saxon.tree

Class ElementImpl

public class ElementImpl extends 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 intnameCode
protected DocumentImplroot
Constructor Summary
ElementImpl()
Construct an empty ElementImpl
Method Summary
voidcopy(Receiver out, int whichNamespaces, boolean copyAnnotations, int locationId)
Copy this node to a given outputter (supporting xsl:copy-of)
voidgenerateId(FastStringBuffer buffer)
Get a character string that uniquely identifies this node
AttributeCollectiongetAttributeList()
Get the attribute list for this element.
StringgetBaseURI()
Get the base URI of this element node.
int[]getDeclaredNamespaces(int[] buffer)
Get all namespace undeclarations and undeclarations defined on this element.
DocumentInfogetDocumentRoot()
Get the root document node
intgetLineNumber()
Get the line number of the node within its source document entity
intgetNameCode()
Get the nameCode of the node.
intgetNodeKind()
Return the type of node.
NodeInfogetRoot()
Get the root node
StringgetSystemId()
Get 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 name
voidsendNamespaceDeclarations(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 entity
voidsetNameCode(int nameCode)
Set the name code.
voidsetSystemId(String uri)
Set the system ID of this node.

Field Detail

nameCode

protected int nameCode

root

protected DocumentImpl root

Constructor Detail

ElementImpl

public ElementImpl()
Construct an empty ElementImpl

Method Detail

copy

public void copy(Receiver out, int whichNamespaces, boolean copyAnnotations, int locationId)
Copy this node to a given outputter (supporting xsl:copy-of)

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

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.

getDeclaredNamespaces

public int[] getDeclaredNamespaces(int[] buffer)
Get all namespace undeclarations and undeclarations defined on this element.

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

getLineNumber

public int getLineNumber()
Get the line number of the node within its source document entity

getNameCode

public int getNameCode()
Get the nameCode of the node. This is used to locate the name in the NamePool

getNodeKind

public final int getNodeKind()
Return the type of node.

Returns: Type.ELEMENT

getRoot

public NodeInfo getRoot()
Get the root node

getSystemId

public final String getSystemId()
Get the system ID of the entity containing this element node.

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

sendNamespaceDeclarations

public void sendNamespaceDeclarations(Receiver out, boolean includeAncestors)
Output all namespace nodes associated with this element.

Parameters: out The relevant outputter

setLineNumber

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

setNameCode

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

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