Package nu.xom

Examples of nu.xom.Nodes


  /** {@inheritDoc} */
  public Nodes makeText(String text) {
    for (int i=0; i < receivers.length; i++) {
      if (exceptions[i] != null) continue; // ignore failed factory
      try {
        Nodes nodes = receivers[i].makeText(text);
        appendNodes(currents[i], nodes, i);
      } catch (RuntimeException e) {
        onException(i, e);
      }
    }
View Full Code Here


    } else {
      // otherwise it refers to a file containing the query string
      xquery = XQueryPool.GLOBAL_POOL.getXQuery(new File(query));
    }
   
    Nodes results = xquery.execute(doc).toNodes();
   
    for (int j=0; j < results.size(); j++) {
      boolean prettyPrint = true;
      if (prettyPrint)
        System.out.println(XOMUtil.toPrettyXML(results.get(j)));
      else
        System.out.println(results.get(j).toXML());
    }
  }
View Full Code Here

   
    Analyzer textAnalyzer = PatternAnalyzer.DEFAULT_ANALYZER;
    Analyzer queryAnalyzer = PatternAnalyzer.DEFAULT_ANALYZER;
   
    String field = "f";
    Nodes lines = XQueryUtil.xquery(doc, path);
    System.out.println("lines=" + lines.size());
    MemoryIndex[] indexes = new MemoryIndex[lines.size()];
    for (int i=0; i < lines.size(); i++) {
      indexes[i] = new MemoryIndex();
      indexes[i].addField(field, lines.get(i).getValue(), textAnalyzer);
    }
    doc = null;   // help gc
    lines = null; // help gc
   
    Query query = new QueryParser(field, queryAnalyzer).parse(queryExpr);
View Full Code Here

        // declare variable $foo as node() external;
        // or
        // declare variable $foo as node()* external;
      }
      else if (value instanceof Nodes) {
        Nodes nodes = (Nodes) value;
        int size = nodes.size();
        ArrayList sources = new ArrayList(size);
        for (int i = 0; i < size; i++) {
          sources.add(wrap(nodes.get(i), docWrappers));
        }
        value = sources;
      }
      else if (value instanceof Node[]) {
        Node[] nodes = (Node[]) value;
View Full Code Here

        Element child3 = new Element("child3");
        parent.appendChild(child1);
        parent.appendChild(child2);
        parent.appendChild(child3);
       
        Nodes result = child1.query("preceding-sibling::*");
        assertEquals(0, result.size());  
        result = child2.query("preceding-sibling::*");
        assertEquals(1, result.size());  
        assertEquals(child1, result.get(0));  
        result = child3.query("preceding-sibling::*");
        assertEquals(2, result.size());   
       
    }
View Full Code Here

        Attribute a3 = new Attribute("a3", "value");
        child2.addAttribute(a1);
        child2.addAttribute(a2);
        child2.addAttribute(a3);
       
        Nodes result = a2.query("preceding-sibling::node()");
        assertEquals(0, result.size());  
        result = a2.query("following-sibling::node()");
        assertEquals(0, result.size());   
       
    }
View Full Code Here

       
        parent.appendChild(child1);
        parent.appendChild(child2);
        parent.appendChild(child3);
       
        Nodes result = parent.query("id('anchor')");
        assertEquals(1, result.size());    
        assertEquals(child2, result.get(0));
       
    }
View Full Code Here

        parent.appendChild(child1);
        parent.appendChild(child2);
        parent.appendChild(child3);
        Document doc = new Document(parent);
       
        Nodes result = doc.query("id('anchor')");
        assertEquals(1, result.size());    
        assertEquals(child2, result.get(0));
       
    }
View Full Code Here

       
        parent.appendChild(child1);
        parent.appendChild(child2);
        parent.appendChild(child3);
       
        Nodes result = parent.query("id('anchor')");
        assertEquals(0, result.size());
       
    }
View Full Code Here

       
        parent.appendChild(child1);
        parent.appendChild(child2);
        parent.appendChild(child3);
       
        Nodes result = text.query("id('anchor')");
        assertEquals(1, result.size());    
        assertEquals(child2, result.get(0));
       
    }
View Full Code Here

TOP

Related Classes of nu.xom.Nodes

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.