Examples of XQuery


Examples of nux.xom.xquery.XQuery

        }
        outputDebugInfo(xdoc, settings, "transformation-result.xml");
    }

    public static void transform(Document xdoc, String query, String morpher) throws IOException, XQueryException, ParsingException {
        XQuery xmorpher = XQueryPool.GLOBAL_POOL.getXQuery(morpher, null);
        Nodes nodes = query(query, xdoc, null);
        Log.info("Transformation query [{0}] returned {1} nodes", query, nodes.size());
        XQueryUtil.update(nodes, xmorpher, null);
    }
View Full Code Here

Examples of nux.xom.xquery.XQuery

        return StringUtils.join(strings, separator == null ? " " : separator);
    }
   
    private static Nodes query(String query, Node contextNode, Map<String, Object> variables) {
        try {
            XQuery xselect = XQueryPool.GLOBAL_POOL.getXQuery(query, null);
            Nodes nodes = xselect.execute(contextNode, null, variables).toNodes();
            return nodes;
        } catch (XQueryException ex) {
            throw new RuntimeException(ex);
        }
    }
View Full Code Here

Examples of org.exist.xquery.XQuery

            }

            if(source != null) {

                //execute the xquery
                final XQuery xquery = broker.getXQueryService();
                xqPool = xquery.getXQueryPool();

                //try and get a pre-compiled query from the pool
                compiled = xqPool.borrowCompiledXQuery(broker, source);

                if(compiled == null) {
                    context = xquery.newContext(AccessContext.REST); //TODO should probably have its own AccessContext.SCHEDULER
                } else {
                    context = compiled.getContext();
                }

                //TODO: don't hardcode this?
                if(resource != null) {
                    context.setModuleLoadPath(XmldbURI.EMBEDDED_SERVER_URI.append(resource.getCollection().getURI()).toString());
                    context.setStaticallyKnownDocuments(new XmldbURI[] {
                        resource.getCollection().getURI()
                    });
                }

                if(compiled == null) {

                    try {
                        compiled = xquery.compile(context, source);
                    }
                    catch(final IOException e) {
                        abort("Failed to read query from " + xqueryresource);
                    }
                }

                //declare any parameters as external variables
                if(params != null) {
                    String bindingPrefix = params.getProperty("bindingPrefix");

                    if(bindingPrefix == null) {
                        bindingPrefix = "local";
                    }
                   

                    for(final Entry param : params.entrySet()) {
                        final String key = (String)param.getKey();
                        final String value = (String)param.getValue();
                        context.declareVariable( bindingPrefix + ":" + key, new StringValue(value));
                    }
                }

                xquery.execute(compiled, null);

            } else {
                LOG.warn("XQuery User Job not found: " + xqueryresource + ", job not scheduled");
            }
        } catch(final EXistException ee) {
View Full Code Here

Examples of org.exist.xquery.XQuery

            broker = db.get(subject);

            final Source source = getQuerySource(broker, scriptURI, script);
            if(source == null) {return;}

            final XQuery xquery = broker.getXQueryService();
            final XQueryContext context = xquery.newContext(AccessContext.XMLDB);

            final CompiledXQuery compiled = xquery.compile(context, source);

//            Sequence result = xquery.execute(compiled, subject.getName());

        final ProcessMonitor pm = db.getProcessMonitor();
View Full Code Here

Examples of org.exist.xquery.XQuery

        String query = "declare namespace catalog=\"http://www.w3.org/2005/02/query-test-XQTSCatalog\";"+
            "let $XQTSCatalog := xmldb:document('/db/XQTS/XQTSCatalog.xml') "+
            "return xs:string($XQTSCatalog/catalog:test-suite/@version)";

        XQuery xqs = broker.getXQueryService();
       
        Sequence results = xqs.execute(query, null, AccessContext.TEST);

        if (! results.isEmpty()) {
            String catalog = (String) results.itemAt(0).getStringValue();
            catalog = "XQTS_"+adoptString(catalog);
            File subfolder = new File(folder.getAbsolutePath()+sep+catalog);
View Full Code Here

Examples of org.exist.xquery.XQuery

        else
            query += "for $testGroup in $XQTSCatalog//catalog:test-group[@name = '"+parentName+"']/catalog:test-group";

        query += "\treturn xs:string($testGroup/@name)";

        XQuery xqs = broker.getXQueryService();
        Sequence results = xqs.execute(query, null, AccessContext.TEST);

        if (!results.isEmpty()) {
            File subfolder;
            String subPackage;
View Full Code Here

Examples of org.exist.xquery.XQuery

        String query = "declare namespace catalog=\"http://www.w3.org/2005/02/query-test-XQTSCatalog\";"+
            "let $XQTSCatalog := xmldb:document('/db/XQTS/XQTSCatalog.xml')"+
            "for $testGroup in $XQTSCatalog//catalog:test-group[@name = '"+testGroup+"']/catalog:test-case"+
            "\treturn xs:string($testGroup/@name)";

        XQuery xqs = broker.getXQueryService();
        Sequence results = xqs.execute(query, null, AccessContext.TEST);

        if (!results.isEmpty()) {
            folder.mkdirs();
            File jTest = new File(folder.getAbsolutePath()+sep+"C_"+adoptString(testGroup)+".java");
            FileWriter fstream = new FileWriter(jTest.getAbsoluteFile());
View Full Code Here

Examples of org.exist.xquery.XQuery

        }
    }

    private Sequence enviroment(String file) throws Exception {
        DBBroker broker = null;
        XQuery xquery = null;

        try {
            broker = db.get(db.getSecurityManager().getSystemSubject());
            xquery = broker.getXQueryService();

            broker.getConfiguration().setProperty(XQueryContext.PROPERTY_XQUERY_RAISE_ERROR_ON_FAILED_RETRIEVAL, true);

            String query = "xmldb:document('" + file + "')";

            return xquery.execute(query, null, AccessContext.TEST);

        } finally {
            db.release(broker);
        }
    }
View Full Code Here

Examples of org.exist.xquery.XQuery

        HashMap<String, Sequence> enviroments = new HashMap<String, Sequence>();

        DBBroker broker = null;
        try {
            broker = db.get(db.getSecurityManager().getSystemSubject());
            XQuery xquery = broker.getXQueryService();

            broker.getConfiguration().setProperty(XQueryContext.PROPERTY_XQUERY_RAISE_ERROR_ON_FAILED_RETRIEVAL, true);

            String query = "declare namespace qt='" + QT_NS + "';\n" + "let $testCases := xmldb:document('/db/QT3/" + file + "')\n"
                    + "let $tc := $testCases//qt:environment\n" + "return $tc";

            Sequence result = xquery.execute(query, null, AccessContext.TEST);

            String col = XmldbURI.create("/db/QT3/" + file).removeLastSegment().toString();

            for (NodeProxy node : result.toNodeSet()) {
                ElementImpl el = (ElementImpl) node.getNode();
View Full Code Here

Examples of org.exist.xquery.XQuery

        String enviroment = null;

        DBBroker broker = null;
        try {
            broker = db.get(db.getSecurityManager().getSystemSubject());
            XQuery xquery = broker.getXQueryService();

            broker.getConfiguration().setProperty(XQueryContext.PROPERTY_XQUERY_RAISE_ERROR_ON_FAILED_RETRIEVAL, true);

            String query = "declare namespace qt='" + QT_NS + "';\n" + "let $testCases := xmldb:document('/db/QT3/" + file + "')\n"
                    + "let $tc := $testCases//qt:environment[@name eq '" + name + "']\n" + "let $catalog := xmldb:document('/db/QT3/catalog.xml')\n"
                    + "let $cat := $catalog//qt:environment[@name eq '" + name + "']\n" + "return ($tc, $cat)";

            Sequence result = xquery.execute(query, null, AccessContext.TEST);

            String col = XmldbURI.create("/db/QT3/" + file).removeLastSegment().toString();

            for (NodeProxy node : result.toNodeSet()) {
                ElementImpl el = (ElementImpl) node.getNode();
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.