Examples of Nodes


Examples of nu.xom.Nodes

        }
        ParentNode parent = elem.getParent();
        if (parent == null) throwTamperedWithParent();
        currents[i] = parent; // recurse up
       
        Nodes nodes = receivers[i].finishMakingElement(elem);
        if (nodes.size()==1 && nodes.get(0)==elem) { // same node? (common case)
          if (parent instanceof Document) hasRootElement[i] = true;
          continue; // optimization: no need to remove and then readd same element
        }

        if (parent.getChildCount()-1 < 0) throwTamperedWithParent();       
        if (parent instanceof Element) { // can't remove root element
          parent.removeChild(parent.getChildCount()-1);
        }
        appendNodes(parent, nodes, i);
      } catch (RuntimeException e) {
        onException(i, e);
      }
    }
   
    if (unused.getParent() instanceof Document) {
      return new Nodes(unused); // XOM documents must have a root element
    }
    return NONE;
  }
View Full Code Here

Examples of nu.xom.Nodes

  public Nodes makeAttribute(String qname, String namespaceURI, String value, Attribute.Type type) {
    for (int i=0; i < receivers.length; i++) {
      if (exceptions[i] != null) continue; // ignore failed factory
      if (!addAttributesAndNamespaces[i]) continue;
      try {
        Nodes nodes = receivers[i].makeAttribute(
            qname, namespaceURI, value, type);
        appendNodes(currents[i], nodes, i);
      } catch (RuntimeException e) {
        onException(i, e);
      }
View Full Code Here

Examples of nu.xom.Nodes

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

Examples of nu.xom.Nodes

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

Examples of nu.xom.Nodes

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

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

Examples of nu.xom.Nodes

    } 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

Examples of nu.xom.Nodes

   
    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

Examples of nu.xom.Nodes

        // 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

Examples of nu.xom.Nodes

        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
TOP
Copyright © 2018 www.massapi.com. 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.