Package nu.xom

Examples of nu.xom.DocType


    }

   
    public void testCanonicalizeDocumentTypeDeclaration() throws IOException {
    
        DocType doctype = new DocType("root", "http://www.example.org");
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        try {
            Canonicalizer serializer = new Canonicalizer(out);
            serializer.write(doctype);
        }
View Full Code Here


                    }
                    catch (AssertionFailedError t) {
                      // If it fails, try it without a doctype in result.
                      // A lot of the test cases have incorrect DOCTYPE
                      // declarations. 
                      DocType doctype = expected.getDocType();
                      DocType actualDoctype = doc.getDocType();
                      if (doctype != null) {
                         expected.removeChild(doctype);
                         assertEquals("Error when processing  "
                          + input, expected, doc);                 
                      }
View Full Code Here

        String name = "sakjdhjhd";
        String uri = "http://www.something.com/";
        Element e = new Element(name, uri);
       
        try {
            e.appendChild(new DocType(name));
            fail("Appended a document type declaration to an element");
        }
        catch (IllegalAddException success) {
            assertNotNull(success.getMessage());
        }
View Full Code Here

       
        serializeParseAndCompare(doc);

        doc.insertChild(new Comment("Hello"), 0);
        serializeParseAndCompare(doc);   
        doc.insertChild(new DocType("root"), 0);
        serializeParseAndCompare(doc);   
        doc.insertChild(new ProcessingInstruction("test", "some data"),
          0);
        serializeParseAndCompare(doc);   
        doc.insertChild(new Comment("Goodbye"), 0);
View Full Code Here

    public void testSerializeDocTypeWithSystemID()
      throws IOException {
       
        Serializer serializer = new Serializer(out);
        Document doc = new Document(new Element("a"));
        doc.setDocType(new DocType("b", "example.dtd"));
        serializer.write(doc);
        String result = out.toString("UTF-8");
        assertTrue(result.endsWith("<a/>\r\n"));
        assertTrue(result.indexOf("<!DOCTYPE b SYSTEM \"example.dtd\">") > 0)
       
View Full Code Here

    public void testSerializeDocTypeWithPublicAndSystemID()
      throws IOException {
       
        Serializer serializer = new Serializer(out);
        Document doc = new Document(new Element("a"));
        doc.setDocType(new DocType("b",
          "-//W3C//DTD XHTML 1.0 Transitional//EN", "example.dtd"));
        serializer.write(doc);
        String result = out.toString("UTF-8");
        assertTrue(result.endsWith("<a/>\r\n"));
        assertTrue(result.indexOf(
View Full Code Here

                    process(f);
                }
                else {
                    try {
                        Document doc = builder.build(f);
                        DocType doctype = new DocType("html",
                          "-//W3C//DTD XHTML 1.0 Frameset//EN",
                          "http://www.w3.org/TR/2000/REC-xhtml1-20000126/DTD/xhtml1-frameset.dtd");
                        doc.setDocType(doctype);
                        Attribute en = new Attribute("lang", "en-US");
                        Attribute xmlen = new Attribute("xml:lang",
View Full Code Here

        return new ProcessingInstruction(pi.getTarget(), pi.getValue());
    }

   
    private Node copy(DocType doctype) {
        return new DocType(
          doctype.getRootElementName(),
          doctype.getPublicID(),
          doctype.getSystemID());
    }
View Full Code Here

        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();
            Serializer serializer = new Serializer(out);
View Full Code Here

            String data = node.getValue();
            lexicalHandler.comment(
              data.toCharArray(), 0, data.length());           
        }
        else if (node instanceof DocType && lexicalHandler != null) {
            DocType type = (DocType) node;
            lexicalHandler.startDTD(type.getRootElementName(),
              type.getPublicID(), type.getSystemID());             
            lexicalHandler.endDTD();         
        }
        // all other types are ignored
       
    }
View Full Code Here

TOP

Related Classes of nu.xom.DocType

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.