Package org.apache.xindice.core.data

Examples of org.apache.xindice.core.data.NodeSet


        }

        assertTrue(collection.getFiler().getRecordCount() == iterations);

        XPathQueryResolver service = new XPathQueryResolver();
        NodeSet result = service.query(collection, "//test1[starts-with(., '8')]", null, null);
        int count = 0;
        while (result.hasMoreNodes()) {
            result.getNextNode();
            count++;
        }

        assertEquals(1, count);

        result = service.query(collection, "//test1[. < '8' or . > '8']", null, null);
        count = 0;
        while (result.hasMoreNodes()) {
            result.getNextNode();
            count++;
        }

        assertEquals(9, count);
    }
View Full Code Here


        resolver = new XPathQueryResolver();
    }

    public void testElementXPathQuery() throws Exception {
        for (int i = 0; i < ELEMENT_QUERY.length; i++) {
            NodeSet nodeSet = resolver.query(col, ELEMENT_QUERY[i], null, null);
            int results = 0;
            Element element = null;
            while(nodeSet.hasMoreNodes()) {
                element = (Element)nodeSet.getNextNode();
                assertNotNull("NodeSet.getNextNode must be not null", element);
                results++;
            }

            assertEquals("Results count", ELEMENT_COUNT[i], results);
View Full Code Here

        }
    }

    public void testNumberXPathQuery() throws Exception {
        for (int i = 0; i < NUMBER_QUERY.length; i++) {
            NodeSet nodeSet = resolver.query(col, NUMBER_QUERY[i], null, null);
            assertTrue("Expected one result", nodeSet.hasMoreNodes());
            Text element = (Text)nodeSet.getNextNode();
            assertNotNull("NodeSet.getNextNode must be not null", element);
            assertEquals("Result value", new Double(NUMBER_VALUE[i]).toString(), element.getNodeValue());
        }
    }
View Full Code Here

        }
    }

    public void testTextXPathQuery() throws Exception {
        for (int i = 0; i < TEXT_QUERY.length; i++) {
            NodeSet nodeSet = resolver.query(col, TEXT_QUERY[i], null, null);
            int results = 0;
            Text element = null;
            while(nodeSet.hasMoreNodes()) {
                element = (Text)nodeSet.getNextNode();
                assertNotNull("NodeSet.getNextNode must be not null", element);
                results++;
            }

            assertEquals("Results count for " + TEXT_QUERY[i], TEXT_COUNT[i], results);
View Full Code Here

    }

  public void testComplexXPathQuery() throws Exception {
    Object node = null;
    XPathQueryResolver queryResolv = new XPathQueryResolver();
    NodeSet nodeSet =
      queryResolv.query(
        col,
        "/terrainmap[coordinates/top-left/latlong/latitude[(number(text()) + 180) >= 0] and coordinates/top-left/latlong/longitude[(number(text()) + 90) <= 0] and coordinates/bottom-right/latlong/latitude[(number(text()) + 180) <= 0] and coordinates/bottom-right/latlong/longitude[(number(text()) + 90) >= 0]]",
        null,
        null);
    if (nodeSet.hasMoreNodes()) {
      node = nodeSet.getNextNode();
    }
    assertNotNull("Complex query didn't return a node", node);
  }
View Full Code Here

        collection.insertDocument("document", document);
        collection.insertBinary("binary", binary);

        XPathQueryResolver service = new XPathQueryResolver();
        NodeSet resultSet = service.query(collection, "/test", null, null);

        int resultCount = 0;
        while (resultSet.hasMoreNodes()) {
            resultSet.getNextNode();
            resultCount++;
        }

        assertEquals(1, resultCount);
    }
View Full Code Here

    /* see superclass for documentation */
    public ResourceSet query(String name, String queryLang, String query, Hashtable nsMap) throws XMLDBException {

        checkOpen();
        try {
            NodeSet nodeSet;
            if (name != null) {
                nodeSet = col.queryDocument(queryLang, query, QueryUtil.mapNamespaces(nsMap), name);
            } else {
                nodeSet = col.queryCollection(queryLang, query, QueryUtil.mapNamespaces(nsMap));
            }
View Full Code Here

    /* see superclass for documentation */
    public ResourceSet query(String name, String queryLang, String query, Hashtable nsMap) throws XMLDBException {

        checkOpen();
        try {
            NodeSet nodeSet;
            if (name != null) {
                nodeSet = col.queryDocument(queryLang, query, QueryUtil.mapNamespaces(nsMap), name);
            } else {
                nodeSet = col.queryCollection(queryLang, query, QueryUtil.mapNamespaces(nsMap));
            }
View Full Code Here

        }

        Collection col = getCollection((String) message.get(COLLECTION));
        NamespaceMap nsMap = QueryUtil.mapNamespaces((Hashtable) message.get(NAMESPACES));

        NodeSet ns;
        if (message.containsKey(NAME)) {
            ns = col.queryDocument(type, query, nsMap, message.get(NAME));
        } else {
            ns = col.queryCollection(type, query, nsMap);
        }
View Full Code Here

                // If we found an XPath selector we need to execute the commands,
                // but we can not execute xupdate variables again.
                // all variables start with a '$'
                if (selector != null && !selector.startsWith("$")) {
                    NodeSet ns = col.queryCollection("XPath", selector, nsMap);
                    while (ns != null && ns.hasMoreNodes()) {
                        DBNode node = (DBNode) ns.getNextNode();
                        Document doc = node.getOwnerDocument();
                        NodeSource source = node.getSource();

                        if (docsUpdated.containsKey(source.getKey())) {
                            continue; // We only have to process it once
View Full Code Here

TOP

Related Classes of org.apache.xindice.core.data.NodeSet

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.