Package nu.xom

Examples of nu.xom.Document.toXML()


      throws ParsingException, IOException {
       
        Document doc = builder.build(new File(inputDir, "`file.xml"));
        String expectedResult = "<?xml version=\"1.0\"?>\n"
            + "<data />\n";
        String actual = doc.toXML();
        assertEquals(expectedResult, actual);
        assertTrue(doc.getBaseURI().startsWith("file:/"));
        assertTrue(doc.getBaseURI().endsWith("data/%"
          + Integer.toHexString('`') + "file.xml"));
       
View Full Code Here


        XMLFilter filter = new WarningFilter();
        filter.setParent(parser);
        Builder builder = new Builder(filter);
       
        Document doc = builder.build("<data/>", null);
        assertEquals("<?xml version=\"1.0\"?>\n<data />\n", doc.toXML());
       
    }
   
   
    private static class WarningFilter extends XMLFilterImpl {
View Full Code Here

          + "%xx;\n"
          + "]>\n"
          + "<test>This sample shows a &tricky; method.</test>\n";
       
        Document doc = builder.build(data, null);
        String s = doc.toXML();
        Document roundTrip = builder.build(s, null);
        assertEquals(doc, roundTrip);
       
    }
   
View Full Code Here

        String data = "<!DOCTYPE attributes  [\n"
          + "<!ATTLIST attributes nmtokens NMTOKENS #IMPLIED>]>\n"
          + "<attributes nmtokens =  \" this&#x0d;&#x0a; also  gets&#x20; normalized \" />";
       
        Document doc = builder.build(data, null);
        String s = doc.toXML();
        Document roundTrip = builder.build(s, null);
        assertEquals(doc, roundTrip);
       
    }
   
View Full Code Here

            Document doc = parser.build(args[0]);
         
            strip(doc.getRootElement());
         

            System.out.println(doc.toXML());
        }
        catch (ParsingException ex) {
          System.out.println(args[0] + " is not well-formed.");
          System.out.println(ex.getMessage());
        }
View Full Code Here

        // Read the entire document into memory
        Document document = builder.build(args[i]);
      
        processElement(document.getRootElement());
       
        System.out.println(document.toXML());        
      }
      catch (ParsingException ex) {
        System.err.println(ex);
        continue;
      }
View Full Code Here

            }
            else {
                System.out.println(args[0] + " does not appear to be an XHTML document");
                return;  
            }
            System.out.println(doc.toXML());
        }
        catch (ParsingException ex) {
          System.out.println(args[0] + " is not well-formed.");
        }
        catch (IOException ex) {
View Full Code Here

       
        String data = "<?xml version=\"1.0\"?>\n"
          + "<!DOCTYPE root [\n  <!ELEMENT test (#PCDATA)>\n]>"
          + "\n<test />\n"
        Document doc = (new Builder()).build(data, null);
        String result = doc.toXML();
        assertEquals(data, result);   
       
   
   
   
View Full Code Here

          + "<!DOCTYPE root [\n" +
                "  <!--comment-->\n  <!ELEMENT test (#PCDATA)>" +
            "\n  <!--comment-->\n]>"
          + "\n<test />\n"
        Document doc = (new Builder()).build(data, null);
        String result = doc.toXML();
        assertEquals(data, result);   
       
   
   
   
View Full Code Here

            "\n  <!--comment-->\n]>"
          + "\n<test />\n"
        XMLFilter filter = new XMLFilterImpl();
        filter.setParent(XMLReaderFactory.createXMLReader("org.apache.xerces.parsers.SAXParser"));
        Document doc = (new Builder(filter)).build(data, null);
        String result = doc.toXML();
        assertEquals(data, result);   
       
   
   
   
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.