Class NamespaceImpl

All Implemented Interfaces:
NodeInfo, DOMLocator, Source, SourceLocator, 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:
Michael H. Kay
  • Constructor Details

    • 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 Details

    • 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
      See Also:
    • getNamespaceCode

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

      public boolean isSameNodeInfo(NodeInfo other)
      Determine whether this is the same node as another node
      Specified by:
      isSameNodeInfo in interface NodeInfo
      Overrides:
      isSameNodeInfo in class NodeImpl
      Returns:
      true if this Node object and the supplied Node object represent the same node in the tree.
    • getLocalName

      public String getLocalName()
      Get the prefix of the namespace that this node relates to
      Specified by:
      getLocalName in interface Node
      Specified by:
      getLocalName in interface NodeInfo
      Overrides:
      getLocalName in class NodeImpl
      Returns:
      The local name of this node. For a node with no name, return an empty string.
    • setNamespaceCode

      public void setNamespaceCode(int nsCode)
      Change the uri of the namespace that this node relates to (used to implement xsl:namespace-alias)
    • getNodeType

      public final short getNodeType()
      Return the type of node.
      Returns:
      NodeInfo.NAMESPACE
    • getStringValue

      public String getStringValue()
      Return the string value of the node.
      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
      Parameters:
      anchor - : the scan stops when it reaches a node that is not a descendant of the specified anchor node
      Returns:
      the next node in the document, or null if there is no such 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(Outputter out) throws TransformerException
      Copy this node to a given outputter
      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