Package nu.xom

Examples of nu.xom.DocType


     * @throws XMLException if the DOM <code>DocumentType</code>
     *     is not a well-formed XML document type declaration
     */
    public static DocType convert(org.w3c.dom.DocumentType doctype) {

        DocType result =
            new DocType(
                doctype.getName(),
                doctype.getPublicId(),
                doctype.getSystemId());
        result.setInternalDTDSubset(doctype.getInternalSubset());
       
        return result;

    }
View Full Code Here


      DOMImplementation impl) {

        Element root = document.getRootElement();
        String rootName = root.getQualifiedName();
        String rootNamespace = root.getNamespaceURI();
        DocType doctype = document.getDocType();    
        DocumentType domDOCTYPE = null;
        if (doctype != null) {
            domDOCTYPE = impl.createDocumentType(rootName,
            doctype.getPublicID(), doctype.getSystemID());  
        }     
       
        org.w3c.dom.Document domDoc
         = impl.createDocument(rootNamespace, rootName, domDOCTYPE);
        org.w3c.dom.Element domRoot = domDoc.getDocumentElement();
View Full Code Here

        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        factory.setNamespaceAware(true);
        builder = factory.newDocumentBuilder();
        impl = builder.getDOMImplementation();       

        DocType type = new DocType("test");
        Element root = new Element("test");         
        xomDocument = new Document(root);
        xomDocument.insertChild(type, 0);
        xomDocument.insertChild(new ProcessingInstruction(
         "xml-stylesheet", "href=\"file.css\" type=\"text/css\""), 1);
View Full Code Here

   
    public void testToXOM() {
       
        Document xomDoc = DOMConverter.convert(domDocument);
        DocType doctype = xomDoc.getDocType();
        Element root = xomDoc.getRootElement();

        assertEquals("test", root.getQualifiedName());
        assertEquals("test", root.getLocalName());
        assertEquals("", root.getNamespaceURI());
       
        assertTrue(doctype != null);
        assertTrue(xomDoc.getChild(0) instanceof DocType);
        assertTrue(xomDoc.getChild(4) instanceof nu.xom.Comment);
        assertTrue(xomDoc.getChild(2) instanceof nu.xom.Comment);
        assertEquals(" test ", xomDoc.getChild(2).getValue());
        assertEquals("epilog", xomDoc.getChild(4).getValue());
        assertTrue(
          xomDoc.getChild(1) instanceof nu.xom.ProcessingInstruction);
        assertEquals("test", doctype.getRootElementName());
        assertNull(doctype.getPublicID());
        assertNull(doctype.getSystemID());
      
    }
View Full Code Here

        byte[] data = "<!DOCTYPE root ><element />".getBytes();
        org.w3c.dom.Document doc = builder.parse(new ByteArrayInputStream(data));
         
        org.w3c.dom.DocumentType type = doc.getDoctype();
        DocType xomType = DOMConverter.convert(type);
        assertEquals(type.getName(), xomType.getRootElementName());
                
    }
View Full Code Here

        byte[] data = "<!DOCTYPE root [<!ELEMENT element EMPTY>]><element />".getBytes();
        org.w3c.dom.Document doc = builder.parse(new ByteArrayInputStream(data));
         
        org.w3c.dom.DocumentType type = doc.getDoctype();
        DocType xomType = DOMConverter.convert(type);
        assertEquals(type.getName(), xomType.getRootElementName());
        assertEquals(type.getInternalSubset(), xomType.getInternalDTDSubset());
                
    }
View Full Code Here

        File inputDir = new File("data");
        File f = new File(inputDir, "dtdtest.xhtml");
        org.w3c.dom.Document doc = builder.parse(f);
         
        org.w3c.dom.DocumentType type = doc.getDoctype();
        DocType xomType = DOMConverter.convert(type);
        assertEquals(type.getName(), xomType.getRootElementName());
        assertEquals(type.getSystemId(), xomType.getSystemID());
        assertEquals(type.getPublicId(), xomType.getPublicID());
                
    }
View Full Code Here

            System.out.println("    text = new Text(\""
             + javaEscape(text.getValue()) + "\");");
            System.out.println("    " + parent + ".appendChild(text);");   
        }
        else if (node instanceof DocType) {
            DocType doctype = (DocType) node;
            String publicID = doctype.getPublicID();
            String systemID = doctype.getSystemID();
            System.out.println("    DocType doctype = new DocType(\""
                + doctype.getRootElementName() + "\");");
            if (systemID != null) {
                System.out.println("    doctype.setSystemID(\""
                 + systemID + "\");");
            }
            if (publicID != null) {
View Full Code Here

        BigInteger temp = high;
        high = high.add(low);
        low = temp;
      }
      Document doc = new Document(root);
      DocType doctype
        = new DocType("Fibonacci_Numbers", "fibonacci.dtd");
      doc.insertChild(doctype, 0);
      System.out.println(doc.toXML())

  }
View Full Code Here

    }

    // change the DOCTYPE to XHTML Basic DOCTYPE
    public Nodes makeDocType(String rootElementName,
      String publicID, String systemID) {
        return new Nodes(new DocType("html",
          "PUBLIC \"-//W3C//DTD XHTML Basic 1.0//EN\"",
          "http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd"));   
    }
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.