Class NumberSequenceFormatter

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

    public class NumberSequenceFormatter
    extends Expression
    This expression performs the formatting part of the logic of the xsl:number instruction It takes as input a sequence of integers, which may either be supplied directly as the value attribute of xsl:number, or may be computed by counting nodes. The expression returns a string.
    • Constructor Detail

      • NumberSequenceFormatter

        public NumberSequenceFormatter​(Expression value,
                                       Expression format,
                                       Expression groupSize,
                                       Expression groupSeparator,
                                       Expression letterValue,
                                       Expression ordinal,
                                       Expression startAt,
                                       Expression lang,
                                       NumberFormatter formatter,
                                       boolean backwardsCompatible)
        Construct a NumberSequenceFormatter
        value - the expression supplied in the value attribute, or the NumberInstruction which computes the place-marker
        format - the expression supplied in the format attribute
        groupSize - the expression supplied in the group-size attribute
        groupSeparator - the expression supplied in the grouping-separator attribute
        letterValue - the expression supplied in the letter-value attribute
        ordinal - the expression supplied in the ordinal attribute
        startAt - the expression supplied in the start-at attribute
        lang - the expression supplied in the lang attribute
        formatter - A NumberFormatter to be used
        backwardsCompatible - true if running in 1.0 compatibility mode with a real value attribute
    • Method Detail

      • simplify

        public Expression simplify()
                            throws XPathException
        Simplify an expression. This performs any static optimization (by rewriting the expression as a different expression). The default implementation simplifies its operands.
        simplify in class Expression
        the simplified expression (or the original if unchanged, or if modified in-situ)
        XPathException - if an error is discovered during expression rewriting
      • 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
      • optimize

        public Expression optimize​(ExpressionVisitor visitor,
                                   ContextItemStaticInfo contextInfo)
                            throws XPathException
        Description copied from class: Expression
        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)
      • copy

        public Expression copy​(RebindingMap rebindings)
        Copy an expression. This makes a deep copy.
        Specified by:
        copy in class Expression
        rebindings - variables that need to be re-bound
        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
      • evaluateItem

        public StringValue evaluateItem​(XPathContext context)
                                 throws XPathException
        Description copied from class: Expression
        Evaluate an expression as a single item. This always returns either a single Item or null (denoting the empty sequence). No conversion is done. This method should not be used unless the static type of the expression is a subtype of "item" or "item?": that is, it should not be called if the expression may return a sequence. There is no guarantee that this condition will be detected.
        evaluateItem in class Expression
        context - The context in which the expression is to be evaluated
        the node or atomic value that results from evaluating the expression; or null to indicate that the result is an empty sequence
        XPathException - if any dynamic error occurs evaluating the expression
      • parseStartAtValue

        public java.util.List<java.lang.Integer> parseStartAtValue​(java.lang.String value)
                                                            throws XPathException
      • 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.