Class SpaceStrippedNode

java.lang.Object
net.sf.saxon.tree.wrapper.AbstractVirtualNode
net.sf.saxon.tree.wrapper.SpaceStrippedNode
All Implemented Interfaces:
Source, SourceLocator, ActiveSource, GNode, GroundedValue, Item, NodeInfo, Sequence, Location, VirtualNode, WrappingFunction, Locator

public class SpaceStrippedNode extends AbstractVirtualNode implements WrappingFunction
A StrippedNode is a view of a node, in a virtual tree that has whitespace text nodes stripped from it. All operations on the node produce the same result as operations on the real underlying node, except that iterations over the axes take care to skip whitespace-only text nodes that are supposed to be stripped. Note that this class is only used in cases where a pre-built tree is supplied as the input to a transformation, and where the stylesheet does whitespace stripping; if a SAXSource or StreamSource is supplied, whitespace is stripped as the tree is built.
  • Constructor Details

    • SpaceStrippedNode

      protected SpaceStrippedNode()
    • SpaceStrippedNode

      protected SpaceStrippedNode(NodeInfo node, SpaceStrippedNode parent)
      This constructor is protected: nodes should be created using the makeWrapper factory method
      Parameters:
      node - The node to be wrapped
      parent - The StrippedNode that wraps the parent of this node
  • Method Details

    • makeWrapper

      protected static SpaceStrippedNode makeWrapper(NodeInfo node, SpaceStrippedDocument docWrapper, SpaceStrippedNode parent)
      Factory method to wrap a node with a wrapper that implements the Saxon NodeInfo interface.
      Parameters:
      node - The underlying node
      docWrapper - The wrapper for the document node (must be supplied)
      parent - The wrapper for the parent of the node (null if unknown)
      Returns:
      The new wrapper for the supplied node
    • makeWrapper

      public VirtualNode makeWrapper(NodeInfo node, VirtualNode parent)
      Factory method to wrap a node within the same document as this node with a VirtualNode
      Specified by:
      makeWrapper in interface WrappingFunction
      Parameters:
      node - The underlying node
      parent - The wrapper for the parent of the node (null if unknown)
      Returns:
      The new wrapper for the supplied node
    • isPreservedNode

      public static boolean isPreservedNode(NodeInfo node, SpaceStrippedDocument docWrapper, NodeInfo actualParent)
      Ask whether a node is preserved after whitespace stripping
      Parameters:
      node - the node in question
      docWrapper - the root of the space-stripped virtual tree
      actualParent - the (real) parent of the node in question
      Returns:
      true if the node survives whitespace-stripping
    • atomize

      public AtomicSequence atomize() throws XPathException
      Get the typed value.
      Specified by:
      atomize in interface Item
      Specified by:
      atomize in interface NodeInfo
      Overrides:
      atomize in class AbstractVirtualNode
      Returns:
      the typed value.
      Throws:
      XPathException - if the node has no typed value, for example if it is an element node with element-only content
      Since:
      8.5
    • equals

      public boolean equals(Object other)
      Determine whether this is the same node as another node.

      Note: a.isSameNode(b) if and only if generateId(a)==generateId(b)

      Specified by:
      equals in interface NodeInfo
      Overrides:
      equals in class AbstractVirtualNode
      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.
    • hashCode

      public int hashCode()
      The hashCode() method obeys the contract for hashCode(): that is, if two objects are equal (represent the same node) then they must have the same hashCode()
      Specified by:
      hashCode in interface NodeInfo
      Overrides:
      hashCode in class AbstractVirtualNode
    • compareOrder

      public int compareOrder(GNode other)
      Determine the relative position of this node and another node, in document order. The other node will always be in the same document.
      Specified by:
      compareOrder in interface GNode
      Specified by:
      compareOrder in interface NodeInfo
      Overrides:
      compareOrder in class AbstractVirtualNode
      Parameters:
      other - The other node, whose position is to be compared with this node
      Returns:
      -1 if this node precedes the other node, +1 if it follows the other node, or 0 if they are the same node. (In this case, isSameNode() will always return true, and the two nodes will produce the same result for generateId())
    • getUnicodeStringValue

      public UnicodeString getUnicodeStringValue()
      Get the string value of the item.
      Specified by:
      getUnicodeStringValue in interface GroundedValue
      Specified by:
      getUnicodeStringValue in interface Item
      Overrides:
      getUnicodeStringValue in class AbstractVirtualNode
      Returns:
      the string value of the node
    • getParent

      public NodeInfo getParent()
      Get the NodeInfo object representing the parent of this node
      Specified by:
      getParent in interface GNode
      Specified by:
      getParent in interface NodeInfo
      Returns:
      the parent of this node; null if this node has no parent
    • iterateAncestorAxis

      public SequenceIterator iterateAncestorAxis(NodePredicate predicate)
      Get an iterator over the ancestor axis, starting at this node; the nodes will be in reverse document order.
      Specified by:
      iterateAncestorAxis in interface GNode
      Parameters:
      predicate - a condition that the nodes must satisfy, or null
      Returns:
      the required iterator
    • iterateAncestorOrSelfAxis

      public SequenceIterator iterateAncestorOrSelfAxis(NodePredicate predicate)
      Get an iterator over the ancestor-or-self axis, starting at this node; the nodes will be in reverse document order.
      Specified by:
      iterateAncestorOrSelfAxis in interface GNode
      Parameters:
      predicate - a condition that the nodes must satisfy, or null
      Returns:
      the required iterator
    • iterateDescendantAxis

      public SequenceIterator iterateDescendantAxis(NodePredicate predicate)
      Get an iterator over the descendant axis, starting at this node; the nodes will be in document order.
      Specified by:
      iterateDescendantAxis in interface GNode
      Parameters:
      predicate - a condition that the nodes must satisfy, or null
      Returns:
      the required iterator
    • iterateDescendantOrSelfAxis

      public SequenceIterator iterateDescendantOrSelfAxis(NodePredicate predicate)
      Get an iterator over the descendant-or-self axis, starting at this node; the nodes will be in document order.
      Specified by:
      iterateDescendantOrSelfAxis in interface GNode
      Parameters:
      predicate - a condition that the nodes must satisfy, or null
      Returns:
      the required iterator
    • iterateFollowingAxis

      public SequenceIterator iterateFollowingAxis(NodePredicate predicate)
      Get an iterator over the following axis, starting at this node; the nodes will be in document order.
      Specified by:
      iterateFollowingAxis in interface GNode
      Parameters:
      predicate - a condition that the nodes must satisfy, or null
      Returns:
      the required iterator
    • iterateFollowingOrSelfAxis

      public SequenceIterator iterateFollowingOrSelfAxis(NodePredicate predicate)
      Get an iterator over the following-or-self axis, starting at this node; the nodes will be in document order.
      Specified by:
      iterateFollowingOrSelfAxis in interface GNode
      Parameters:
      predicate - a condition that the nodes must satisfy, or null
      Returns:
      the required iterator
    • iterateFollowingSiblingAxis

      public SequenceIterator iterateFollowingSiblingAxis(NodePredicate predicate)
      Get an iterator over the following-sibling axis, starting at this node; the nodes will be in document order.
      Specified by:
      iterateFollowingSiblingAxis in interface GNode
      Parameters:
      predicate - a condition that the nodes must satisfy, or null
      Returns:
      the required iterator
    • iterateFollowingSiblingOrSelfAxis

      public SequenceIterator iterateFollowingSiblingOrSelfAxis(NodePredicate predicate)
      Get an iterator over the following-sibling-or-self axis, starting at this node; the nodes will be in document order.
      Specified by:
      iterateFollowingSiblingOrSelfAxis in interface GNode
      Parameters:
      predicate - a condition that the nodes must satisfy, or null
      Returns:
      the required iterator
    • iterateParentAxis

      public SequenceIterator iterateParentAxis(NodePredicate predicate)
      Get an iterator over the parent axis, starting at this node; returns zero or one nodes
      Specified by:
      iterateParentAxis in interface GNode
      Parameters:
      predicate - a condition that the nodes must satisfy, or null
      Returns:
      the required iterator
    • iteratePrecedingAxis

      public SequenceIterator iteratePrecedingAxis(NodePredicate predicate)
      Get an iterator over the preceding axis, starting at this node; the nodes will be in reverse document order.
      Specified by:
      iteratePrecedingAxis in interface GNode
      Parameters:
      predicate - a condition that the nodes must satisfy, or null
      Returns:
      the required iterator
    • iteratePrecedingOrSelfAxis

      public SequenceIterator iteratePrecedingOrSelfAxis(NodePredicate predicate)
      Get an iterator over the preceding-or-self axis, starting at this node; the nodes will be in reverse document order.
      Specified by:
      iteratePrecedingOrSelfAxis in interface GNode
      Parameters:
      predicate - a condition that the nodes must satisfy, or null
      Returns:
      the required iterator
    • iteratePrecedingSiblingAxis

      public SequenceIterator iteratePrecedingSiblingAxis(NodePredicate predicate)
      Get an iterator over the preceding-sibling axis, starting at this node; the nodes will be in reverse document order.
      Specified by:
      iteratePrecedingSiblingAxis in interface GNode
      Parameters:
      predicate - a condition that the nodes must satisfy, or null
      Returns:
      the required iterator
    • iteratePrecedingSiblingOrSelfAxis

      public SequenceIterator iteratePrecedingSiblingOrSelfAxis(NodePredicate predicate)
      Get an iterator over the preceding-sibling-or-self axis, starting at this node; the nodes will be in reverse document order.
      Specified by:
      iteratePrecedingSiblingOrSelfAxis in interface GNode
      Parameters:
      predicate - a condition that the nodes must satisfy, or null
      Returns:
      the required iterator
    • iterateSelfAxis

      public SequenceIterator iterateSelfAxis(NodePredicate predicate)
      Get an iterator over the self axis, starting at this node; there will be zero or one nodes.
      Specified by:
      iterateSelfAxis in interface GNode
      Parameters:
      predicate - a condition that the nodes must satisfy, or null
      Returns:
      the required iterator
    • iterateAttributeAxis

      public SequenceIterator iterateAttributeAxis(NodePredicate predicate)
      Get an iterator over the attribute axis, starting at this node; the nodes will be in document order.
      Specified by:
      iterateAttributeAxis in interface GNode
      Parameters:
      predicate - a condition that the nodes must satisfy, or null
      Returns:
      the required iterator
    • iterateNamespaceAxis

      public SequenceIterator iterateNamespaceAxis(NodePredicate predicate)
      Get an iterator over the namespace axis, starting at this node; the nodes will be in reverse document order.
      Specified by:
      iterateNamespaceAxis in interface GNode
      Parameters:
      predicate - a condition that the nodes must satisfy, or null
      Returns:
      the required iterator
    • iterateChildAxis

      public SequenceIterator iterateChildAxis(NodePredicate predicate)
      Get an iterator over the child axis, starting at this node; the nodes will be in document order.
      Specified by:
      iterateChildAxis in interface GNode
      Parameters:
      predicate - a condition that the nodes must satisfy, or null
      Returns:
      the required iterator
    • copy

      public void copy(Receiver out, int copyOptions, Location locationId) throws XPathException
      Copy this node to a given outputter (deep copy)
      Specified by:
      copy in interface NodeInfo
      Parameters:
      out - the Receiver to which the node should be copied. It is the caller's responsibility to ensure that this Receiver is open before the method is called (or that it is self-opening), and that it is closed after use.
      copyOptions - a selection of the options defined in CopyOptions
      locationId - If non-null, identifies the location of the instruction that requested this copy. If null, indicates that the location information is not available
      Throws:
      XPathException - if any downstream error occurs