Package nu.xom

Examples of nu.xom.Document


        throws UnsupportedEncodingException {
      super(out, encoding);
    }

    public void write(Nodes nodes) throws IOException {
      Document doc = wrapSequence(nodes);
      write(doc);     
    }
View Full Code Here


      int size = nodes.size();
      for (int i=0; i < size; i++) {
        items.appendChild(wrap(nodes.get(i)));
      }
     
      return new Document(items);
    }
View Full Code Here

      // add copy of content to wrapper:
      if (node instanceof Attribute) {
        Attribute attr = (Attribute) node;         
        item.addAttribute((Attribute) attr.copy());
      } else if (node instanceof Document) {
        Document doc = (Document) node;         
        for (int j=0; j < doc.getChildCount(); j++) {
          item.appendChild(doc.getChild(j).copy());
        }
//      } else if (node instanceof Namespace) { // xom >= 1.1 only
//        Namespace ns = (Namespace) node;
////        item.addNamespaceDeclaration(ns.getPrefix(), ns.getValue());
//        if (ns.getPrefix().length() > 0) {
View Full Code Here

          try {
            Builder builder = new Builder();
            int i = 0;
            while (i < files.length) {
              System.out.println("t="+ t + ", index="+i);
              Document doc = builder.build(files[i]);
              Object key = files[i];
              pool.putDocument(key, doc);
              i++;
            }
            System.out.println("done");
View Full Code Here

      int j = k + 10000;
      while (k < j) {
        root.appendChild(new Element("elem" + (k++)));
      }
     
      XQueryUtil.xquery(new Document(root), query);
     
      if (i % 1 == 0) System.out.print(".");
      if (i % 10 == 0) System.out.println("i=" + i);
    }
  }
View Full Code Here

     
      if (input == null && baseURI == null)
        throw new IllegalArgumentException("input and baseURI must not both be null");
      if (input == null) input = baseURI.toURL().openStream();
      try {
        Document doc = XOMUtil.getBinaryXMLCodec().deserialize(input, null);
        if (baseURI != null) doc.setBaseURI(baseURI.toASCIIString());
        return doc;
      } finally {
        input.close(); // do what SAX XML parsers do
      }
    }
View Full Code Here

  public static void main(String[] args) throws Exception {
    new XQueryUpdateTest().run(args);
  }
 
  private void run(String[] args) throws Exception {
    Document doc = new Builder().build(new File("samples/data/articles.xml"));
    System.out.println("input=\n" + XOMUtil.toPrettyXML(doc));
//    update(doc, "//article[@name='chair']", "(. , ., .)", "make copies");
    update(doc, "//node() | //@*", ".", "identity transform");
    update(doc, "//@*", "()", "delete all attributes");
    update(doc, "//article[@name='chair']", "()", "delete all chairs");
View Full Code Here

   
    System.out.println("\nNumber of bugs detected: " + bugs);
  }
   
  private void run(File file) throws Exception {
    Document expected = getBuilder().build(file);
   
    NodeFactory factory = new NodeFactory();
    XMLInputFactory staxFactory = createXMLInputFactory();
    Document actual = StaxUtil.createBuilder(staxFactory, factory).build(file);
   
    IOTestUtil.xomAssertEquals(expected, actual);
    IOTestUtil.canonicalAssertEquals(expected, actual);   
  }
View Full Code Here

   * <pre>
   * java nux.xom.tests.XQueryBenchmark data/romeo.xml 100 data/romeo100.xml
   * </pre>
   */
  public static void generateTestData(String[] args) throws Exception {
    Document doc = new Builder().build(new File(args[0])); // e.g. "romeo.xml"
    int times = Integer.parseInt(args[1]);    // e.g. 100
    Elements children = doc.getRootElement().getChildElements();
    for (int k=0; k < times; k++) {
      for (int i=0; i < children.size(); i++) {
        doc.getRootElement().appendChild(children.get(i).copy());
      }
    }
   
    FileOutputStream out = new FileOutputStream(args[2]); // e.g. "romeo100.xml"
    Serializer ser = new Serializer(out);
View Full Code Here

  }

  private static Document readDocument(String fileName) throws Exception {
    System.out.print("Now reading " + fileName);
    long start = System.currentTimeMillis();
    Document doc;
    if (fileName.endsWith(".bnux")) { // it's a binary xml file
      byte data[] = FileUtil.toByteArray(new FileInputStream(fileName));
      doc = new BinaryXMLCodec().deserialize(data);
    }
    else { // it's a standard textual XML file
View Full Code Here

TOP

Related Classes of nu.xom.Document

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.