Class NumberInstruction

  • All Implemented Interfaces:
    ExportAgent, Locatable, IdentityComparable, Traceable

    public class NumberInstruction
    extends Expression
    This instruction performs the node-counting function of the xsl:number instruction. It delivers as its result a sequence of integers. The parent expression is typically a NumberSequenceFormatter which takes this sequence of integers and performs the necessary formatting.
    • Constructor Detail

      • NumberInstruction

        public NumberInstruction​(Expression select,
                                 int level,
                                 Pattern count,
                                 Pattern from)
        Construct a NumberInstruction
        select - the expression supplied in the select attribute
        level - one of "single", "level", "multi"
        count - the pattern supplied in the count attribute
        from - the pattern supplied in the from attribute
    • Method Detail

      • isInstruction

        public boolean isInstruction()
        Ask whether this expression is an instruction. In XSLT streamability analysis this is used to distinguish constructs corresponding to XSLT instructions from other constructs, typically XPath expressions.
        isInstruction in class Expression
        true -- this construct originates as an XSLT instruction
      • operands

        public java.lang.Iterable<Operand> operands()
        Description copied from class: Expression
        Get the immediate sub-expressions of this expression, with information about the relationship of each expression to its parent expression. Default implementation works off the results of iterateSubExpressions()

        If the expression is a Callable, then it is required that the order of the operands returned by this function is the same as the order of arguments supplied to the corresponding call() method.

        operands in class Expression
        an iterator containing the sub-expressions of this expression
      • getLevel

        public int getLevel()
        Get the level attribute
        the coded value of the level attribute
      • getCount

        public Pattern getCount()
        Get the count pattern, if specified
        the count pattern if there is one, otherwise null
      • getFrom

        public Pattern getFrom()
        Get the from pattern, if specified
        the from pattern if there is one, otherwise null
      • getSelect

        public Expression getSelect()
        Get the select expression
        the select expression (which defaults to a ContextItemExpression)
      • copy

        public Expression copy​(RebindingMap rebindings)
        Copy an expression. This makes a deep copy.
        Specified by:
        copy in class Expression
        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.
        the copy of the original expression
      • getItemType

        public ItemType getItemType()
        Description copied from class: Expression
        Determine the static item type of the expression, as precisely possible. All expression return sequences, in general; this method determines the type of the items within the sequence, assuming that (a) this is known in advance, and (b) it is the same for all items in the sequence.

        This method should always return a result, though it may be the best approximation that is available at the time.

        Specified by:
        getItemType in class Expression
        a value such as Type.STRING, Type.BOOLEAN, Type.NUMBER, Type.NODE, or Type.ITEM (meaning not known at compile time)
      • 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
        the implementation method, for example Expression.ITERATE_METHOD or Expression.EVALUATE_METHOD or Expression.PROCESS_METHOD
      • optimize

        public Expression optimize​(ExpressionVisitor visitor,
                                   ContextItemStaticInfo contextInfo)
                            throws XPathException
        Perform optimisation of an expression and its subexpressions. This is the third and final phase of static optimization.

        This method is called after all references to functions and variables have been resolved to the declaration of the function or variable, and after all type checking has been done.

        optimize in class Expression
        visitor - an expression visitor
        contextInfo - the static type of "." at the point where this expression is invoked. The parameter is set to null if it is known statically that the context item will be undefined. If the type of the context item is not known statically, the argument is set to Type.ITEM_TYPE
        the original expression, rewritten if appropriate to optimize execution
        XPathException - if an error is discovered during this phase (typically a type error)
      • iterate

        public SequenceIterator iterate​(XPathContext context)
                                 throws XPathException
        Description copied from class: Expression
        Return an Iterator to iterate over the values of a sequence. The value of every expression can be regarded as a sequence, so this method is supported for all expressions. This default implementation handles iteration for expressions that return singleton values: for non-singleton expressions, the subclass must provide its own implementation.
        iterate in class Expression
        context - supplies the context for evaluation
        a SequenceIterator that can be used to iterate over the result of the expression
        XPathException - if any dynamic error occurs evaluating the expression
      • getExpressionName

        public java.lang.String getExpressionName()
        Description copied from class: Expression
        Get a name identifying the kind of expression, in terms meaningful to a user.
        getExpressionName in class Expression
        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 export() output displaying the expression.
      • 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
        out - the expression presenter used to display the structure
        XPathException - if the export fails, for example if an expression is found that won't work in the target environment.