Package org.exist.xmldb

Examples of org.exist.xmldb.XQueryService.query()


  public static String[] wordList(Collection root) throws XMLDBException {
        final String query = "util:index-keys(//*, \"\", function($key, $options) {\n" +
                "    $key\n" +
                "}, 100, \"lucene-index\")";
        XQueryService service = getXQueryService(root);
        ResourceSet result = service.query(query);

        ArrayList<String> list = new ArrayList<String>();
        for (ResourceIterator iter = result.getIterator(); iter.hasMoreResources(); ) {
            Resource next = iter.nextResource();
            list.add(next.getContent().toString());
View Full Code Here


    private void storeRemoveDocs(String collectionName) {
        try {
            storeDocs(collectionName);

            XQueryService xqs = (XQueryService) test.getService("XQueryService", "1.0");
            ResourceSet result = xqs.query("//SPEECH[ft:query(LINE, 'king')]");
            assertEquals(98, result.getSize());
            result = xqs.query("//SPEECH[ft:query(SPEAKER, 'juliet')]");
            assertEquals(118, result.getSize());

            String[] resources = test.listResources();
View Full Code Here

            storeDocs(collectionName);

            XQueryService xqs = (XQueryService) test.getService("XQueryService", "1.0");
            ResourceSet result = xqs.query("//SPEECH[ft:query(LINE, 'king')]");
            assertEquals(98, result.getSize());
            result = xqs.query("//SPEECH[ft:query(SPEAKER, 'juliet')]");
            assertEquals(118, result.getSize());

            String[] resources = test.listResources();
            for (int i = 0; i < resources.length; i++) {
                Resource resource = test.getResource(resources[i]);
View Full Code Here

            String[] resources = test.listResources();
            for (int i = 0; i < resources.length; i++) {
                Resource resource = test.getResource(resources[i]);
                test.removeResource(resource);
            }
            result = xqs.query("//SPEECH[ft:query(LINE, 'king')]");
            assertEquals(0, result.getSize());
            result = xqs.query("//SPEECH[ft:query(SPEAKER, 'juliet')]");
            assertEquals(0, result.getSize());
        } catch (XMLDBException e) {
            e.printStackTrace();
View Full Code Here

                Resource resource = test.getResource(resources[i]);
                test.removeResource(resource);
            }
            result = xqs.query("//SPEECH[ft:query(LINE, 'king')]");
            assertEquals(0, result.getSize());
            result = xqs.query("//SPEECH[ft:query(SPEAKER, 'juliet')]");
            assertEquals(0, result.getSize());
        } catch (XMLDBException e) {
            e.printStackTrace();
            fail(e.getMessage());
        }
View Full Code Here

    private void xupdateDocs(String collectionName) {
        try {
            storeDocs(collectionName);

            XQueryService xqs = (XQueryService) test.getService("XQueryService", "1.0");
            ResourceSet result = xqs.query("//SPEECH[ft:query(SPEAKER, 'juliet')]");
            assertEquals(118, result.getSize());

            String xupdate =
                LuceneIndexTest.XUPDATE_START +
                "   <xu:remove select=\"//SPEECH[ft:query(SPEAKER, 'juliet')]\"/>" +
View Full Code Here

                "   <xu:remove select=\"//SPEECH[ft:query(SPEAKER, 'juliet')]\"/>" +
                LuceneIndexTest.XUPDATE_END;
            XUpdateQueryService xuqs = (XUpdateQueryService) test.getService("XUpdateQueryService", "1.0");
            xuqs.update(xupdate);

            result = xqs.query("//SPEECH[ft:query(SPEAKER, 'juliet')]");
            assertEquals(0, result.getSize());
            result = xqs.query("//SPEECH[ft:query(LINE, 'king')]");
            assertEquals(98, result.getSize());
        } catch (XMLDBException e) {
            e.printStackTrace();
View Full Code Here

            XUpdateQueryService xuqs = (XUpdateQueryService) test.getService("XUpdateQueryService", "1.0");
            xuqs.update(xupdate);

            result = xqs.query("//SPEECH[ft:query(SPEAKER, 'juliet')]");
            assertEquals(0, result.getSize());
            result = xqs.query("//SPEECH[ft:query(LINE, 'king')]");
            assertEquals(98, result.getSize());
        } catch (XMLDBException e) {
            e.printStackTrace();
            fail(e.getMessage());
        }
View Full Code Here

        if (getParent().getNamespaces() != null) {
          for (Map.Entry<String, String> entry : getParent().getNamespaces().entrySet()) {
            service.setNamespace(entry.getKey(), entry.getValue());
          }
        }
        ResourceSet result = service.query(forceOptimize ? OPTIMIZE + query : query);
        lastResult = (int) result.getSize();
        if (retrieve) {
            for (ResourceIterator i = result.getIterator(); i.hasMoreResources(); ) {
                Resource r = i.nextResource();
                LOG.debug(r.getContent());
View Full Code Here

  }

  private static void doQuery(Collection collection, String query) throws XMLDBException {
    XQueryService service = (XQueryService)
      collection.getService("XQueryService", "1.0");
    ResourceSet result = service.query(query);
    System.out.println("Found " + result.getSize() + " results.");
    for(ResourceIterator i = result.getIterator(); i.hasMoreResources(); ) {
      System.out.println(i.nextResource().getContent());
    }
  }
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.