Class SortedSelection


  • public class SortedSelection
    extends NodeSetExpression
    A NodeSetExpression that retrieves nodes in order according to a specified sort key.
    Note there is no direct XSL expression syntax that generates this.
    The expression sorts a base NodeSet according to the value of a specified sort key. The sort key may be composite. The base NodeSet will always be in document order.
    • Constructor Detail

      • SortedSelection

        public SortedSelection​(Expression s,
                               int k)
        Constructor
        Parameters:
        s - An expression whose value is the base nodeset to be sorted
        k - the number of sort keys
    • Method Detail

      • setSortKey

        public void setSortKey​(SortKeyDefinition sk,
                               int k)
        Add a sort key and other sorting parameters
        Parameters:
        sk - A SortKeyDefinition
        k - The index of this SortKeyDefinition. The first sort key in major-to-minor order is numbered 0 (zero), the others are 1, 2, ... in sequence.
        Throws:
        java.lang.ArrayIndexOutOfBoundsException - if the sort key index is out of range, according to the number of sort keys defined when the SortedSelection was initialized.
      • getDependencies

        public int getDependencies()
        Determine which aspects of the context the expression depends on. The result is a bitwise-or'ed value composed from constants such as Context.VARIABLES and Context.CURRENT_NODE
        Specified by:
        getDependencies in class Expression
      • reduce

        public Expression reduce​(int dependencies,
                                 Context context)
                          throws XPathException
        Perform a partial evaluation of the expression, by eliminating specified dependencies on the context.
        Specified by:
        reduce in class Expression
        Parameters:
        dependencies - The dependencies to be removed
        context - The context to be used for the partial evaluation
        Returns:
        a new expression that does not have any of the specified dependencies
        Throws:
        XPathException
      • enumerate

        public NodeEnumeration enumerate​(Context context,
                                         boolean sort)
                                  throws XPathException
        Evaluate the expression by sorting the base nodeset using the supplied key.
        Specified by:
        enumerate in class NodeSetExpression
        Parameters:
        context - The context for the evaluation
        sort - : must be false (because document order would be meaningless)
        Returns:
        the sorted nodeset
        Throws:
        XPathException - when the expression does not return a nodeset.
      • display

        public void display​(int level)
        Diagnostic print of expression structure
        Specified by:
        display in class Expression