Examples of StaticContext


Examples of xbird.xquery.meta.StaticContext

    }

    public void execute(XQueryModule module, DynamicContext dynEnv, XQEventReceiver handler)
            throws XQueryException {
        // static analysis
        StaticContext statEnv = dynEnv.getStaticContext();
        module.staticAnalysis(statEnv);
        // dynamic evaluation
        XQExpression body = module.getExpression();
        dynEnv.setQueryExpression(body);
        evalHook(dynEnv);
View Full Code Here

Examples of xbird.xquery.meta.StaticContext

            }
        }
    }

    private static void evalHook(DynamicContext dynEnv) {
        final StaticContext statEnv = dynEnv.getStaticContext();
        final List<ThreadedVariable> threadedVars = statEnv.getThreadedVariables();
        for(ThreadedVariable threadedVar : threadedVars) {
            final String threadName = "ThreadedVariable#" + threadedVar.getName();
            threadedVar.setDynamicContext(dynEnv);
            final Thread task = new Thread(threadedVar, threadName);
            task.setDaemon(true);
View Full Code Here

Examples of xbird.xquery.meta.StaticContext

                    + rsig);
        }
        final CompileRequest compileRequest = (CompileRequest) request;
        final XQExpression rawExpr = compileRequest.getExpression();

        final StaticContext statEnv = new StaticContext();
        final XQExpression compiledExpr;
        try {
            compiledExpr = rawExpr.staticAnalysis(statEnv);
        } catch (XQueryException e) {
            rc.setFault(e);
View Full Code Here

Examples of xbird.xquery.meta.StaticContext

        return QualifiedName.class;
    }

    public QNameValue createInstance(String literal, AtomicType srcType, DynamicContext dynEnv)
            throws XQueryException {
        final StaticContext staticEnv = dynEnv.getStaticContext();
        final QualifiedName name;
        try {
            name = QNameUtil.parse(literal, staticEnv.getStaticalyKnownNamespaces(), staticEnv.getDefaultElementNamespace());
        } catch (XQueryException e) {
            e.setErrCode("err:FONS0004");
            throw e;
        }
        return new QNameValue(name);
View Full Code Here

Examples of xbird.xquery.meta.StaticContext

        return s;
    }

    public Sequence eval(Sequence<? extends Item> contextSeq, ValueSequence argv, DynamicContext dynEnv)
            throws XQueryException {
        StaticContext sc = dynEnv.getStaticContext();
        URI uri = sc.getBaseURI();
        if(uri == null) {
            return ValueSequence.EMPTY_SEQUENCE;
        }
        return new AnyURIValue(uri);
    }
View Full Code Here

Examples of xbird.xquery.meta.StaticContext

        match("//*/cccc", "/bbb/aaa/ccc/cccc", true);
        match("//aaa/*", "/bbb/aaa/ccc/cccc", false);
    }
   
    private void match(String ptnStr1, String ptnStr2, boolean expected) {
        StaticContext statEnv = new StaticContext();
        NamespaceBinder namespaces = statEnv.getStaticalyKnownNamespaces();
        XMLPathPattern ptn1 = new XMLPathPattern(ptnStr1, namespaces);
        XMLPathPattern ptn2 = new XMLPathPattern(ptnStr2, namespaces);
        Assert.assertSame(ptn1 + " <-> " + ptn2, expected, ptn1.match(ptn2));
    }
View Full Code Here

