Package org.xmldb.api.modules

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


        queryResource(service, "siblings.xml", "(<a/>, <b/>, <c/>)/following-sibling::*", 0);

        service.setProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
        service.setProperty(OutputKeys.INDENT, "no");
        ResourceSet rs = service.query("let $doc := <doc><div id='1'><div id='2'/></div><div id='3'/></doc> " +
                "return $doc/div[1]/following-sibling::div");
        assertEquals(1, rs.getSize());
        assertXMLEqual("<div id='3'/>", rs.getResource(0).getContent().toString());

        service.setProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
View Full Code Here


        assertEquals(1, rs.getSize());
        assertXMLEqual("<div id='3'/>", rs.getResource(0).getContent().toString());

        service.setProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
        service.setProperty(OutputKeys.INDENT, "no");
        rs = service.query("let $doc := <doc><div id='1'/><div id='2'><div id='3'/></div><div id='4'/><div id='5'><div id='6'/></div></doc> " +
                "return $doc/div/preceding-sibling::div");
        assertEquals(3, rs.getSize());
        assertXMLEqual("<div id='1'/>", rs.getResource(0).getContent().toString());
        assertXMLEqual("<div id='2'><div id='3'/></div>", rs.getResource(1).getContent().toString());
        assertXMLEqual("<div id='4'/>", rs.getResource(2).getContent().toString());
View Full Code Here

    @Test
    public void predicates_bug1460610() throws XMLDBException {
        final String xQuery = "(1, 2, 3)[ . lt 3]";
       
        final XQueryService service = getQueryService();
        final ResourceSet rs = service.query(xQuery);
       
        assertEquals("SFBUG 1460610 nr of results", 2, rs.getSize());
        assertEquals("SFBUG 1460610 1st result", "1",
                rs.getResource(0).getContent().toString());
        assertEquals("SFBUG 1460610 2nd result", "2",
View Full Code Here

    @Test
    public void predicates_bug1537355() throws XMLDBException {
        final String xQuery = "let $one := 1 return (1, 2, 3)[$one + 1]";
       
        final XQueryService service = getQueryService();
        final ResourceSet rs = service.query(xQuery);
       
        assertEquals("SFBUG 1537355 nr of results", 1, rs.getSize());
        assertEquals("SFBUG 1537355 result", "2",
                rs.getResource(0).getContent().toString());
    }
View Full Code Here

          "</objects> " +
          "let $matches := $doc/detail[source[dynamic='false'] or class] " +
          "return count($matches) eq 2";
   
      XQueryService service = getQueryService();
      ResourceSet rs = service.query(xQuery);
     
      assertEquals(1, rs.getSize());
      assertEquals("true", rs.getResource(0).getContent().toString());

      xQuery = "let $xml := <test><element>" +
View Full Code Here

          "return $xml//element[complexType/attribute[@name eq \"design\"]/@fixed eq \"1\"]";

      service = getQueryService();
        service.setProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
        service.setProperty(OutputKeys.INDENT, "no");     
      rs = service.query(xQuery);

      assertEquals(1, rs.getSize());
      assertXMLEqual("<element><complexType><attribute name=\"design\" fixed=\"1\"/></complexType></element>",
          rs.getResource(0).getContent().toString());
View Full Code Here

        XQueryService service = getQueryService();
        ResourceSet rs=null;
       
        // test one
        final String xQuery1 = "let $q := <q><t>eXist</t></q> return $q//t";
        rs = service.query(xQuery1);
        assertEquals("nr of results", 1, rs.getSize());
        assertEquals("result", "<t>eXist</t>",
                rs.getResource(0).getContent().toString());
       
        // test two
View Full Code Here

        assertEquals("result", "<t>eXist</t>",
                rs.getResource(0).getContent().toString());
       
        // test two
        final String xQuery2 = "let $q := <q><t>eXist</t></q> return ($q//t)[1]";
        rs = service.query(xQuery2);
        assertEquals("nr of results", 1, rs.getSize());
        assertEquals("result", "<t>eXist</t>",
                rs.getResource(0).getContent().toString());
       
        // This one fails http://sourceforge.net/tracker/index.php?func=detail&aid=1488303&group_id=17691&atid=117691
View Full Code Here

        assertEquals("result", "<t>eXist</t>",
                rs.getResource(0).getContent().toString());
       
        // This one fails http://sourceforge.net/tracker/index.php?func=detail&aid=1488303&group_id=17691&atid=117691
        final String xQuery3 = "let $q := <q><t>eXist</t></q> return $q//t[1]";
        rs = service.query(xQuery3);
        assertEquals("SFBUG 1488303 nr of results", 1, rs.getSize());
        assertEquals("SFBUG 1488303 result", "<t>eXist</t>",
                rs.getResource(0).getContent().toString());
    }
View Full Code Here

    public void descendantOrSelf_bug1460791() throws XMLDBException {
        final String xQuery = "declare option exist:serialize \"method=xml indent=no\"; let $test:=<z><a>aaa</a><z>zzz</z></z> "
                +"return ( <one>{$test//z}</one>, <two>{$test/descendant-or-self::node()/child::z}</two> )";
       
        final XQueryService service = getQueryService();
        final ResourceSet rs = service.query(xQuery);
       
        System.out.println("BUG1460791/1" + rs.getResource(0).getContent().toString() );
        System.out.println("BUG1460791/2" + rs.getResource(1).getContent().toString() );
       
        assertEquals("SFBUG 1460791 nr of results", 2, rs.getSize());
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.