Package xbird.xquery

Examples of xbird.xquery.XQueryModule


                        System.err.println(file.getName());
                        System.out.println(IOUtils.toString(new FileInputStream(file)));
                        System.out.println();
                        FileReader fr = new FileReader(file);
                        XQueryParser t = new XQueryParser(fr);
                        XQueryModule m = t.parse();
                        fr.close();
                        StaticContext sc = t.getStaticContext();
                        sc.setSystemBaseURI(statEnv.getSystemBaseURI());
                        m.staticAnalysis(sc);
                        m.visit(GraphConstructionVisitor.this, sc);
                        // create panel
                        final JGraph jgraph = createJGraph();
                        jgraph.setBackground(Color.decode(DEFAULT_BG_COLOR));
                        final JScrollPane panel = new JScrollPane(jgraph);
                        panel.setPreferredSize(DEFAULT_SIZE);
View Full Code Here


                new ByteArrayInputStream(expr.getBytes()));
        parser.disable_tracing();

        PrintVisitor dumper;
        try {
            XQueryModule module = parser.parse();
            dumper = new PrintVisitor();
            module.visit(dumper, null);
            textArea2.setText(dumper.getResult());
        } catch (Exception e) {
            textArea2.setText(e.getMessage());
        }
    }
View Full Code Here

        }
        return (T) wrapResult(result, returnType);
    }

    private static XQExpression localCompile(final XQueryParser parser) throws RemoteException {
        final XQueryModule module;
        try {
            module = parser.parse();
        } catch (XQueryException e) {
            throw new RemoteException("parse failed.", e);
        }
        StaticContext statEnv = parser.getStaticContext();
        try {
            module.staticAnalysis(statEnv);
        } catch (XQueryException e) {
            throw new RemoteException("Error caused in the static analysis phase.", e);
        }
        return module.getExpression();
    }
View Full Code Here

        long free = SystemUtils.getHeapFreeMemory();
        StringBuilder stdbuf = new StringBuilder(256);
        stdbuf.append(" - free(init): " + StringUtils.displayBytesSize(free));
        StopWatch sw = new StopWatch("[Xbird] " + queryFile);
        XQueryProcessor processor = new XQueryProcessor();
        XQueryModule mod = processor.parse(new FileInputStream(queryFile), new File(DOC_BASE).toURI());
        processor.compile(mod);
        System.err.println(mod.getExpression().toString());
        Sequence result = processor.execute(mod);
        StringWriter res_sw = new StringWriter();
        Serializer ser = new SAXSerializer(new SAXWriter(res_sw), res_sw);
        ser.emit(result);
        String swresult = sw.toString();
View Full Code Here

    private static void parse(String path) throws Exception {
        System.out.println("Reading from: " + path);
        XQueryParser t = new XQueryParser(new FileInputStream(path));
        t.disable_tracing();
        final XQueryModule m;
        try {
            m = t.parse();
        } catch (Throwable e) {
            throw new Exception("Exception caused while parsing: " + path, e);
        }
        StaticContext sc = t.getStaticContext();
        sc.setSystemBaseURI(new File(path).toURI());
        if (enableStaticAnalysis) {
            m.staticAnalysis(sc);
        }
        GraphConstructionVisitor visualizer = new GraphConstructionVisitor(sc);
        m.visit(visualizer, sc);
        visualizer.showInFrame();
    }
View Full Code Here

                executeAt(reader, writer, _remoteEndpoint);
            } catch (IOException e) {
                throw new XQueryException("Caused an IO error", e);
            }
        } else {
            XQueryModule xqmod = new XQueryModule();
            XQueryProcessor proc = new XQueryProcessor(xqmod);
            XQueryModule module = proc.parse(reader, getBaseUri());
            if(_pull) {
                executeWithPullMode(proc, module, writer);
            } else {
                executeWithPushMode(proc, module, writer);
            }
View Full Code Here

            return;
        } catch (CacheException e) {
            reportError("Caching failed: " + queryPath, e, out);
            return;
        }
        XQueryModule loadedModule = loaded.queryObject;
        XQExpression body = loadedModule.getExpression();
        if(body == null) {
            return;
        }
        // set parameters
        Enumeration<String> paramNames = req.getParameterNames();
        while(paramNames.hasMoreElements()) {
            String name = paramNames.nextElement();
            String value = req.getParameter(name);
            QualifiedName qname = QNameUtil.parse(name, XQSP_NSURI);
            Variable var = loadedModule.getVariable(qname);
            if(var != null && (var instanceof ExternalVariable)) {
                var.setResult(XString.valueOf(value));
            }
        }
        // execute
View Full Code Here

                URI baseUri = url.toURI();
                staticEnv.setBaseURI(baseUri);
            } catch (URISyntaxException e) {
                log(PrintUtils.prettyPrintStackTrace(e, -1));
            }
            final XQueryModule module;
            try {
                module = parser.parse();
            } catch (XQueryException e) {
                log(PrintUtils.prettyPrintStackTrace(e, -1));
                _lock.readLock().unlock();
                throw e;
            }
            _lock.readLock().unlock();
            _lock.writeLock().lock();
            // set query cache
            cached.queryObject = module;
            cached.staticEnv = staticEnv;
            cached.loadTimeStamp = System.currentTimeMillis();
            _caches.put(path, cached);
            _lock.writeLock().unlock();
            _lock.readLock().lock();
            // static analysis
            try {
                module.staticAnalysis(staticEnv);
            } catch (XQueryException e) {
                log(PrintUtils.prettyPrintStackTrace(e, -1));
                _lock.readLock().unlock();
                throw e;
            }
View Full Code Here

        StringBuilder stdbuf = new StringBuilder(256);
        stdbuf.append(" - free(init): " + StringUtils.displayBytesSize(free));
        final StopWatch sw = new StopWatch("[Xbird] " + queryFile);
        queryFile = XMARK_HOME + '/' + queryFile;
        final XQueryProcessor processor = new XQueryProcessor();
        XQueryModule mod = processor.parse(new FileInputStream(queryFile), new File(queryFile).toURI());
        Sequence result = processor.execute(mod);
        StringWriter res_sw = new StringWriter();
        final Serializer ser = new SAXSerializer(new SAXWriter(res_sw), res_sw);
        ser.emit(result);
        String swresult = sw.toString();
View Full Code Here

        list.add(msg2);
        Assert.assertEquals(2, list.size());

        String query1 = "fn:collection('/" + COLLECTION_NAME + "/1.xml')//author[1]";
        XQueryProcessor proc = new XQueryProcessor();
        XQueryModule compiled1 = proc.parse(query1);
        StringWriter sw = new StringWriter();
        SAXWriter handler = new SAXWriter(sw);
        SAXSerializer ser = new SAXSerializer(handler);

        proc.execute(compiled1, ser);
View Full Code Here

TOP

Related Classes of xbird.xquery.XQueryModule

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.