Package org.xmldb.api.base

Examples of org.xmldb.api.base.ResourceSet


            xpath = "/person[address/@type='home' and address/text() = '" + searchstring + "' ]" ;
         } else if ( searchtype.equals("workaddress")) {
            xpath = "/person[address/@type='work' and address/text() = '" + searchstring + "' ]" ;
         }
        
         ResourceSet resultSet = service.query(xpath);
         ResourceIterator results = resultSet.getIterator();
        
         Group group = (Group)session.getAttribute("group");
        
         // Clear out group object...
         group.removeAll();
View Full Code Here


         XPathQueryService service = (XPathQueryService)col.getService("XPathQueryService",XMLDBAPIVERSION);
        
         // Get the seach parameters from the form
         String searchstring = request.getParameter("SEARCHSTRING");
        
         ResourceSet resultSet = service.query(searchstring);
         ResourceIterator results = resultSet.getIterator();
        
         Group group = (Group)session.getAttribute("group");
        
         // Clear out group object...
         group.removeAll();
View Full Code Here

         col = getCollection(request,response);
  
         XPathQueryService service = (XPathQueryService)col.getService("XPathQueryService",XMLDBAPIVERSION);
  
         // Get all Person elements from the database
         ResourceSet resultSet = service.query("/person");
         ResourceIterator results = resultSet.getIterator();
        
         // Clear out group object...
         group.removeAll();
        
         // Add results of the Xpath query to the Group instance
View Full Code Here

    }

    public void testLesserSearchQuery() throws Exception {
        String query = "//person[age < 25]";

        ResourceSet resultSet = xpathservice.query(query);
        assertEquals(1, resultSet.getSize());

        Document result0 = (Document)((XMLResource) resultSet.getResource(0)).getContentAsDOM();
        assertEquals("person", result0.getDocumentElement().getNodeName());
    }
View Full Code Here

        String query = "//h:person[h:first='Sally' and h:last='Smith']/h:first";

        xpathservice.setNamespace("h", "http://example.net/person");

        ResourceSet resultSet = xpathservice.query(query);
        assertEquals(1, resultSet.getSize());

        XMLResource resource = (XMLResource) resultSet.getResource(0);

        // ensure that the resource has the correct doc id.
        assertEquals("doc3", resource.getDocumentId());

        Node node = resource.getContentAsDOM();
View Full Code Here


    public void testFetchSingleTextNode() throws Exception {
        String query = "//person[first='John' and last='Smith']/first/text()";

        ResourceSet resultSet = xpathservice.query(query);
        assertEquals(1L, resultSet.getSize());

        Node result = ((XMLResource) resultSet.getResource(0)).getContentAsDOM();
        assertEquals(Node.TEXT_NODE, result.getChildNodes().item(0).getChildNodes().item(0).getNodeType());
        assertEquals("John", result.getChildNodes().item(0).getChildNodes().item(0).getNodeValue());
    }
View Full Code Here

    }

    public void testFetchMultipleTextNodes() throws Exception {
        String query = "//person/first/text()";

        ResourceSet resultSet = xpathservice.query(query);
        assertEquals(2, resultSet.getSize());

        Node result0 = ((XMLResource) resultSet.getResource(0)).getContentAsDOM();
        Node result1 = ((XMLResource) resultSet.getResource(1)).getContentAsDOM();
        assertEquals(Node.TEXT_NODE, result0.getChildNodes().item(0).getChildNodes().item(0).getNodeType());
        assertEquals(Node.TEXT_NODE, result1.getChildNodes().item(0).getChildNodes().item(0).getNodeType());
        assertEquals("John", result0.getChildNodes().item(0).getChildNodes().item(0).getNodeValue());
        assertEquals("Sally", result1.getChildNodes().item(0).getChildNodes().item(0).getNodeValue());
    }
View Full Code Here

        client.insertDocument(TEST_COLLECTION_PATH, "doc3", document3);

        try {
            String query = "//foo/@bar";

            ResourceSet resultSet = xpathservice.query(query);
            assertEquals(1L, resultSet.getSize());

            Node result = ((XMLResource) resultSet.getResource(0)).getContentAsDOM();
            assertEquals("foo", result.getChildNodes().item(0).getAttributes().getNamedItem("bar").getNodeValue());
        } finally {
            client.removeDocument(TEST_COLLECTION_PATH, "doc3");
        }
    }
View Full Code Here

        client.insertDocument(TEST_COLLECTION_PATH, "doc3", document3);

        try {
            String query = "//@bar";

            ResourceSet resultSet = xpathservice.query(query);
            assertEquals(2, resultSet.getSize());

            Node result0 = ((XMLResource) resultSet.getResource(0)).getContentAsDOM();
            Node result1 = ((XMLResource) resultSet.getResource(1)).getContentAsDOM();
            assertEquals("foo", result0.getChildNodes().item(0).getAttributes().getNamedItem("bar").getNodeValue());
            assertEquals("bar", result1.getChildNodes().item(0).getAttributes().getNamedItem("bar").getNodeValue());
        } finally {
            client.removeDocument(TEST_COLLECTION_PATH, "doc3");
        }
View Full Code Here

    }

    public void testFetchCommentNode() throws Exception {
        String query = "//person/comment()[contains(., 'John')]";

        ResourceSet resultSet = xpathservice.query(query);
        assertEquals(1, resultSet.getSize());

        Node result = ((XMLResource) resultSet.getResource(0)).getContentAsDOM();
        assertEquals(" John Smith ", result.getChildNodes().item(0).getChildNodes().item(0).getNodeValue());
    }
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.