Package xbird.xquery.meta

Examples of xbird.xquery.meta.DynamicContext


        SequenceExpression seq = new SequenceExpression();
        AtomicValue it1 = new XString("1");
        AtomicValue it2 = new XString("2");
        seq.addExpression(new LiteralExpr(it1));
        seq.addExpression(new LiteralExpr(it2));
        Sequence<Item> res = (Sequence<Item>) seq.eval(null, new DynamicContext(new StaticContext()));
        Iterator<Item> resItor = res.iterator();
        assertTrue(resItor.hasNext());
        assertSame(it1, resItor.next());
        assertTrue(resItor.hasNext());
        assertSame(it2, resItor.next());
View Full Code Here


            }
        }
        // execute
        final Sequence<? extends Item> result;
        try {
            result = body.eval(null, new DynamicContext(loaded.staticEnv));
        } catch (XQueryException e) {
            reportError("Execution failed: " + queryPath, e, out);
            return;
        }
        // serialize       
View Full Code Here

    public Sequence<? extends Item> execute(XQueryModule module) throws XQueryException {
        if(_statEnv == null) {
            throw new IllegalStateException("compile() is not performed.");
        }
        return execute(module, new DynamicContext(_statEnv));
    }
View Full Code Here

    public void execute(XQueryModule module, XQEventReceiver handler) throws XQueryException {
        if(_statEnv == null) {
            throw new IllegalStateException("compile() is not performed.");
        }
        execute(module, new DynamicContext(_statEnv), handler);
    }
View Full Code Here

            _resHandler.onResponse(rc);
            return;
        }
        final Sequence<? extends Item> resultSeq;
        _runningThreads.put(rc, Thread.currentThread());
        final DynamicContext dynEnv = new DynamicContext(proccessor.getStaticContext());
        try {
            resultSeq = proccessor.execute(module, dynEnv);
        } catch (Exception e) {
            LOG.error("execute failed: \n" + query, e);
            rc.setFault(e);
View Full Code Here

        private void sort() throws XQueryException {
            if(!done) {
                final List<Comparable[]> items = _items;
                final List<OrderSpec> oderSpecs = _orderSpecs;
                final DynamicContext dynEnv = _dynEnv;

                final int keylen = oderSpecs.size();
                final IFocus<? extends Item> itor = src.iterator();
                for(Item it : itor) {
                    final Comparable[] tuple = new Comparable[keylen + 1];
View Full Code Here

                } else {
                    NodeList list = (NodeList) xpath.evaluate("/*[local-name()='test-suite']/*[local-name()='sources']/*[local-name()='collection'][@ID='"
                            + testDataId + "']/*[local-name()='input-document']/text()", catalog, XPathConstants.NODESET);
                    final int listlen = list.getLength();
                    if(listlen > 0) {
                        final NodeSequence<DTMDocument> ret = new NodeSequence<DTMDocument>(new DynamicContext(statEnv));
                        for(int i = 0; i < listlen; i++) {
                            String name = list.item(i).getTextContent();
                            DTMDocument testDataDoc = _docCache.get(name);
                            if(testDataDoc == null) {
                                File testDataFile = new File(xqtsDir, name + ".xml");
View Full Code Here

        for(int i = 0; i < _predicates.size(); i++) {
            XQExpression e = _predicates.get(i);
            if(e instanceof LiteralExpr) {
                AtomicValue literal = ((LiteralExpr) e).getValue();
                if(literal instanceof XNumber) {
                    DynamicContext probe = DynamicContext.PROBE;
                    probe.setStaticContext(statEnv);
                    XNumber xnum = (XNumber) literal;
                    double xdouble = xnum.asDouble();
                    long xint = xnum.asLong();
                    if(xdouble != xint) {
                        return SequenceExpression.EMPTY_SEQUENCE;
View Full Code Here

            super.staticAnalysis(statEnv);
            func.staticAnalysis(statEnv, _params);
            this._type = func.getReturnType(_params);
            final EvaluationPolicy evalPolicy = func.getEvaluationPolicy();
            if(evalPolicy == EvaluationPolicy.eager) {
                Sequence preEvaled = eval(ValueSequence.EMPTY_SEQUENCE, new DynamicContext(statEnv));
                return new PreEvaluatedVariable(preEvaled, _type);
            } else if(evalPolicy == EvaluationPolicy.rewritten) {
                XQExpression rewritted = func.rewrite(_params, statEnv);
                XQExpression analyzed = rewritted.staticAnalysis(statEnv);
                return analyzed;
View Full Code Here

            this.predicate = predicate;
            this.type = type;
        }

        public boolean next(IFocus focus) throws XQueryException {
            final DynamicContext dynEnv = _dynEnv;
            Iterator<? extends Item> itor = focus.getBaseFocus();
            while(itor.hasNext()) {
                int curidx = focus.incrPosition();
                Item it = itor.next();
                focus.setContextItem(it);

                // REVIEWME workaround for fn:last()
                dynEnv.pushSequence(_delegate);

                // evaluates predicate
                IFocus baseFocus = dynEnv.getFocus();
                dynEnv.setFocus(focus); // change focus
                Sequence cond = predicate.eval(it, dynEnv);
                dynEnv.setFocus(baseFocus);

                // workaround for fn:last()
                dynEnv.popSequence();

                if(cond instanceof XInteger) { // positional filtering
                    final long pos = ((XInteger) cond).getValue();
                    if(curidx == pos) {
                        return true;
                    } else {
                        continue;
                    }
                }

                dynEnv.pushSequence(_delegate);
                final boolean ebv = FnBoolean.effectiveBooleanValue(cond, curidx);
                dynEnv.popSequence();
                if(ebv) {
                    return true;
                } else {
                    continue;
                }
View Full Code Here

TOP

Related Classes of xbird.xquery.meta.DynamicContext

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.