net.sf.saxon.tree
Class NamespaceImpl

java.lang.Object
  extended by net.sf.saxon.om.AbstractNode
      extended by net.sf.saxon.tree.NodeImpl
          extended by net.sf.saxon.tree.NamespaceImpl
All Implemented Interfaces:
DOMLocator, Source, SourceLocator, Item, NodeInfo, Node

final class NamespaceImpl
extends NodeImpl

A node in the XML parse tree representing a Namespace. Note that this is generated only "on demand", when the namespace axis is expanded.

Version:
3 November 1999
Author:
Field Summary
 
Fields inherited from class net.sf.saxon.tree.NodeImpl
parent
 
Fields inherited from class net.sf.saxon.om.AbstractNode
NODE_LETTER
 
Fields inherited from interface org.w3c.dom.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
 
Fields inherited from interface net.sf.saxon.om.NodeInfo
ALL_NAMESPACES, LOCAL_NAMESPACES, NO_NAMESPACES
 
Constructor Summary
NamespaceImpl(ElementImpl element, int nsCode, int index)
          Construct a Namespace node
 
Method Summary
 void copy(Receiver out, int whichNamespaces)
          Copy this node to a given outputter
 String generateId()
          Get sequential key.
 String getBaseURI()
          Get the base URI for the node.
 String getLocalPart()
          Get the prefix of the namespace that this node relates to.
 int getNameCode()
          Get the namecode for this name.
 int getNamespaceCode()
          Get the namespace code for this prefix/uri pair.
 NodeImpl getNextInDocument(NodeImpl anchor)
          Get the next node in document order (skipping namespace nodes)
 Node getNextSibling()
          Get next sibling - not defined for namespace nodes
 int getNodeKind()
          Return the type of node.
 String getNodeName()
          Get the name of this node, following the DOM rules (which aren't actually defined for Namespace nodes...)
 NodeImpl getPreviousInDocument()
          Get the previous node in document order (skipping namespace nodes)
 Node getPreviousSibling()
          Get previous sibling - not defined for namespace nodes
protected  long getSequenceNumber()
          Get the node sequence number (in document order).
 String getStringValue()
          Return the string value of the node.
 boolean isSameNode(NodeInfo other)
          Determine whether this is the same node as another node
 
Methods inherited from class net.sf.saxon.tree.NodeImpl
compareOrder, copy, getAttributeValue, getDisplayName, getDocumentElement, getDocumentRoot, getFingerprint, getFirstChild, getLastChild, getLineNumber, getNamePool, getOriginatingNode, getParent, getPrefix, getRoot, getSystemId, getURI, hasAttributes, hasChildNodes, iterateAxis, iterateAxis, outputNamespaceNodes, setSystemId
 
Methods inherited from class net.sf.saxon.om.AbstractNode
appendChild, appendData, cloneNode, createAttribute, createAttributeNS, createCDATASection, createComment, createDocumentFragment, createElement, createElementNS, createEntityReference, createProcessingInstruction, createTextNode, deleteData, disallowUpdate, getAttribute, getAttributeNode, getAttributeNodeNS, getAttributeNS, getAttributes, getChildNodes, getColumnNumber, getData, getDoctype, getDocumentNumber, getElementById, getElementsByTagName, getElementsByTagNameNS, getImplementation, getLength, getLocalName, getName, getNamespaceURI, getNodeType, getNodeValue, getOwnerDocument, getOwnerElement, getParentNode, getPublicId, getSpecified, getTagName, getTypeAnnotation, getTypedValue, getValue, hasAttribute, hasAttributeNS, importNode, insertBefore, insertData, isSupported, normalize, removeAttribute, removeAttributeNode, removeAttributeNS, removeChild, replaceChild, replaceData, setAttributeNode, setAttributeNodeNS, setAttributeNS, setData, setNodeValue, setPrefix, setValue, splitText, substringData, supports
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.w3c.dom.Node
compareDocumentPosition, getFeature, getTextContent, getUserData, isDefaultNamespace, isEqualNode, isSameNode, lookupNamespaceURI, lookupPrefix, setTextContent, setUserData
 

Constructor Detail

NamespaceImpl

public NamespaceImpl(ElementImpl element,
                     int nsCode,
                     int index)
Construct a Namespace node

Parameters:
element - The element owning the namespace node
nsCode - The namespace code
index - Integer identifying this namespace node among the nodes for its parent
Method Detail

getNameCode

public int getNameCode()
Get the namecode for this name. Not the same as the namespace code!

Specified by:
getNameCode in interface NodeInfo
Overrides:
getNameCode in class NodeImpl
Returns:
an integer name code, which may be used to obtain the actual node name from the name pool
See Also:
allocate, getFingerprint

getNamespaceCode

public int getNamespaceCode()
Get the namespace code for this prefix/uri pair. Not the same as the name code!


isSameNode

public boolean isSameNode(NodeInfo other)
Determine whether this is the same node as another node

Specified by:
isSameNode in interface NodeInfo
Overrides:
isSameNode in class NodeImpl
Parameters:
other - the node to be compared with this node
Returns:
true if this Node object and the supplied Node object represent the same node in the tree.

getLocalPart

public String getLocalPart()
Get the prefix of the namespace that this node relates to.

Specified by:
getLocalPart in interface NodeInfo
Overrides:
getLocalPart in class NodeImpl
Returns:
the namespace prefix, or "" for the default namespace

getNodeKind

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

Returns:
Type.NAMESPACE
See Also:
Type

getStringValue

public String getStringValue()
Return the string value of the node.

Specified by:
getStringValue in interface Item
Specified by:
getStringValue in interface NodeInfo
Specified by:
getStringValue in class AbstractNode
Returns:
the namespace uri

getNodeName

public String getNodeName()
Get the name of this node, following the DOM rules (which aren't actually defined for Namespace nodes...)

Specified by:
getNodeName in interface Node
Overrides:
getNodeName in class AbstractNode
Returns:
the namespace prefix

getNextSibling

public Node getNextSibling()
Get next sibling - not defined for namespace nodes

Specified by:
getNextSibling in interface Node
Overrides:
getNextSibling in class NodeImpl
Returns:
The next sibling node of the required type. Returns null if the current node is the last child of its parent.

getPreviousSibling

public Node getPreviousSibling()
Get previous sibling - not defined for namespace nodes

Specified by:
getPreviousSibling in interface Node
Overrides:
getPreviousSibling in class NodeImpl
Returns:
The previous sibling node. Returns null if the current node is the first child of its parent.

getPreviousInDocument

public NodeImpl getPreviousInDocument()
Get the previous node in document order (skipping namespace nodes)

Overrides:
getPreviousInDocument in class NodeImpl
Returns:
the previous node in the document, or null if there is no such node

getNextInDocument

public NodeImpl getNextInDocument(NodeImpl anchor)
Get the next node in document order (skipping namespace nodes)

Overrides:
getNextInDocument in class NodeImpl
Returns:
the next node in the document, or null if there is no such node

getBaseURI

public String getBaseURI()
Get the base URI for the node. In XPath 2.0, the base URI of a namespace node is (), which we represent as null.

Specified by:
getBaseURI in interface NodeInfo
Specified by:
getBaseURI in interface Node
Overrides:
getBaseURI in class NodeImpl
Returns:
the base URI of the node

generateId

public String generateId()
Get sequential key. Returns key of owning element with the namespace prefix as a suffix

Specified by:
generateId in interface NodeInfo
Overrides:
generateId in class NodeImpl
Returns:
a string.

copy

public void copy(Receiver out,
                 int whichNamespaces)
          throws TransformerException
Copy this node to a given outputter

Specified by:
copy in class NodeImpl
Throws:
TransformerException

getSequenceNumber

protected long getSequenceNumber()
Get the node sequence number (in document order). Sequence numbers are monotonic but not consecutive. In the current implementation, parent nodes (elements and roots) have a zero least-significant word, while namespaces, attributes, text nodes, comments, and PIs have the top word the same as their owner and the bottom half reflecting their relative position.

Overrides:
getSequenceNumber in class NodeImpl