Package org.xmldb.api.modules

Examples of org.xmldb.api.modules.XQueryService.query()


 
  public boolean execute() throws Exception {
    Collection col = DatabaseManager.getCollection(collectionPath);
    XQueryService service = (XQueryService) col.getService("XQueryService", "1.0");
   
    service.query(query);
    return false;
  }
}
View Full Code Here


   */
  protected void tearDown() {
    try {
      Collection col = getTestCollection();
      XQueryService service = (XQueryService) col.getService("XQueryService", "1.0");
      ResourceSet result = service.query("distinct-values(//node/@id)");
      assertEquals(result.getSize(), 41);
      for (int i = 0; i < result.getSize(); i++) {
        XMLResource next = (XMLResource) result.getResource((long)i);
        System.out.println(next.getContent());
      }
View Full Code Here

            Resource resource = root.createResource("data.xml", "XMLResource");
            resource.setContent(DOCUMENT_CONTENT);
            root.storeResource(resource);

            XQueryService qs = (XQueryService) root.getService("XQueryService", "1.0");
            ResourceSet result = qs.query("if (doc-available('" + testCollection + "/messages.xml')) then doc('" + testCollection + "/messages.xml')/events/event[@id = 'STORE-DOCUMENT'] else ()");
            assertEquals("No trigger should have fired. Configuration was removed", 0, result.getSize());
        } catch (XMLDBException e) {
            e.printStackTrace();
            fail(e.getMessage());
        }
View Full Code Here

            resource = root.createResource("data.xml", "XMLResource");
            resource.setContent(DOCUMENT_CONTENT);
            root.storeResource(resource);

            XQueryService qs = (XQueryService) root.getService("XQueryService", "1.0");
            ResourceSet result = qs.query("if (doc-available('" + testCollection + "/messages.xml')) then doc('" + testCollection + "/messages.xml')/events/event[@id = 'STORE-DOCUMENT']/string(@collection) else ()");
            assertEquals(1, result.getSize());
            assertEquals(testCollection, result.getResource(0).getContent());
        } catch (XMLDBException e) {
            e.printStackTrace();
            fail(e.getMessage());
View Full Code Here

//          "XPathQueryService",
//          "1.0");
//      ResourceSet result = service.query("//SPEECH[LINE &= 'marriage']");
        final XQueryService service =
                storeXMLStringAndGetQueryService("numbers.xml", numbers);
        final ResourceSet result = service.query("//item/price");

        final Resource r = result.getMembersAsResource();
        final Object rawContent = r.getContent();
        String content = null;
        if(rawContent instanceof File) {
View Full Code Here

    @Test (expected=XMLDBException.class)
    public void manualRelease() throws XMLDBException {
        System.out.println("---manualRelease");
        Collection test = DatabaseManager.getCollection(baseURI + "/db/rpctest", "admin", "");
        XQueryService service = (XQueryService) test.getService("XQueryService", "1.0");
        ResourceSet result = service.query("//chapter[@xml:id = 'chapter1']");
        Assert.assertEquals(1, result.getSize());

        // clear should release the query result on the server
        result.clear();
View Full Code Here

            try {
                Collection test = DatabaseManager.getCollection(baseURI + "/db/rpctest", "admin", "");
                XQueryService service = (XQueryService) test.getService("XQueryService", "1.0");
                int n = random.nextInt(DOC_COUNT) + 1;
                service.declareVariable("n", "chapter" + n);
                ResourceSet result = service.query(query);
                Assert.assertEquals(1, result.getSize());
            } catch (XMLDBException e) {
                e.printStackTrace();
                Assert.fail(e.getMessage());
            }
View Full Code Here

    @Test
    public void getContentAsDOM() throws XMLDBException, TransformerConfigurationException, TransformerException {

        Collection testCollection = DatabaseManager.getCollection(ROOT_URI + "/" + TEST_COLLECTION);
        XQueryService service = (XQueryService) testCollection.getService("XQueryService", "1.0");
        ResourceSet result = service.query(XQUERY);
        for(long i = 0; i < result.getSize(); i++) {
            XMLResource r = (XMLResource) result.getResource(i);

            System.out.println("Output of getContent():");
            System.out.println(r.getContent());
View Full Code Here

  private Collection testCollection;
 
  public void testQueryResults() {
    try {
      XQueryService service = (XQueryService) testCollection.getService("XQueryService", "1.0");
      ResourceSet result = service.query("declare namespace foo=\"http://foo.com\"; //foo:entry");
      Resource resource = result.getMembersAsResource();
      String str = resource.getContent().toString();
      System.out.println(str);
      assertXMLEqual(XML_EXPECTED1, str);
     
View Full Code Here

      String str = resource.getContent().toString();
      System.out.println(str);
      assertXMLEqual(XML_EXPECTED1, str);
     
      //TODO : THIS IS BUGGY !
      result = service.query("declare namespace config='urn:config'; " +
          "declare namespace c='urn:content'; "  +
          "declare variable $config {<config xmlns='urn:config'>123</config>}; " +
          "declare variable $serverConfig {<serverconfig xmlns='urn:config'>123</serverconfig>}; " +
          "<c:Site xmlns='urn:content' xmlns:c='urn:content'> " +
          "{($config,$serverConfig)} " +
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.