net.sf.saxon.expr

## Class RootExpression

- java.lang.Object
- - net.sf.saxon.expr.Expression
  - - net.sf.saxon.expr.SingleNodeExpression
    - - net.sf.saxon.expr.RootExpression

- All Implemented Interfaces:
    Serializable, SourceLocator, LocationProvider, SaxonLocator, InstructionInfo, Locator

      public class RootExpression
      extends SingleNodeExpression

  An expression whose value is always a set of nodes containing a single node, the document root. This corresponds to the XPath Expression "/", including the implicit "/" at the start of a path expression with a leading "/".
  See Also:
    Serialized Form

- - ### Field Summary

    - ### Fields inherited from class net.sf.saxon.expr.Expression

      `EFFECTIVE_BOOLEAN_VALUE, EVALUATE_METHOD, EVENT_FEED_METHOD, INHERITED_CONTEXT, INSPECTION_CONTEXT, ITEM_FEED_METHOD, ITERATE_METHOD, locationId, MAX_SEQUENCE_LENGTH, MAX_STRING_LENGTH, NAVIGATION_CONTEXT, NODE_VALUE_CONTEXT, PROCESS_METHOD, PUSH_SELECTION, staticProperties, UNBOUNDED_LOWER, UNBOUNDED_UPPER, W3C_CONSUMING, W3C_FREE_RANGING, W3C_GROUP_CONSUMING, W3C_MOTIONLESS, WATCH_METHOD`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `RootExpression()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `PathMap.PathMapNodeSet` | `addToPathMap(PathMap pathMap, PathMap.PathMapNodeSet pathMapNodeSet)` Add a representation of this expression to a PathMap.
    `int` | `computeCardinality()` Specify that the expression returns a singleton
    `Expression` | `copy()` Copy an expression.
    `boolean` | `equals(Object other)` Is this expression the same as another expression?
    `void` | `explain(ExpressionPresenter destination)` Diagnostic print of expression structure.
    `ExpressionCompiler` | `getExpressionCompiler()` Return the compiler of the Root expression
    `String` | `getExpressionName()` Get a name identifying the kind of expression, in terms meaningful to a user.
    `int` | `getIntrinsicDependencies()` Determine which aspects of the context the expression depends on.
    `ItemType` | `getItemType(TypeHierarchy th)` Determine the data type of the items returned by this expression
    `NodeInfo` | `getNode(XPathContext context)` Return the first element selected by this Expression
    `int` | `getStreamability(int syntacticContext, boolean allowExtensions, List<String> reasons)` Get the "sweep" of this expression as defined in the W3C streamability specifications.
    `StreamingAdjunct` | `getStreamingAdjunct()` Get a class that supports streamed evaluation of this expression
    `int` | `hashCode()` get HashCode for comparing two expressions
    `protected String` | `noContextMessage()` Customize the error message on type checking
    `Pattern` | `toPattern(Configuration config, boolean is30)` Convert this expression to an equivalent XSLT pattern
    `Pattern` | `toStreamingPattern(Configuration config, List<String> reasonForFailure)` Convert this expression to a streaming pattern (a pattern used internally to match nodes during push processing of an event stream)
    `String` | `toString()` The toString() method for an expression attempts to give a representation of the expression in an XPath-like form, but there is no guarantee that the syntax will actually be true XPath.

    - ### Methods inherited from class net.sf.saxon.expr.SingleNodeExpression

      `computeSpecialProperties, effectiveBooleanValue, evaluateItem, isContextPossiblyUndefined, iterate, optimize, typeCheck`

    - ### Methods inherited from class net.sf.saxon.expr.Expression

      `adoptChildExpression, checkForUpdatingSubexpressions, checkPermittedContents, computeDependencies, computeStaticProperties, doPromotion, dynamicError, evaluateAsString, evaluatePendingUpdates, explain, getCardinality, getColumnNumber, getColumnNumber, getConstructType, getContainer, getDependencies, getEvaluationMethod, getExecutable, getHostLanguage, getImplementationMethod, getIntegerBounds, getLineNumber, getLineNumber, getLocationId, getLocationProvider, getObjectName, getProperties, getProperty, getPublicId, getSlotsUsed, getSpecialProperties, getSystemId, getSystemId, hasVariableBinding, implementsStaticTypeCheck, isSubtreeExpression, isUpdatingExpression, isVacuousExpression, iterateEvents, iterateSubExpressionInfo, iterateSubExpressions, markTailFunctionCalls, process, promote, replaceSubExpression, resetLocalStaticProperties, setContainer, setEvaluationMethod, setFiltered, setFlattened, setLocationId, simplify, staticTypeCheck, suppressValidation, typeError`

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

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### RootExpression

          public RootExpression()

  - ### Method Detail

    - #### noContextMessage

          protected String noContextMessage()

      Customize the error message on type checking
      Specified by:
        `noContextMessage` in class `SingleNodeExpression`

    - #### equals

          public boolean equals(Object other)

      Is this expression the same as another expression?
      Overrides:
        `equals` in class `Object`

    - #### computeCardinality

          public final int computeCardinality()

      Specify that the expression returns a singleton
      Overrides:
        `computeCardinality` in class `SingleNodeExpression`
      Returns:
        the computed cardinality, as one of the values `StaticProperty.ALLOWS_ZERO_OR_ONE`, `StaticProperty.EXACTLY_ONE`, `StaticProperty.ALLOWS_ONE_OR_MORE`, `StaticProperty.ALLOWS_ZERO_OR_MORE`

    - #### getItemType

          public ItemType getItemType(TypeHierarchy th)

      Determine the data type of the items returned by this expression
      Overrides:
        `getItemType` in class `SingleNodeExpression`
      Parameters:
        `th` - the type hierarchy cache
      Returns:
        Type.NODE

    - #### hashCode

          public int hashCode()

      get HashCode for comparing two expressions
      Overrides:
        `hashCode` in class `Object`

    - #### getNode

          public NodeInfo getNode(XPathContext context)
                           throws XPathException

      Return the first element selected by this Expression
      Specified by:
        `getNode` in class `SingleNodeExpression`
      Parameters:
        `context` - The evaluation context
      Returns:
        the NodeInfo of the first selected element, or null if no element is selected
      Throws:
        `XPathException`

    - #### getIntrinsicDependencies

          public int getIntrinsicDependencies()

      Determine which aspects of the context the expression depends on. The result is a bitwise-or'ed value composed from constants such as StaticProperty.VARIABLES and StaticProperty.CURRENT_NODE
      Overrides:
        `getIntrinsicDependencies` in class `SingleNodeExpression`
      Returns:
        a set of bit-significant flags identifying the "intrinsic" dependencies. The flags are documented in class net.sf.saxon.value.StaticProperty

    - #### copy

          public Expression copy()

      Copy an expression. This makes a deep copy.
      Specified by:
        `copy` in class `Expression`
      Returns:
        the copy of the original expression

    - #### toPattern

          public Pattern toPattern(Configuration config,
                          boolean is30)
                            throws XPathException

      Convert this expression to an equivalent XSLT pattern
      Overrides:
        `toPattern` in class `Expression`
      Parameters:
        `config` - the Saxon configuration
        `is30` - true if this is XSLT 3.0
      Returns:
        the equivalent pattern
      Throws:
        `XPathException` - if conversion is not possible

    - #### getStreamability

          public int getStreamability(int syntacticContext,
                             boolean allowExtensions,
                             List<String> reasons)

      Get the "sweep" of this expression as defined in the W3C streamability specifications. This provides an assessment of stylesheet code against the W3C criteria for guaranteed streamability, and is implemented to allow these criteria to be tested. It is not the case that all expression that emerge as streamable from this analysis are currently capable of being streamed by Saxon
      Overrides:
        `getStreamability` in class `Expression`
      Parameters:
        `syntacticContext` - one of the values `Expression.NAVIGATION_CONTEXT`, `Expression.NODE_VALUE_CONTEXT`, `Expression.INHERITED_CONTEXT`, `Expression.INSPECTION_CONTEXT`
        `allowExtensions` - if false, the definition of "guaranteed streamability" in the W3C specification is used. If true, Saxon extensions are permitted, which make some
        `reasons` - the caller may supply a list, in which case the implementation may add to this list a message explaining why the construct is not streamable, suitable for inclusion in an error message.
      Returns:
        one of the values `Expression.W3C_MOTIONLESS`, `Expression.W3C_CONSUMING`, `Expression.W3C_GROUP_CONSUMING`, `Expression.W3C_FREE_RANGING`

    - #### toStreamingPattern

          public Pattern toStreamingPattern(Configuration config,
                                   List<String> reasonForFailure)

      Convert this expression to a streaming pattern (a pattern used internally to match nodes during push processing of an event stream)
      Overrides:
        `toStreamingPattern` in class `Expression`
      Parameters:
        `config` - the Saxon configuration
        `reasonForFailure` - a list which will be populated with messages giving reasons why the expression cannot be converted
      Returns:
        the equivalent pattern if conversion succeeds; otherwise null

    - #### addToPathMap

          public PathMap.PathMapNodeSet addToPathMap(PathMap pathMap,
                                            PathMap.PathMapNodeSet pathMapNodeSet)

      Add a representation of this expression to a PathMap. The PathMap captures a map of the nodes visited by an expression in a source tree.
      Overrides:
        `addToPathMap` in class `Expression`
      Parameters:
        `pathMap` - the PathMap to which the expression should be added
        `pathMapNodeSet` -
      Returns:
        the pathMapNode representing the focus established by this expression, in the case where this expression is the first operand of a path expression or filter expression

    - #### getExpressionCompiler

          public ExpressionCompiler getExpressionCompiler()

      Return the compiler of the Root expression
      Overrides:
        `getExpressionCompiler` in class `Expression`
      Returns:
        the relevant ExpressionCompiler

    - #### getStreamingAdjunct

          public StreamingAdjunct getStreamingAdjunct()

      Get a class that supports streamed evaluation of this expression
      Overrides:
        `getStreamingAdjunct` in class `Expression`
      Returns:
        the relevant StreamingAdjunct, or null if none is available

    - #### toString

          public String toString()

      The toString() method for an expression attempts to give a representation of the expression in an XPath-like form, but there is no guarantee that the syntax will actually be true XPath. In the case of XSLT instructions, the toString() method gives an abstracted view of the syntax
      Overrides:
        `toString` in class `Expression`
      Returns:
        a representation of the expression as a string

    - #### getExpressionName

          public String getExpressionName()

      Description copied from class: `Expression`
      Get a name identifying the kind of expression, in terms meaningful to a user.
      Overrides:
        `getExpressionName` in class `Expression`
      Returns:
        a name identifying the kind of expression, in terms meaningful to a user. The name will always be in the form of a lexical XML QName, and should match the name used in explain() output displaying the expression.

    - #### explain

          public void explain(ExpressionPresenter destination)

      Diagnostic print of expression structure. The abstract expression tree is written to the supplied output destination.
      Specified by:
        `explain` in class `Expression`
      Parameters:
        `destination` - the expression presenter used to display the structure

Copyright (c) 2004-2013 Saxonica Limited. All rights reserved.