Package net.sf.saxon.sapling

## Class SaplingNode

- java.lang.Object
- - net.sf.saxon.sapling.SaplingNode

- Direct Known Subclasses:
    `SaplingComment`, `SaplingDocument`, `SaplingElement`, `SaplingProcessingInstruction`, `SaplingText`

      public abstract class SaplingNode
      extends java.lang.Object

  This class represents a sapling node. Sapling nodes represent transient nodes used in the course of tree construction; they are intended to have a very lightweight implementation, making construction as simple as possible, and they do not support any complex navigation or query interfaces. Typically when construction of a sapling tree is complete it will be converted to a regular `NodeInfo` or `XdmNode` for further processing, or it can be sent to a destination such as a `Serializer` or `SchemaValidator`.

  The `SaplingDocument` node at the root of a constructed tree implements the JAXP `Source` interface which is widely accepted by a variety of interfaces in Saxon: this means that it can readily be used as input to a query, a transformation, a document builder, or a schema validator.

  Sapling nodes are immutable objects; operations such as `SaplingElement.withChild(net.sf.saxon.sapling.SaplingNode...)` create a new object and leave the original unchanged. This eliminates the need (found in other models such as the DOM) to make copies of nodes when attaching them to a tree.

  The data model supported by Sapling nodes is close to the XDM model, but with some limitations:

  - All nodes are untyped (elements are of type xs:untyped, attributes are xs:untypedAtomic).
  - The ID, IDREF, and NILLED properties cannot be set.
  - Some constraints on the model (for example, rules on the lexical form of names) are not enforced by the construction API.
  - Elements cannot have an independent base URI property, except to the extent that this can be defined using `xml:base` attributes; only document nodes have their own base URI
  - Zero length text nodes and adjacent text node siblings are permitted (they will be merged or eliminated when the sapling tree is converted to a regular node tree)

  Attributes are not represented as nodes in their own right, but rather as properties of element nodes.

  The internal representation of document and element nodes include a list of the node's children; but there are no links back from a node to its parent. This enables a node to be attached as a child to many different parents. This does not create problems, because nodes are immutable, and there are no operations that depend on concepts of node identity or document order.

  As in XDM, an element node contains a set of in-scope namespaces. There is no requirement that the in-scope namespaces of an element should be in any way related to those of its child or parent elements. Operations that construct a regular tree from a sapling tree will introduce namespace inheritance, whereby namespaces defined on a parent element are inherited by its children. Namespace bindings for the (prefix, URI) pairs used in the names of elements and attributes are added to an element automatically; additional namespace bindings may be added by explicit API request.

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `SaplingNode()` |

  - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `abstract int` | `getNodeKind()` | Get the kind of node (document, element, text, comment, or processing instruction)
    `protected abstract void` | `sendTo​(Receiver receiver)` | Send a sequence of events representing this node to a supplied Receiver

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### SaplingNode

          public SaplingNode()

  - ### Method Detail

    - #### getNodeKind

          public abstract int getNodeKind()

      Get the kind of node (document, element, text, comment, or processing instruction)
      Returns:
        the kind of node, for example `Type.ELEMENT` for an element node.

    - #### sendTo

          protected abstract void sendTo​(Receiver receiver)
                                  throws XPathException

      Send a sequence of events representing this node to a supplied Receiver
      Parameters:
        `receiver` - the receiver to which the events are to be sent
      Throws:
        `XPathException` - if the receiver throws an exception