Examples of xbird.xquery.meta.StaticContext

            final int rslen = rs.getLength();
            for(int i = 0; i < rslen; i++) {
                if(doPrint) {
                    println("\n------------------------------------------------");
                }
                final StaticContext statEnv = new StaticContext();
                statEnv.setConstructionModeStrip(true);

                Node testCase = rs.item(i);
                final String testName = xpath.evaluate("./@name", testCase);
                final String testFilePath = xpath.evaluate("./@FilePath", testCase);
                final String queryFileName = xpath.evaluate("./*[local-name()='query']/@name", testCase);
                File queryFile = new File(xqtsQueryPath, testFilePath + queryFileName + ".xq");
                final URI baseUri = new File(xqtsQueryPath, testFilePath).toURI();

                XQueryModule xqmod = new XQueryModule();

                {// ((//*:test-group)//*:test-case)/*:module
                    NodeList moduleNodes = (NodeList) xpath.evaluate("./*[local-name()='module']", testCase, XPathConstants.NODESET);
                    final int modcount = moduleNodes.getLength();
                    if(modcount > 0) {
                        ModuleManager moduleManager = statEnv.getModuleManager();
                        SimpleModuleResolver modResolver = new SimpleModuleResolver();
                        moduleManager.setModuleResolver(modResolver);
                        for(int j = 0; j < modcount; j++) {
                            Node moduleNode = moduleNodes.item(j);
                            String moduleId = moduleNode.getTextContent();
                            String moduleFileStr = xpath.evaluate("/*[local-name()='test-suite']/*[local-name()='sources']/*[local-name()='module']/@FileName[../@ID='"
                                    + moduleId + "']", catalog);
                            File moduleFile = new File(xqtsDir, moduleFileStr + ".xq");
                            String physical = moduleFile.toURI().toString();
                            String logical = xpath.evaluate("./@namespace", moduleNode);
                            modResolver.addMappingRule(logical, physical);
                        }
                    }
                }
                {// ((//*:test-group)//*:test-case)/*:input-file
                    NodeList vars1 = (NodeList) xpath.evaluate("./*[local-name()='input-file']/@variable", testCase, XPathConstants.NODESET);
                    loadVariables(vars1, testCase, xqmod, statEnv, xpath, catalog, false);
                }
                { // ((//*:test-group)//*:test-case)/*:input-URI
                    NodeList vars2 = (NodeList) xpath.evaluate("./*[local-name()='input-URI']/@variable", testCase, XPathConstants.NODESET);
                    loadVariables(vars2, testCase, xqmod, statEnv, xpath, catalog, true);
                }
                {// ((//*:test-group)//*:test-case)/*:defaultCollection
                    String colId = xpath.evaluate("./*[local-name()='defaultCollection']/text()", testCase);
                    if(colId != null) {
                        NodeList list = (NodeList) xpath.evaluate("/*[local-name()='test-suite']/*[local-name()='sources']/*[local-name()='collection'][@ID='"
                                + colId + "']/*[local-name()='input-document']/text()", catalog, XPathConstants.NODESET);
                        final int listlen = list.getLength();
                        if(listlen > 0) {
                            final Map<String, DTMDocument> defaultCollectionMap = new HashMap<String, DTMDocument>(listlen);
                            for(int j = 0; j < listlen; j++) {
                                String name = list.item(j).getTextContent();
                                String docName = name + ".xml";
                                DTMDocument testDataDoc = _docCache.get(name);
                                if(testDataDoc == null) {
                                    File testDataFile = new File(xqtsDir, docName);
                                    DocumentTableModel dtm = new DocumentTableModel(false);
                                    dtm.loadDocument(new FileInputStream(testDataFile));
                                    testDataDoc = dtm.documentNode();
                                    _docCache.put(name, testDataDoc);
                                }
                                defaultCollectionMap.put(docName, testDataDoc);
                                // import namespace decl
                                Map<String, String> nsmap = testDataDoc.documentTable().getDeclaredNamespaces();
                                NamespaceBinder nsResolver = statEnv.getStaticalyKnownNamespaces();
                                nsResolver.declarePrefixs(nsmap);
                            }
                            statEnv.setDefaultCollection(defaultCollectionMap);
                        }
                    }
                }
                Sequence<? extends Item> contextItem = null;
                {// ((//*:test-group)//*:test-case)/*:contextItem
 
View Full Code Here

Examples of xbird.xquery.meta.StaticContext

            LOG.info("Invoking remote query at [" + endpoint + "]:\n " + query);
        }

        XQEngineClient client = new XQEngineClient(endpoint);
        QueryRequest request = new QueryRequest(query, RETURN_TYPE);
        StaticContext statEnv = dynEnv.getStaticContext();
        URI baseUri = statEnv.getBaseURI();
        if(baseUri == null) {
            baseUri = statEnv.getSystemBaseURI();
        }
        request.setBaseUri(baseUri);
        prepareVariablesToShip(request, argv, dynEnv);
        final Object result;
        try {
View Full Code Here

Examples of xbird.xquery.meta.StaticContext

    public static Sequence evaluateQuery(Reader reader, DynamicContext dynEnv)
            throws XQueryException {
        assert (dynEnv != null);
        // parse query
        XQueryParser parser = new XQueryParser(reader);
        StaticContext sc = dynEnv.getStaticContext();
        parser.setStaticContext(sc);
        Module mod = parser.parse();
        // static analysis
        mod.staticAnalysis(sc);
        // evaluate
View Full Code Here

Examples of xbird.xquery.meta.StaticContext

        NodeList rs = (NodeList) xpath.evaluate(testPath, catalog, XPathConstants.NODESET);
        final int rslen = rs.getLength();
        for(int i = 0; i < rslen; i++) {
            if(doPrint)
                println("\n------------------------------------------------");
            final StaticContext statEnv = new StaticContext();
            statEnv.setConstructionModeStrip(true);

            Node testCase = rs.item(i);
            final String testName = xpath.evaluate("./@name", testCase);
            final String testFilePath = xpath.evaluate("./@FilePath", testCase);
            final String queryFileName = xpath.evaluate("./*[local-name()='query']/@name", testCase);
            File queryFile = new File(xqtsQueryPath, testFilePath + queryFileName + ".xq");
            final URI baseUri = new File(xqtsQueryPath, testFilePath).toURI();

            XQueryModule xqmod = new XQueryModule();

            {// ((//*:test-group)//*:test-case)/*:module
                NodeList moduleNodes = (NodeList) xpath.evaluate("./*[local-name()='module']", testCase, XPathConstants.NODESET);
                final int modcount = moduleNodes.getLength();
                if(modcount > 0) {
                    ModuleManager moduleManager = statEnv.getModuleManager();
                    SimpleModuleResolver modResolver = new SimpleModuleResolver();
                    moduleManager.setModuleResolver(modResolver);
                    for(int j = 0; j < modcount; j++) {
                        Node moduleNode = moduleNodes.item(j);
                        String moduleId = moduleNode.getTextContent();
                        String moduleFileStr = xpath.evaluate("/*[local-name()='test-suite']/*[local-name()='sources']/*[local-name()='module']/@FileName[../@ID='"
                                + moduleId + "']", catalog);
                        File moduleFile = new File(xqtsDir, moduleFileStr + ".xq");
                        String physical = moduleFile.toURI().toString();
                        String logical = xpath.evaluate("./@namespace", moduleNode);
                        modResolver.addMappingRule(logical, physical);
                    }
                }
            }
            {// ((//*:test-group)//*:test-case)/*:input-file
                NodeList vars1 = (NodeList) xpath.evaluate("./*[local-name()='input-file']/@variable", testCase, XPathConstants.NODESET);
                loadVariables(vars1, testCase, xqmod, statEnv, xpath, false);
            }
            { // ((//*:test-group)//*:test-case)/*:input-URI
                NodeList vars2 = (NodeList) xpath.evaluate("./*[local-name()='input-URI']/@variable", testCase, XPathConstants.NODESET);
                loadVariables(vars2, testCase, xqmod, statEnv, xpath, true);
            }
            {// ((//*:test-group)//*:test-case)/*:defaultCollection
                String colId = xpath.evaluate("./*[local-name()='defaultCollection']/text()", testCase);
                if(colId != null) {
                    NodeList list = (NodeList) xpath.evaluate("/*[local-name()='test-suite']/*[local-name()='sources']/*[local-name()='collection'][@ID='"
                            + colId + "']/*[local-name()='input-document']/text()", catalog, XPathConstants.NODESET);
                    final int listlen = list.getLength();
                    if(listlen > 0) {
                        final Map<String, DTMDocument> defaultCollectionMap = new HashMap<String, DTMDocument>(listlen);
                        for(int j = 0; j < listlen; j++) {
                            String name = list.item(j).getTextContent();
                            String docName = name + ".xml";
                            DTMDocument testDataDoc = _docCache.get(name);
                            if(testDataDoc == null) {
                                File testDataFile = new File(xqtsDir, docName);
                                DocumentTableModel dtm = new DocumentTableModel(false);
                                dtm.loadDocument(new FileInputStream(testDataFile));
                                testDataDoc = dtm.documentNode();
                                _docCache.put(name, testDataDoc);
                            }
                            defaultCollectionMap.put(docName, testDataDoc);
                            // import namespace decl
                            Map<String, String> nsmap = testDataDoc.documentTable().getDeclaredNamespaces();
                            NamespaceBinder nsResolver = statEnv.getStaticalyKnownNamespaces();
                            nsResolver.declarePrefixs(nsmap);
                        }
                        statEnv.setDefaultCollection(defaultCollectionMap);
                    }
                }
            }
            Sequence<? extends Item> contextItem = null;
            {// ((//*:test-group)//*:test-case)/*:contextItem
 
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.