Package org.apache.xindice.core.data

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


            while (keys.hasMoreElements()) {
               String key = (String) keys.nextElement();
               namespaces.put(key, nsMap.get(key));
            }

            NodeSet result;
            if (name != null) {               
               result = col.queryDocument(queryLang, query, namespaces, name);
            }
            else {
               result = col.queryCollection(queryLang, query, namespaces);
            }
           
            ResourceSetImpl rs = new ResourceSetImpl(this, null);

            while (result.hasMoreNodes()) {

               Node n = result.getNextNode();
               if ( n instanceof DBNode ) {
                  ( ( DBNode ) n ).expandSource();
               }

               String documentId = ((Element) n).getAttributeNS(QUERY_NS, "key");
View Full Code Here


      if(!message.containsKey(QUERY)) {
         throw new Exception(MISSING_QUERY_PARAM);
      }

      Collection col = getCollection( (String) message.get(COLLECTION) );
      NodeSet ns = null;

      if (message.containsKey( NAME )) {

         ns = col.queryDocument( (String)message.get(TYPE), (String)message.get(QUERY), mapNamespaces( (Hashtable)message.get(NAMESPACES) ), (String)message.get(NAME) );
View Full Code Here

            attribIndex++;
            String selector = (String) attribs.get("select");

            // If we found an XPath selector we need to execute the commands.
            if (selector != null) {
               NodeSet ns = col.queryCollection("XPath", selector, nsMap);
               Document lastDoc = null;
               while (ns != null && ns.hasMoreNodes()) {
                  DBNode node = (DBNode)ns.getNextNode();
                  Document doc = node.getOwnerDocument();
                 
                  if ( doc == lastDoc )
                     continue; // We only have to process it once
                  else
View Full Code Here

        if (!message.containsKey(QUERY)) {
            throw new Exception(MISSING_QUERY_PARAM);
        }

        Collection col = getCollection((String) message.get(COLLECTION));
        NodeSet ns = null;

        if (message.containsKey(NAME)) {
            ns = col.queryDocument((String) message.get(TYPE),
                                   (String) message.get(QUERY),
                                   mapNamespaces((Hashtable) message.get(NAMESPACES)),
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);
            Double element = null;
            assertTrue("Expected one result", nodeSet.hasMoreNodes());
            element = (Double)nodeSet.getNextNode();
            assertNotNull("NodeSet.getNextNode must be not null", element);
            assertEquals("Result value", new Double(NUMBER_VALUE[i]), element);
        }
    }
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

                attribIndex++;
                String selector = (String) attribs.get("select");

                // If we found an XPath selector we need to execute the commands.
                if (selector != null) {
                    NodeSet ns = col.queryCollection("XPath", selector, nsMap);
                    Document lastDoc = null;
                    while (ns != null && ns.hasMoreNodes()) {
                        DBNode node = (DBNode) ns.getNextNode();
                        Document doc = node.getOwnerDocument();

                        if (doc == lastDoc) {
                            continue; // We only have to process it once
                        } else {
View Full Code Here

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

        checkOpen();
        try {
            NodeSet result;
            if (name != null) {
                result = col.queryDocument(queryLang, query, createNamespaceMap(nsMap), name);
            } else {
                result = col.queryCollection(queryLang, query, createNamespaceMap(nsMap));
            }
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.