Package org.apache.xindice.core.data

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


        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 col = getCollection((String) message.get(COLLECTION));
        NamespaceMap nsMap = QueryUtil.mapNamespaces((Map) 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

        if(xupdate == null) {
            xupdate = "";
        } else if(xupdate.length() > 0) {
            // do xupdate
            try {
                NodeSet result = col.queryCollection("XUpdate", xupdate, new NamespaceMap());
                printResult(result, output);
            } catch (DBException e) {
                log.error(e);
            }
        }
View Full Code Here

            int index = 0;
            for (int i = 0; i < nsSize; i++) {
                nsMap.setNamespace(ns[index++], ns[index++]);
            }
            try {
                NodeSet result = col.queryCollection("XPath", query, nsMap);
                printQuery(result, output, query, path);
            } catch (DBException e) {
                log.error(e);
                printStartTable("Error while XPath Query", output);
                printStartSingleTableBox(output);
View Full Code Here

    }

    public void testQuery() throws Exception {
        TextQueryResolver res = new TextQueryResolver();

        NodeSet set = res.query(collection, "test1:test", null, null);
        int count = 0;
        while (set.hasMoreNodes()) {
            set.getNextNode();
            count++;
        }
        assertEquals("Number of elements in a result", 3, count);

        collection.remove("key1");
        set = res.query(collection, "test1:test", null, null);

        count = 0;
        while (set.hasMoreNodes()) {
            set.getNextNode();
            count++;
        }
        assertEquals("Number of elements in a result", 2, count);
    }
View Full Code Here

    public void testCompiledQuery() throws Exception {
        TextQueryResolver res = new TextQueryResolver();

        Query query = res.compileQuery(collection, "test1:test", null, null);
        NodeSet set = query.execute();
        int count = 0;
        while (set.hasMoreNodes()) {
            set.getNextNode();
            count++;
        }
        assertEquals("Number of elements in a result", 3, count);
    }
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.