Package org.xmldb.api.base

Examples of org.xmldb.api.base.ResourceSet


                    +" $categories/category[1], "
                    +" $categories/category[position() eq 1]";

            XPathQueryService service = (XPathQueryService)
                    getTestCollection().getService("XPathQueryService", "1.0");
            ResourceSet result = service.query(query);

            assertEquals(2, result.getSize());
            assertEquals(query,
                    result.getResource(0).getContent().toString(), "<category uid=\"1\">Fruit</category>");
            assertEquals(query,
                    result.getResource(1).getContent().toString(), "<category uid=\"1\">Fruit</category>");

        } catch (XMLDBException ex) {
            // should not yield into exception
            ex.printStackTrace();
            fail(ex.toString());
View Full Code Here


                    +"(: note that these should be the same *by definition* :) "
                    +")";

            XPathQueryService service = (XPathQueryService)
                    getTestCollection().getService("XPathQueryService", "1.0");
            ResourceSet result = service.query(query);

            assertEquals(2, result.getSize());
            assertEquals(query,
                    result.getResource(0).getContent().toString(), "<one><z> zzz </z></one>");
            assertEquals(query,
                    result.getResource(1).getContent().toString(), "<two><z> zzz </z></two>");

        } catch (XMLDBException ex) {
            // should not yield into exception
            ex.printStackTrace();
            fail(ex.toString());
View Full Code Here

            fail(ex.toString());
        }
    }

    public void testAttributesSerialization() {
        ResourceSet result;
        String query;
        try {
            XPathQueryService service =
                    storeXMLStringAndGetQueryService(attributesSERIALIZATION, attributes);
           
            query = "//@* \n";
            try {
              result = service.query(query);
            } catch (Exception e) {
              //SENR0001 : OK
              System.out.println(e.getMessage());
            }
            query = "declare option exist:serialize 'method=text'; \n"
              + "//@* \n";
            result = service.query(query);
            assertEquals("XQuery: " + query, 3, result.getSize());
        } catch (XMLDBException e) {
            fail(e.getMessage());
        }
    }
View Full Code Here

        // OK
        try {
            String query = "declare namespace xf = \"http://a\"; " + "declare option exist:serialize 'indent=no';" + "<html xmlns=\"http://b\"><xf:model><xf:instance xmlns=\"\"/></xf:model></html>";

            XPathQueryService service = (XPathQueryService) getTestCollection().getService("XPathQueryService", "1.0");
            ResourceSet result = service.query(query);

            assertEquals(1, result.getSize());
            assertEquals(query, "<html xmlns=\"http://b\"><xf:model xmlns:xf=\"http://a\">" + "<xf:instance xmlns=\"\"/></xf:model></html>",
                    result.getResource(0).getContent().toString());
        } catch (XMLDBException ex) {
            ex.printStackTrace();
            fail(ex.toString());
        }
    }
View Full Code Here

        try {
            String query = "let $docs := <Document/> return $docs[a[1] = 'b']";

            XPathQueryService service = (XPathQueryService) getTestCollection().getService("XPathQueryService", "1.0");
            ResourceSet result = service.query(query);

            assertEquals(0, result.getSize());

        } catch (XMLDBException ex) {
            ex.printStackTrace();
            fail(ex.toString());
        }

        try {
            String query = "<a/>[() = 'b']";

            XPathQueryService service = (XPathQueryService) getTestCollection().getService("XPathQueryService", "1.0");
            ResourceSet result = service.query(query);

            assertEquals(0, result.getSize());

        } catch (XMLDBException ex) {
            ex.printStackTrace();
            fail(ex.toString());
        }
View Full Code Here

                    "<a><b>Foo</b></a>" +
                    "<c>{local:table()}</c>" +
                    "</foobar>";

            XPathQueryService service = (XPathQueryService) getTestCollection().getService("XPathQueryService", "1.0");
            ResourceSet result = service.query(query);

            assertEquals(1, result.getSize());
            assertEquals(query,
                    "<foobar xmlns=\"http://www.w3.org/1999/xhtml\">" +
                    "<a><b>Foo</b></a>" +
                    "<c><d xmlns=\"\">Bar</d></c>" +
                    "</foobar>", result.getResource(0).getContent().toString());


        } catch (XMLDBException ex) {
            ex.printStackTrace();
            fail(ex.toString());
View Full Code Here

        // OK
        try {
            String query = "empty( ()/string() )";

            XPathQueryService service = (XPathQueryService) getTestCollection().getService("XPathQueryService", "1.0");
            ResourceSet result = service.query(query);

            assertEquals(1, result.getSize());
            assertEquals(query, "true",
                    result.getResource(0).getContent().toString());
        } catch (XMLDBException ex) {
            ex.printStackTrace();
            fail(ex.toString());
        }
    }
View Full Code Here

   
    XPathQueryServiceImpl service = (XPathQueryServiceImpl)
      col.getService("XPathQueryService", "1.0");
   
//    service.beginProtected();
    ResourceSet result = service.query(xquery);

    System.out.println(Thread.currentThread().getName() + ": found " + result.getSize());
   
    DefaultHandler handler = new DefaultHandler();
    for (int i = 0; i < result.getSize(); i++) {
      XMLResource next = (XMLResource) result.getResource((long)i);
      next.getContentAsSAX(handler);
    }
//    service.endProtected();
   
    runningTime += (System.currentTimeMillis() - start);
View Full Code Here

        // OK
        try {
            String query = "empty( ()/string() )";

            XPathQueryService service = (XPathQueryService) getTestCollection().getService("XPathQueryService", "1.0");
            ResourceSet result = service.query(query);

            assertEquals(1, result.getSize());
            assertEquals(query, "true",
                    result.getResource(0).getContent().toString());
        } catch (XMLDBException ex) {
            ex.printStackTrace();
            fail(ex.toString());
        }

        // NOK
        try {
            String query = "empty( ()/string(.) )";

            XPathQueryService service = (XPathQueryService) getTestCollection().getService("XPathQueryService", "1.0");
            ResourceSet result = service.query(query);

            assertEquals(1, result.getSize());
            assertEquals(query, "true",
                    result.getResource(0).getContent().toString());
        } catch (XMLDBException ex) {
            ex.printStackTrace();
            fail(ex.toString());
        }
    }
View Full Code Here

        // OK
        try {
            String query = "text {\"\"} =\"\"";

            XPathQueryService service = (XPathQueryService) getTestCollection().getService("XPathQueryService", "1.0");
            ResourceSet result = service.query(query);

            assertEquals(1, result.getSize());
            assertEquals(query, "true",
                    result.getResource(0).getContent().toString());
        } catch (XMLDBException ex) {
            ex.printStackTrace();
            fail(ex.toString());
        }
    }
View Full Code Here

TOP

Related Classes of org.xmldb.api.base.ResourceSet

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.