Class ElementImpl
java.lang.Object
com.icl.saxon.om.AbstractNode
com.icl.saxon.tree.NodeImpl
com.icl.saxon.tree.ParentNodeImpl
com.icl.saxon.tree.ElementImpl
- All Implemented Interfaces:
NodeInfo, DOMLocator, Source, SourceLocator, Element, Node
- 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
emptyArray, index, parentFields inherited from class AbstractNode
NODE_LETTERFields inherited from interface Node
ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_POSITION_CONTAINED_BY, DOCUMENT_POSITION_CONTAINS, DOCUMENT_POSITION_DISCONNECTED, DOCUMENT_POSITION_FOLLOWING, DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, DOCUMENT_POSITION_PRECEDING, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddNamespaceNodes(ElementImpl owner, Vector list, boolean addXML) Make the set of all namespace nodes associated with this element.voidCopy this node to a given outputter (supporting xsl:copy-of)voidCopy this node to a given outputter (supporting xsl:copy-of)Get a character string that uniquely identifies this node within this document (The calling code will prepend a document identifier)Get the attribute list for this element.getAttributeValue(String name) Find the value of a given attribute of this element.Get the base URI of this element node.Get the root nodeintGet the line number of the node within its source document entityintGet the nameCode of the node.final shortReturn the type of node.getPrefixForURI(String uri) Search the NamespaceList for a given URI, returning the corresponding prefix.final StringGet the system ID of the entity containing this element node.shortgetURICodeForPrefix(String prefix) Search the NamespaceList for a given prefix, returning the corresponding URI.voidinitialise(int nameCode, AttributeCollection atts, NodeInfo parent, String baseURI, int lineNumber, int sequenceNumber) Initialise a new ElementImpl with an element namefinal intmakeNameCode(String qname, boolean useDefault) Make a NameCode, using this Element as the context for namespace resolution.voidoutputNamespaceNodes(Outputter out, boolean includeAncestors) Output all namespace nodes associated with this element.voidsetAttribute(String name, String value) Set the value of an attribute on the current 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, copyStringValue, dropChildren, enumerateChildren, getChildNodes, getFirstChild, getLastChild, getNodeValue, getNthChild, getSequenceNumber, getStringValue, hasChildNodes, removeChild, renumberChildren, useChildrenArrayMethods inherited from class NodeImpl
compareOrder, getAttributes, getAttributeValue, getAttributeValue, getDisplayName, getDocumentElement, getEnumeration, getFingerprint, getLocalName, getNamePool, getNextInDocument, getNextSibling, getOriginatingNode, getParent, getPrefix, getPreviousInDocument, getPreviousSibling, getURI, hasAttributes, isSameNodeInfo, removeNodeMethods inherited from class AbstractNode
appendChild, appendData, cloneNode, compareDocumentPosition, createAttribute, createAttributeNS, createCDATASection, createComment, createDocumentFragment, createElement, createElementNS, createEntityReference, createProcessingInstruction, createTextNode, deleteData, disallowUpdate, getAttribute, getAttributeNode, getAttributeNodeNS, getAttributeNS, getColumnNumber, getData, getDoctype, getElementById, getElementsByTagName, getElementsByTagNameNS, getFeature, getImplementation, getLength, getName, getNamespaceURI, getNodeName, getOwnerDocument, getOwnerElement, getParentNode, getPublicId, getSchemaTypeInfo, getSpecified, getTagName, getTextContent, getUserData, getValue, getWholeText, hasAttribute, hasAttributeNS, importNode, insertBefore, insertData, isDefaultNamespace, isElementContentWhitespace, isEqualNode, isId, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, normalize, removeAttribute, removeAttributeNode, removeAttributeNS, removeChild, replaceChild, replaceData, replaceWholeText, setAttributeNode, setAttributeNodeNS, setAttributeNS, setData, setIdAttribute, setIdAttributeNode, setIdAttributeNS, setNodeValue, setPrefix, setTextContent, setUserData, setValue, splitText, substringData, supportsMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Element
getAttribute, getAttributeNode, getAttributeNodeNS, getAttributeNS, getElementsByTagName, getElementsByTagNameNS, getSchemaTypeInfo, getTagName, hasAttribute, hasAttributeNS, removeAttribute, removeAttributeNode, removeAttributeNS, setAttributeNode, setAttributeNodeNS, setAttributeNS, setIdAttribute, setIdAttributeNode, setIdAttributeNSMethods inherited from interface Node
appendChild, cloneNode, compareDocumentPosition, getAttributes, getChildNodes, getFeature, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNodeName, getNodeValue, getOwnerDocument, getParentNode, getPrefix, getPreviousSibling, getTextContent, getUserData, hasAttributes, hasChildNodes, insertBefore, isDefaultNamespace, isEqualNode, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, normalize, removeChild, replaceChild, setNodeValue, setPrefix, setTextContent, setUserData
-
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, AttributeCollection atts, NodeInfo parent, String baseURI, int lineNumber, int sequenceNumber) Initialise a new ElementImpl with an element name- Parameters:
atts- The attribute list: always nullparent- The parent nodename- The element name, with namespaces resolved
-
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
-
getDocumentRoot
Get the root 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. Note this is not the same as the base URI: the base URI can be modified by xml:base, but the system ID cannot.
-
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 interfaceNode- Specified by:
getBaseURIin interfaceNodeInfo- Overrides:
getBaseURIin classNodeImpl
-
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- See Also:
-
generateId
Get a character string that uniquely identifies this node within this document (The calling code will prepend a document identifier)- Specified by:
generateIdin interfaceNodeInfo- Overrides:
generateIdin classNodeImpl- Returns:
- a string.
-
getURICodeForPrefix
Search the NamespaceList for a given prefix, returning the corresponding URI.- 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:
NamespaceException- if the prefix has not been declared on this NamespaceList.
-
getPrefixForURI
Search the NamespaceList for a given URI, returning the corresponding prefix.- 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.
-
makeNameCode
Make a NameCode, using this Element as the context for namespace resolution. The name will be entered in the namepool: therefore this method should not be called once the name pool is sealed.- Parameters:
qname- The name as written, in the form "[prefix:]localname"- Throws:
NamespaceException
-
addNamespaceNodes
Make the set of all namespace nodes associated with this element.- Parameters:
owner- The element owning these namespace nodes.list- a Vector containing NamespaceImpl objects representing the namespaces in scope for this element; the method appends nodes to this Vector, which should initially be empty. Note that the returned list will never contain the XML namespace (to get this, the NamespaceEnumeration class adds it itself). The list WILL include an entry for the undeclaration xmlns=""; again it is the job of NamespaceEnumeration to ignore this, since it doesn't represent a true namespace node.addXML- Add the XML namespace node to the list
-
outputNamespaceNodes
public void outputNamespaceNodes(Outputter out, boolean includeAncestors) throws TransformerException Output all namespace nodes associated with this element.- Specified by:
outputNamespaceNodesin interfaceNodeInfo- Overrides:
outputNamespaceNodesin classNodeImpl- Parameters:
out- The relevant outputterincludeAncestors- True if namespaces declared on ancestor elements must be output; false if it is known that these are already on the result tree- Throws:
TransformerException
-
getNodeType
public final short getNodeType()Return the type of node.- Specified by:
getNodeTypein interfaceNode- Specified by:
getNodeTypein interfaceNodeInfo- Returns:
- NodeInfo.ELEMENT
-
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
-
getAttributeValue
Find the value of a given attribute of this element.
This is a short-cut method; the full capability to examine attributes is offered via the getAttributeList() method.
The attribute may either be one that was present in the original XML document, or one that has been set by the application using setAttribute().- Parameters:
name- the name of an attribute. There must be no prefix in the name.- Returns:
- the value of the attribute, if it exists, otherwise null
-
setAttribute
Set the value of an attribute on the current element.- Specified by:
setAttributein interfaceElement- Throws:
DOMException- (always): the Saxon tree is immutable
-
copy
Copy this node to a given outputter (supporting xsl:copy-of)- Specified by:
copyin interfaceNodeInfo- Throws:
TransformerException
-
copy
Copy this node to a given outputter (supporting xsl:copy-of)- Parameters:
out- The outputterallNamespaces- true if namespaces for ancestor nodes must be output- Throws:
TransformerException
-