Interface Sequence

    • Method Detail

      • head

        Item head()
           throws XPathException
        Get the first item in the sequence.
        Returns:
        the first item in the sequence if there is one, or null if the sequence is empty
        Throws:
        XPathException - in the situation where the sequence is evaluated lazily, and evaluation of the first item causes a dynamic error.
      • iterate

        SequenceIterator iterate()
        Get a SequenceIterator over all the items in the sequence
        Returns:
        an iterator (specifically, a Saxon SequenceIterator, which is not a Iterator) over all the items
        Throws:
        UncheckedXPathException - in the situation where the sequence is evaluated lazily, and constructing an iterator over the items causes a dynamic error.
      • materialize

        default GroundedValue materialize()
                                   throws XPathException
        Create a GroundedValue containing the same items as this Sequence. A GroundedValue typically contains the entire sequence in memory; at any rate, it guarantees that the entire sequence can be read without any possibility of XPath dynamic errors arising.
        Returns:
        a GroundedValue containing the same items as this Sequence
        Throws:
        XPathException - if evaluating the contents of the sequence (lazily) fails with a dynamic error.
      • makeRepeatable

        default Sequence makeRepeatable()
                                 throws XPathException
        Ensure that the sequence is in a form where it can be evaluated more than once. Some sequences (for example LazySequence and Closure can only be evaluated once, and this operation causes these to be grounded. However, making it repeatable is not the same as making it grounded; it does not flush out all errors. Indeed, lazy evaluation relies on this property, because an expression that has been lifted out of a loop must not be evaluated unless the loop is executed at least once, to prevent spurious errors.
        Returns:
        An equivalent sequence that can be repeatedly evaluated
        Throws:
        XPathException - if evaluation fails