Package nu.xom

Examples of nu.xom.Builder


          );
          return;
        }
       
        try {
          Builder parser = new Builder(new StreamingXHTMLQualifier());
          Document doc = parser.build(args[0]);
          Serializer out = new Serializer(System.out);
          out.write(doc);
        }
        catch (ParsingException ex) {
          System.out.println(args[0] + " is not well-formed.");
View Full Code Here


          );
          return;
        }
        
        TreeWalker iterator = new TreeWalker();
        Builder parser = new Builder();
        try {
            // Separate out the basic I/O by parsing document,
            // and then serializing into a byte array. This caches
            // the document and removes any dependence on the DTD.
            Document doc = parser.build(args[0]);
            DocType type = doc.getDocType();
            if (type != null) {
                doc.removeChild(type);  
            }
            ByteArrayOutputStream out = new ByteArrayOutputStream();
View Full Code Here

    if (args.length == 0) {
      System.out.println("Usage: java nu.xom.samples.TreePrinter URL");
      return;
    }
     
    Builder builder = new Builder();
    
    try {
      Document doc = builder.build(args[0]);
      Element root = doc.getRootElement();
      listChildren(root);     
    }
    // indicates a well-formedness error
    catch (ParsingException ex) {
View Full Code Here

          );
          return;
        }
        
        FastReproducer iterator = new FastReproducer();
        Builder parser = new Builder();
        try {
            // Separate out the basic I/O by parsing document,
            // and then serializing into a byte array. This caches
            // the document and removes any dependence on the DTD.
            Document document = parser.build(args[0]);

            long prewalk = System.currentTimeMillis();        
            // Process it starting at the root
            iterator.copy(document);
            long postwalk = System.currentTimeMillis();
View Full Code Here

    if (args.length == 0) {
      System.out.println("Usage: java nu.xom.samples.NodeLister URL");
      return;
    }
     
    Builder builder = new Builder();
    
    try {
      Document doc = builder.build(args[0]);
      Element root = doc.getRootElement();
      listChildren(root, 0);     
    }
    // indicates a well-formedness error
    catch (ParsingException ex) {
View Full Code Here

          );
          return;
        }
        
        Reproducer iterator = new Reproducer();
        Builder parser = new Builder();
        try {
            // Separate out the basic I/O by parsing document,
            // and then serializing into a byte array. This caches
            // the document and removes any dependence on the DTD.
            Document document = parser.build(args[0]);

            long prewalk = System.currentTimeMillis();        
            // Process it starting at the root
            iterator.copy(document);
            long postwalk = System.currentTimeMillis();
View Full Code Here

        Runtime r = Runtime.getRuntime();
        long memory = r.totalMemory() - r.freeMemory();
       
        System.out.println("Initial: " + memory);
       
        Builder builder = new Builder();
        Document dataDoc = builder.build(elementData, "http://www.example.com");
        Element root = new Element("root");
        Document doc = new Document(root);
        Element dataElement = dataDoc.getRootElement();

       
View Full Code Here

          );
          return;
        }
        
        DocumentModifier iterator = new DocumentModifier();
        Builder parser = new Builder();
        try {   
            // Separate out the basic I/O by parsing document,
            // and then serializing into a byte array.
            // This caches the and removes any dependence on the DTD.
            Document doc = parser.build(args[0]);
            DocType type = doc.getDocType();
            if (type != null) {
                doc.removeChild(type);  
            }
            ByteArrayOutputStream out = new ByteArrayOutputStream();
            Serializer serializer = new Serializer(out);
            serializer.write(doc);
            serializer.flush();
            out.close();
            byte[] data = out.toByteArray();
            
            warmup(parser, iterator, data, 5);
            InputStream raw = new BufferedInputStream(
              new ByteArrayInputStream(data)
            );   
           
            // Try to avoid garbage collection pauses    
            System.gc(); System.gc(); System.gc();
           
            long prebuild = System.currentTimeMillis();
         
            // Read the entire document into memory
            Document document = parser.build(raw);
            long postbuild = System.currentTimeMillis();
           
            System.out.println((postbuild - prebuild)
              + "ms to build the document");
View Full Code Here

        + "</zazy>\n";
   
   
    public static void main(String[] args) throws Exception {
               
        Builder builder = new Builder();
        Document dataDoc = builder.build(elementData, "http://www.example.com");
        Element root = new Element("root");
        Document doc = new Document(root);
        Element dataElement = dataDoc.getRootElement();
       
        long pre = System.currentTimeMillis();
View Full Code Here

          System.out.println("Usage: java nu.xom.samples.SourceCodeSerializer URL");
          return;
        }
       
        try {
          Builder parser = new Builder();
          Document doc = parser.build(args[0]);
          Serializer serializer = new SourceCodeSerializer(System.out, "ISO-8859-1");
          serializer.write(doc);
          serializer.flush();
        }
        catch (ParsingException ex) {
View Full Code Here

TOP

Related Classes of nu.xom.Builder

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.