Package client.net.sf.saxon.ce.om

Examples of client.net.sf.saxon.ce.om.SequenceIterator


        if (out instanceof ComplexContentOutputter) {
            // Optimization is only safe if evaluated as part of a complex content constructor
            // Start and end with an empty string to force space separation from any previous or following outputs
            out.append(StringValue.EMPTY_STRING, 0);

            SequenceIterator iter = argument[0].iterate(context);
            Item it = iter.next();
            if (it == null) {
                return;
            }

            CharSequence first = it.getStringValueCS();
            out.characters(first);

            it = iter.next();
            if (it == null) {
                out.append(StringValue.EMPTY_STRING, 0);
                return;
            }

            // Type checking ensures that the separator is not an empty sequence
            if (argument.length == 1) {
                out.characters(it.getStringValueCS());

                while (true) {
                    it = iter.next();
                    if (it == null) {
                        break;
                    }
                    out.characters(it.getStringValueCS());
                }
            } else {
                CharSequence sep = argument[1].evaluateItem(context).getStringValueCS();
                out.characters(sep);
                out.characters(it.getStringValueCS());

                while (true) {
                    it = iter.next();
                    if (it == null) {
                        break;
                    }
                    out.characters(sep);
                    out.characters(it.getStringValueCS());
View Full Code Here


    * Evaluate
    */

    public Item evaluateItem(XPathContext c) throws XPathException {
        FastStringBuffer sb = new FastStringBuffer(FastStringBuffer.SMALL);
        SequenceIterator si = argument[0].iterate(c);
        while (true) {
            NumericValue nextInt = (NumericValue)si.next();
            if (nextInt == null) {
                break;
            }
            long next = nextInt.intValue();
            if (next < 0 || next > Integer.MAX_VALUE || !NameChecker.isValidChar((int)next)) {
View Full Code Here

    * Evaluate the function
    */

    public Item evaluateItem(XPathContext context) throws XPathException {
        AtomicComparer comparer = getAtomicComparer(context);
        SequenceIterator iter = argument[0].iterate(context);
        try {
            return minimax(iter, operation, comparer, ignoreNaN, context);
        } catch (XPathException err) {
            err.maybeSetLocation(getSourceLocator());
            throw err;
View Full Code Here

    public int getImplementationMethod() {
        return ITERATE_METHOD | PROCESS_METHOD;
    }

    public TailCall processLeavingTail(XPathContext context) throws XPathException {
        SequenceIterator iter = select.iterate(context);

        XPathContextMajor c2 = context.newContext();
        c2.setCurrentIterator(iter);
        c2.setCurrentTemplateRule(null);

        if (containsTailCall) {
            if (LogConfiguration.loggingIsEnabled() && LogController.traceIsEnabled()) {
                TraceListener listener = LogController.getTraceListener();
                Item item = iter.next();
                if (item == null) {
                    return null;
                }
                listener.startCurrentItem(item);
                TailCall tc = ((TailCallReturner)action).processLeavingTail(c2);
                listener.endCurrentItem(item);
                return tc;
             
            } else {
              Item item = iter.next();
              if (item == null) {
                  return null;
              }
            }
            return ((TailCallReturner)action).processLeavingTail(c2);
        } else {
            if (LogConfiguration.loggingIsEnabled() && LogController.traceIsEnabled()) {
                TraceListener listener = LogController.getTraceListener();
                while(true) {
                    Item item = iter.next();
                    if (item == null) {
                        break;
                    }
                    listener.startCurrentItem(item);
                    action.process(c2);
                    listener.endCurrentItem(item);
                }
            } else {
              while(true) {
                  Item item = iter.next();
                  if (item == null) {
                      break;
                  }
                  action.process(c2);
              }
View Full Code Here

     * @return a SequenceIterator that can be used to iterate over the result
     *     of the expression
     */

    public SequenceIterator iterate(XPathContext context) throws XPathException {
        SequenceIterator master = select.iterate(context);
        XPathContextMajor c2 = context.newContext();
        c2.setCurrentTemplateRule(null);
        c2.setCurrentIterator(master);
        master = new ContextMappingIterator(this, c2);
        return master;
View Full Code Here

    /**
     * Iterate over the sequence of values
     */

    public SequenceIterator iterate(final XPathContext context) throws XPathException {
        SequenceIterator base = operand.iterate(context);
        return new ItemMappingIterator(base, getMappingFunction(context), true);
    }
View Full Code Here

        // This class delivers the result of the path expression in unsorted order,
        // without removal of duplicates. If sorting and deduplication are needed,
        // this is achieved by wrapping the path expression in a DocumentSorter

        SequenceIterator result = start.iterate(context);
        XPathContext context2 = context.newMinorContext();
        context2.setCurrentIterator(result);

        result = new ContextMappingIterator(this, context2);

        // Peek at the first item, and depending on its type, check that all the items
        // are atomic values or that all are nodes.
        final SourceLocator loc = getSourceLocator();
        Item first = result.next();
        if (first == null) {
            return EmptyIterator.getInstance();
        } else if (first instanceof AtomicValue) {
            ItemMappingFunction atomicValueChecker = new ItemMappingFunction() {
                public Item mapItem(Item item) throws XPathException {
View Full Code Here

            CharSequence textValue;
            if (constantText != null) {
                textValue = constantText;
            } else {
                FastStringBuffer sb = new FastStringBuffer(FastStringBuffer.SMALL);
                SequenceIterator iter = content.iterate(context);
                while (true) {
                    Item item = iter.next();
                    if (item==null) break;
                    sb.append(item.getStringValueCS());
                }
                textValue = sb.condense();
            }
View Full Code Here

    /**
    * Iterate over the sequence of values
    */

    public SequenceIterator iterate(XPathContext context) throws XPathException {
        SequenceIterator base = operand.iterate(context);

        // If the base iterator knows how many items there are, then check it now rather than wasting time

        if ((base.getProperties() & SequenceIterator.LAST_POSITION_FINDER) != 0) {
            int count = ((LastPositionFinder)base).getLastPosition();
            if (count == 0 && !Cardinality.allowsZero(requiredCardinality)) {
                typeError("An empty sequence is not allowed as the " +
                             role.getMessage(), role.getErrorCode(), context);
            } else if (count == 1 && requiredCardinality == StaticProperty.EMPTY) {
                typeError("The only value allowed for the " +
                             role.getMessage() + " is an empty sequence", role.getErrorCode(), context);
            } else if (count > 1 && !Cardinality.allowsMany(requiredCardinality)) {
                typeError("A sequence of more than one item is not allowed as the " +
                                role.getMessage() + depictSequenceStart(base.getAnother(), 2),
                           role.getErrorCode(), context);
            }
            return base;
        }

View Full Code Here

    /**
    * Evaluate as an Item.
    */

    public Item evaluateItem(XPathContext context) throws XPathException {
        SequenceIterator iter = operand.iterate(context);
        Item item = null;
        while (true) {
            Item nextItem = iter.next();
            if (nextItem == null) break;
            if (requiredCardinality == StaticProperty.EMPTY) {
                typeError("An empty sequence is required as the " +
                    role.getMessage(), role.getErrorCode(), context);
                return null;
            }
            if (item != null) {
                typeError("A sequence of more than one item is not allowed as the " +
                    role.getMessage() + depictSequenceStart(iter.getAnother(), 2), role.getErrorCode(), context);
                return null;
            }
            item = nextItem;
        }
        if (item == null && !Cardinality.allowsZero(requiredCardinality)) {
View Full Code Here

TOP

Related Classes of client.net.sf.saxon.ce.om.SequenceIterator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.