net.sf.saxon.tree
public class ElementImpl extends ParentNodeImpl implements NamespaceResolver
This class is an implementation of NodeInfo. For elements with attributes or namespace declarations, class ElementWithAttributes is used.
Field Summary | |
---|---|
protected AttributeCollection | attributeList |
protected int | nameCode |
protected int[] | namespaceList |
protected int | typeCode |
Constructor Summary | |
---|---|
ElementImpl()
Construct an empty ElementImpl |
Method Summary | |
---|---|
void | addAttribute(int nameCode, int typeCode, CharSequence value, int properties)
Add an attribute to this element node.
|
void | addNamespace(int nscode, boolean inherit)
Add a namespace binding (that is, a namespace node) to this element. |
void | copy(Receiver out, int whichNamespaces, boolean copyAnnotations, int locationId)
Copy this node to a given outputter (supporting xsl:copy-of) |
void | delete()
Delete this node (that is, detach it from its parent) |
protected void | fixupInsertedNamespaces(boolean inherit)
Ensure that a child element being inserted into a tree has the right namespace declarations.
|
void | generateId(FastStringBuffer buffer)
Get a character string that uniquely identifies this node |
AttributeCollection | getAttributeList()
Get the attribute list for this element. |
String | getAttributeValue(int fingerprint)
Get the value of a given attribute of this node |
String | getAttributeValue(String uri, String localName)
Get the value of a given attribute of this node |
String | getBaseURI()
Get the base URI of this element node. |
int | getColumnNumber()
Get the line number of the node within its source document entity |
int[] | getDeclaredNamespaces(int[] buffer)
Get all namespace undeclarations and undeclarations defined on this element.
|
DocumentInfo | getDocumentRoot()
Get the root node, if it is a document node.
|
int[] | getInScopeNamespaceCodes()
Get the list of in-scope namespaces for this element as an array of
namespace codes. |
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 kind of node. |
String | getPrefixForURI(String uri)
Search the NamespaceList for a given URI, returning the corresponding prefix. |
NodeInfo | getRoot()
Get the root node |
String | getSystemId()
Get the system ID of the entity containing this element node. |
int | getTypeAnnotation()
Get the type annotation of this node, if any |
short | getURICodeForPrefix(String prefix)
Search the NamespaceList for a given prefix, returning the corresponding URI. |
protected short | getURICodeForPrefixCode(int prefixCode)
Get the URI bound to a given prefix in the in-scope namespaces of this element |
String | getURIForPrefix(String prefix, boolean useDefault)
Get the namespace URI corresponding to a given prefix. |
void | initialise(int nameCode, int typeCode, AttributeCollectionImpl atts, NodeInfo parent, int sequenceNumber)
Initialise a new ElementImpl with an element name |
boolean | isId()
Determine whether this node has the is-id property |
boolean | isNilled()
Determine whether the node has the is-nilled property
|
Iterator | iteratePrefixes()
Get an iterator over all the prefixes declared in this namespace context. |
void | removeAttribute(NodeInfo attribute)
Remove an attribute from this element node
If this node is not an element, or if the specified node is not an attribute of this element, this method takes no action. The attribute object itself becomes unusable; any attempt to use this attribute object, or any other object representing the same node, is likely to result in an exception. |
void | removeTypeAnnotation()
Remove type information from this node (and its ancestors, recursively).
|
void | rename(int newNameCode)
Rename this node
|
void | replaceStringValue(CharSequence stringValue)
Replace the string-value of this node
|
void | setLineAndColumn(int line, int column)
Set the line number of the element within its source document entity |
void | setLocation(String systemId, int line, int column)
Set location information for this node |
void | setNameCode(int nameCode)
Set the name code. |
void | setNamespaceDeclarations(int[] namespaces, int namespacesUsed)
Set the namespace declarations for the element |
void | setSystemId(String uri)
Set the system ID of this node. |
void | setTypeAnnotation(int typeCode)
Set the type annotation on a node. |
If this node is not an element, or if the supplied node is not an attribute, the method takes no action. If the element already has an attribute with this name, the method throws an exception.
This method does not perform any namespace fixup. It is the caller's responsibility to ensure that any namespace prefix used in the name of the attribute (or in its value if it has a namespace-sensitive type) is declared on this element.
Parameters: nameCode the name of the new attribute typeCode the type annotation of the new attribute value the string value of the new attribute properties properties including IS_ID and IS_IDREF properties
Throws: IllegalStateException if the element already has an attribute with the given name.
Parameters: nscode The namespace code representing the (prefix, uri) pair of the namespace binding to be added. If the target element already has a namespace binding with this (prefix, uri) pair, the call has no effect. If the target element currently has a namespace binding with this prefix and a different URI, an exception is raised. inherit If true, the new namespace binding will be inherited by any children of the target element that do not already have a namespace binding for the specified prefix, recursively. If false, the new namespace binding will not be inherited.
Throws: IllegalArgumentException if the target element already has a namespace binding for this prefix, or if the namespace code represents a namespace undeclaration
Parameters: out The outputter whichNamespaces indicates which namespaces should be output: all, none, or local namespaces only (those not declared on the parent element)
Parameters: inherit true if the child is to inherit the inscope namespaces of its new parent
Parameters: buffer to contain the generated ID
Returns: The attribute list. This will not include any namespace attributes. The attribute names will be in expanded form, with prefixes replaced by URIs
Parameters: fingerprint The fingerprint of the attribute name
Returns: the attribute value if it exists or null if not
Parameters: uri the namespace URI of the attribute name, or "" if the attribute is not in a namepsace localName the local part of the attribute name
Returns: the attribute value if it exists or null if not
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.
Returns: the DocumentInfo representing the containing document. If this node is part of a tree that does not have a document node as its root, returns null.
Since: 8.4
Returns: the list of namespaces
Returns: Type.ELEMENT
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.
Returns: the type annotation, as the integer name code of the type name
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: net.sf.saxon.om.NamespaceException if the prefix has not been declared on this NamespaceList.
Parameters: prefixCode the prefix code as a 16-bit integer
Returns: the uri code as a 16-bit integer, or -1 if there is no in-scope binding for this prefix
Parameters: prefix the namespace prefix. May be the zero-length string, indicating that there is no prefix. This indicates either the default namespace or the null namespace, depending on the value of useDefault. useDefault true if the default namespace is to be used when the prefix is "". If false, the method returns "" when the prefix is "".
Returns: the uri for the namespace, or null if the prefix is not in scope. The "null namespace" is represented by the pseudo-URI "".
Parameters: nameCode Integer representing the element name, with namespaces resolved typeCode Integer representing the schema type of the element node atts The attribute list: always null parent The parent node sequenceNumber Integer identifying this element within the document
Returns: true if the node is an ID
Returns: true if the node has the is-nilled property
If this node is not an element, or if the specified node is not an attribute of this element, this method takes no action.
The attribute object itself becomes unusable; any attempt to use this attribute object, or any other object representing the same node, is likely to result in an exception.
Parameters: attribute the attribute node to be removed
Parameters: newNameCode the NamePool code of the new name
Parameters: stringValue the new string value
Parameters: line the line number column the column number
Parameters: systemId the base URI line the line number if known column the column number if known
Parameters: nameCode the integer name code representing the element name
Parameters: namespaces the list of namespace codes namespacesUsed the number of entries in the list that are used
Parameters: typeCode the type annotation (possibly including high bits set to indicate the isID, isIDREF, and isNilled properties)