Class CurrentGroupCall

java.lang.Object
net.sf.saxon.expr.Expression
net.sf.saxon.functions.CurrentGroupCall
All Implemented Interfaces:
Callable, ExportAgent, Locatable, IdentityComparable, Traceable

public class CurrentGroupCall extends Expression implements Callable
Implements the XSLT function current-group()
  • Constructor Details

    • CurrentGroupCall

      public CurrentGroupCall()
  • Method Details

    • getScopingExpression

      public Expression getScopingExpression()
      Get the innermost scoping expression of this expression, for expressions that directly depend on something in the dynamic context. For example, in the case of a local variable reference this is the expression that causes the relevant variable to be bound; for a context item expression it is the innermost focus-setting container. For expressions that have no intrinsic dependency on the dynamic context, the value returned is null; the scoping container for such an expression is the innermost scoping container of its operands.
      Overrides:
      getScopingExpression in class Expression
      Returns:
      the innermost scoping container of this expression
    • setControllingInstruction

      public void setControllingInstruction(ForEachGroup instruction, ItemType itemType, boolean isHigherOrder)
      Set the containing xsl:for-each-group instruction, if there is one
      Parameters:
      instruction - the (innermost) containing xsl:for-each-group instruction
      itemType - the statically inferred item type of the grouping population
      isHigherOrder - true typically if the current-group() expression is evaluated more than once during evaluation of the body of the for-each-group instruction; or more generally, if there is an operand on the path between the controlling for-each-group instruction and this current-group() call that is a higher-order operand of its parent instruction.
    • resetLocalStaticProperties

      public void resetLocalStaticProperties()
      Description copied from class: Expression
      Reset the static properties of the expression to -1, so that they have to be recomputed next time they are used.
      Overrides:
      resetLocalStaticProperties in class Expression
    • getControllingInstruction

      public ForEachGroup getControllingInstruction()
      Get the innermost containing xsl:for-each-group instruction, if there is one
      Returns:
      the innermost containing xsl:for-each-group instruction
    • findControllingInstruction

      public static ForEachGroup findControllingInstruction(Expression exp)
    • isInHigherOrderOperand

      public boolean isInHigherOrderOperand()
      Determine whether the current-group() function is executed repeatedly within a single iteration of the containing xsl:for-each-group
      Returns:
      true if it is evaluated repeatedly
    • getItemType

      public ItemType getItemType()
      Determine the item type of the value returned by the function
      Specified by:
      getItemType in class Expression
      Returns:
      a value such as Type.STRING, Type.BOOLEAN, Type.NUMBER, Type.NODE, or Type.ITEM (meaning not known at compile time)
    • getIntrinsicDependencies

      public int getIntrinsicDependencies()
      Determine the dependencies
      Overrides:
      getIntrinsicDependencies in class Expression
      Returns:
      an integer containing bit-significant flags identifying the "intrinsic" dependencies. The flags are documented in class net.sf.saxon.value.StaticProperty
    • computeCardinality

      protected int computeCardinality()
      Compute the static cardinality of this expression
      Specified by:
      computeCardinality in class Expression
      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
    • getImplementationMethod

      public int getImplementationMethod()
      An implementation of Expression must provide at least one of the methods evaluateItem(), iterate(), or process(). This method indicates which of these methods is provided directly. The other methods will always be available indirectly, using an implementation that relies on one of the other methods.
      Specified by:
      getImplementationMethod in class Expression
      Returns:
      the implementation method, for example Expression.ITERATE_METHOD or Expression.EVALUATE_METHOD or Expression.PROCESS_METHOD
    • export

      public void export(ExpressionPresenter out) throws XPathException
      Diagnostic print of expression structure. The abstract expression tree is written to the supplied output destination.
      Specified by:
      export in interface ExportAgent
      Specified by:
      export in class Expression
      Parameters:
      out - the expression presenter used to display the structure
      Throws:
      XPathException - if the export fails, for example if an expression is found that won't work in the target environment.
    • computeSpecialProperties

      protected int computeSpecialProperties()
      Determine the special properties of this expression. The properties such as document-ordering are the same as the properties of the grouping population as a whole.
      Overrides:
      computeSpecialProperties in class Expression
      Returns:
      StaticProperty.NO_NODES_NEWLY_CREATED (unless the variable is assignable using saxon:assign)
    • copy

      public Expression copy(RebindingMap rebindings)
      Description copied from class: Expression
      Copy an expression. This makes a deep copy.
      Specified by:
      copy in class Expression
      Parameters:
      rebindings - a mutable list of (old binding, new binding) pairs that is used to update the bindings held in any local variable references that are copied.
      Returns:
      the copy of the original expression
    • iterate

      public SequenceIterator iterate(XPathContext context) throws XPathException
      Return an iteration over the result sequence
      Overrides:
      iterate in class Expression
      Parameters:
      context - supplies the context for evaluation
      Returns:
      a SequenceIterator that can be used to iterate over the result of the expression
      Throws:
      XPathException - if any dynamic error occurs evaluating the expression
    • call

      public Sequence call(XPathContext context, Sequence[] arguments) throws XPathException
      Call the Callable (used from generated bytecode).
      Specified by:
      call in interface Callable
      Parameters:
      context - the dynamic evaluation context
      arguments - the values of the arguments, supplied as Sequences.

      Generally it is advisable, if calling iterate() to process a supplied sequence, to call it only once; if the value is required more than once, it should first be converted to a GroundedValue by calling the utility method SequenceTool.toGroundedValue().

      If the expected value is a single item, the item should be obtained by calling Sequence.head(): it cannot be assumed that the item will be passed as an instance of Item or AtomicValue.

      It is the caller's responsibility to perform any type conversions required to convert arguments to the type expected by the callee. An exception is where this Callable is explicitly an argument-converting wrapper around the original Callable.

      Returns:
      the result of the evaluation, in the form of a Sequence. It is the responsibility of the callee to ensure that the type of result conforms to the expected result type.
      Throws:
      XPathException - if a dynamic error occurs during the evaluation of the expression
    • toString

      public String toString()

      The toString() method for an expression attempts to give a representation of the expression in an XPath-like form.

      For subclasses of Expression that represent XPath expressions, the result should always be a string that parses as an XPath 3.0 expression. The expression produced should be equivalent to the original making certain assumptions about the static context. In general the expansion will make no assumptions about namespace bindings, except that (a) the prefix "xs" is used to refer to the XML Schema namespace, and (b) the default funcion namespace is assumed to be the "fn" namespace.

      In the case of XSLT instructions and XQuery expressions, the toString() method gives an abstracted view of the syntax that is not designed in general to be parseable.

      Overrides:
      toString in class Expression
      Returns:
      a representation of the expression as a string
    • toShortString

      public String toShortString()
      Produce a short string identifying the expression for use in error messages
      Overrides:
      toShortString in class Expression
      Returns:
      a short string, sufficient to identify the expression
    • getStreamerName

      public String getStreamerName()
      Get the (partial) name of a class that supports streaming of this kind of expression
      Overrides:
      getStreamerName in class Expression
      Returns:
      the partial name of a class that can be instantiated to provide streaming support in Saxon-EE, or null if there is no such class
    • getElaborator

      public Elaborator getElaborator()
      Make an elaborator for this expression
      Overrides:
      getElaborator in class Expression
      Returns:
      an appropriate Elaborator