Package org.pdf4j.saxon.om

Examples of org.pdf4j.saxon.om.SequenceIterator


    /**
    * Evaluate the function to return an iteration of selected nodes.
    */

    public SequenceIterator iterate(XPathContext context) throws XPathException {
        SequenceIterator seq = argument[0].iterate(context);
        AtomicValue n0 = (AtomicValue)argument[1].evaluateItem(context);
        NumericValue n = (NumericValue)n0;
        int pos = (int)n.longValue();
        if (pos < 1) {
            return seq;
View Full Code Here


    /**
    * Evaluate the function to return an iteration of selected nodes.
    */

    public SequenceIterator iterate(XPathContext context) throws XPathException {
        SequenceIterator seq = argument[0].iterate(context);
        AtomicValue startVal0 = (AtomicValue)argument[1].evaluateItem(context);
        NumericValue startVal = (NumericValue)startVal0;

        if (argument.length == 2) {
            long lstart;
View Full Code Here

     * Construct an node list that wraps a supplied SequenceExtent, checking that all the
     * items in the sequence are wrappers around DOM Nodes
    */

    public static DOMNodeList checkAndMake(SequenceExtent extent) throws XPathException {
        SequenceIterator it = extent.iterate();
        List list = new ArrayList(extent.getLength());
        while (true) {
            Item next = it.next();
            if (next==null) break;
            Object o = next;
            if (!(o instanceof NodeInfo)) {
                throw new XPathException("Supplied sequence contains an item that is not a Saxon NodeInfo");
            }
View Full Code Here

    public boolean matches(Value value, Configuration config) throws XPathException {
        if (!Cardinality.subsumes(cardinality, value.getCardinality())) {
            return false;
        }
        SequenceIterator iter = value.iterate();
        while (true) {
            Item item = iter.next();
            if (item == null) {
                return true;
            }
             if (!primaryType.matchesItem(item, false, config)) {
                 return false;
View Full Code Here

    * @return true if p1 and p2 contain at least one node in common (i.e. if the intersection
    * is not empty)
    */

    public static boolean hasSameNode(SequenceIterator p1, SequenceIterator p2) throws XPathException {
        SequenceIterator intersection =
            new IntersectionEnumeration(p1, p2, GlobalOrderComparer.getInstance());
        return intersection.next() != null;
    }
View Full Code Here

    public XdmValue evaluate() throws SaxonApiException {
        if (expression.isUpdateQuery()) {
            throw new IllegalStateException("Query is updating");
        }
        try {
            SequenceIterator iter = expression.iterator(context);
            ValueRepresentation result = SequenceExtent.makeSequenceExtent(iter);
            if (result instanceof NodeInfo) {
                return new XdmNode((NodeInfo)result);
            } else if (result instanceof AtomicValue) {
                return new XdmAtomicValue((AtomicValue)result);
View Full Code Here

    /**
    * Evaluate the function in a boolean context
    */

    public boolean effectiveBooleanValue(XPathContext c) throws XPathException {
        SequenceIterator iter = argument[0].iterate(c);
        boolean result = false;
        if ((iter.getProperties() & SequenceIterator.LOOKAHEAD) != 0) {
            switch (operation) {
                case EXISTS:
                    result = ((LookaheadIterator)iter).hasNext();
                    break;
                case EMPTY:
                    result = !((LookaheadIterator)iter).hasNext();
                    break;
            }
        } else {
            switch (operation) {
                case EXISTS:
                    result = iter.next() != null;
                    break;
                case EMPTY:
                    result = iter.next() == null;
                    break;
            }
        }
        iter.close();
        return result;
    }
View Full Code Here

    /**
    * Evaluate the function to return an iteration of selected nodes.
    */

    public SequenceIterator iterate(XPathContext context) throws XPathException {
        SequenceIterator seq = argument[0].iterate(context);
        AtomicValue n0 = (AtomicValue)argument[1].evaluateItem(context);
        NumericValue n = (NumericValue)n0;
        int pos = (int)n.longValue();
        SequenceIterator ins = argument[2].iterate(context);
        return new InsertIterator(seq, ins, pos);
    }
View Full Code Here

            switch (node.getNodeKind()) {
                case Type.DOCUMENT: {
                    if (node instanceof TinyNodeImpl) {
                        return new TinyTreeEventIterator(((TinyNodeImpl)node), pipe);
                    } else {
                        SequenceIterator content = node.iterateAxis(Axis.CHILD);
                        EventIterator contentEvents = new EventIteratorOverSequence(content);
                        return new BracketedDocumentIterator(
                                new Decomposer(contentEvents, pipe));
                    }
                }
                case Type.ELEMENT: {
                    if (node instanceof TinyNodeImpl) {
                        return new TinyTreeEventIterator(((TinyNodeImpl)node), pipe);
                    } else {
                        SequenceIterator content = node.iterateAxis(Axis.CHILD);
                        EventIterator contentEvents = new EventIteratorOverSequence(content);
                        StartElementEvent see = new StartElementEvent(pipe);
                        see.setNameCode(node.getNameCode());
                        see.setTypeCode(node.getTypeAnnotation());
                        see.setLocalNamespaces(node.getDeclaredNamespaces(null));
View Full Code Here

        XPathExpression exp = xpe.createExpression(
                "for $v in distinct-values(tokenize($in, '/')) return concat(' +', $v)");
        NodeInfo doc = xpe.getConfiguration().buildDocument(new StreamSource(new File(args[0])));
        XPathDynamicContext context = exp.createDynamicContext(doc);
        //context.setVariable(in, new StringValue(args[1]));
        SequenceIterator results = exp.iterate(context);
        while (true) {
            Item item = results.next();
            if (item == null) break;
            System.err.println(item);
        }
//        if (args.length != 2) {
//            System.err.println("format: java XPathEvaluator source.xml \"expression\"");
View Full Code Here

TOP

Related Classes of org.pdf4j.saxon.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.