Search in sources :

Example 21 with DocumentType

use of org.w3c.dom.DocumentType in project robovm by robovm.

the class ImportNode method testImportNode16.

public void testImportNode16() throws Throwable {
    Document doc;
    Document anotherDoc;
    DocumentType docType;
    doc = (Document) load("staffNS", builder);
    anotherDoc = (Document) load("staffNS", builder);
    docType = anotherDoc.getDoctype();
    {
        boolean success = false;
        try {
            doc.importNode(docType, false);
        } catch (DOMException ex) {
            success = (ex.code == DOMException.NOT_SUPPORTED_ERR);
        }
        assertTrue("throw_NOT_SUPPORTED_ERR", success);
    }
}
Also used : DOMException(org.w3c.dom.DOMException) DocumentType(org.w3c.dom.DocumentType) Document(org.w3c.dom.Document)

Example 22 with DocumentType

use of org.w3c.dom.DocumentType in project robovm by robovm.

the class ImportNode method testImportNode2.

public void testImportNode2() throws Throwable {
    Document doc;
    Document aNewDoc;
    CDATASection cDataSec;
    Node aNode;
    Document ownerDocument;
    DocumentType docType;
    String system;
    String value;
    doc = (Document) load("staffNS", builder);
    aNewDoc = (Document) load("staffNS", builder);
    cDataSec = aNewDoc.createCDATASection("this is CDATASection data");
    aNode = doc.importNode(cDataSec, false);
    ownerDocument = aNode.getOwnerDocument();
    assertNotNull("ownerDocumentNotNull", ownerDocument);
    docType = ownerDocument.getDoctype();
    system = docType.getSystemId();
    assertURIEquals("dtdSystemId", null, null, null, "staffNS.dtd", null, null, null, null, system);
    value = aNode.getNodeValue();
    assertEquals("nodeValue", "this is CDATASection data", value);
}
Also used : CDATASection(org.w3c.dom.CDATASection) Node(org.w3c.dom.Node) DocumentType(org.w3c.dom.DocumentType) Document(org.w3c.dom.Document)

Example 23 with DocumentType

use of org.w3c.dom.DocumentType in project robovm by robovm.

the class ImportNode method testImportNode10.

// Assumes validation.
//    public void testImportNode9() throws Throwable {
//        Document doc;
//        Document aNewDoc;
//
//        NamedNodeMap entityList;
//        Entity entity2;
//        Entity entity1;
//        Document ownerDocument;
//        DocumentType docType;
//        String system;
//        String entityName;
//        String publicVal;
//        String notationName;
//        doc = (Document) load("staffNS", builder);
//        aNewDoc = (Document) load("staffNS", builder);
//        docType = aNewDoc.getDoctype();
//        entityList = docType.getEntities();
//        assertNotNull("entitiesNotNull", entityList);
//        entity2 = (Entity) entityList.getNamedItem("ent6");
//        entity1 = (Entity) doc.importNode(entity2, false);
//        ownerDocument = entity1.getOwnerDocument();
//        docType = ownerDocument.getDoctype();
//        system = docType.getSystemId();
//        assertURIEquals("dtdSystemId", null, null, null, "staffNS.dtd", null,
//                null, null, null, system);
//        entityName = entity1.getNodeName();
//        assertEquals("entityName", "ent6", entityName);
//        publicVal = entity1.getPublicId();
//        assertEquals("entityPublicId", "uri", publicVal);
//        system = entity1.getSystemId();
//        assertURIEquals("entitySystemId", null, null, null, "file", null, null,
//                null, null, system);
//        notationName = entity1.getNotationName();
//        assertEquals("notationName", "notation2", notationName);
//    }
public void testImportNode10() throws Throwable {
    Document doc;
    Document aNewDoc;
    EntityReference entRef;
    Node aNode;
    Document ownerDocument;
    DocumentType docType;
    String system;
    String name;
    doc = (Document) load("staffNS", builder);
    aNewDoc = (Document) load("staffNS", builder);
    entRef = aNewDoc.createEntityReference("entRef1");
    assertNotNull("createdEntRefNotNull", entRef);
    entRef.setNodeValue("entRef1Value");
    aNode = doc.importNode(entRef, false);
    ownerDocument = aNode.getOwnerDocument();
    docType = ownerDocument.getDoctype();
    system = docType.getSystemId();
    assertURIEquals("systemId", null, null, null, "staffNS.dtd", null, null, null, null, system);
    name = aNode.getNodeName();
    assertEquals("nodeName", "entRef1", name);
}
Also used : Node(org.w3c.dom.Node) EntityReference(org.w3c.dom.EntityReference) DocumentType(org.w3c.dom.DocumentType) Document(org.w3c.dom.Document)

Example 24 with DocumentType

use of org.w3c.dom.DocumentType in project robovm by robovm.

the class HCNotationsRemoveNamedItemNS method testRemoveNamedItemNS.

/**
     * Runs the test case.
     *
     * @throws Throwable
     *             Any uncaught exception causes test to fail
     */
public void testRemoveNamedItemNS() throws Throwable {
    Document doc;
    NamedNodeMap notations;
    DocumentType docType;
    doc = (Document) load("hc_staff", builder);
    docType = doc.getDoctype();
    if (!(("text/html".equals(getContentType())))) {
        assertNotNull("docTypeNotNull", docType);
        notations = docType.getNotations();
        assertNotNull("notationsNotNull", notations);
        try {
            notations.removeNamedItemNS("http://www.w3.org/1999/xhtml", "alpha");
            fail("throw_NO_MOD_OR_NOT_FOUND_ERR");
        } catch (DOMException ex) {
            switch(ex.code) {
                case 7:
                    break;
                case 8:
                    break;
                default:
                    throw ex;
            }
        }
    }
}
Also used : DOMException(org.w3c.dom.DOMException) NamedNodeMap(org.w3c.dom.NamedNodeMap) DocumentType(org.w3c.dom.DocumentType) Document(org.w3c.dom.Document)

Example 25 with DocumentType

use of org.w3c.dom.DocumentType in project robovm by robovm.

the class DocumentImportNode method testImportNode7.

public void testImportNode7() throws Throwable {
    Document doc;
    DocumentType docType;
    doc = (Document) load("staffNS", builder);
    docType = doc.getDoctype();
    {
        boolean success = false;
        try {
            doc.importNode(docType, true);
        } catch (DOMException ex) {
            success = (ex.code == DOMException.NOT_SUPPORTED_ERR);
        }
        assertTrue("throw_NOT_SUPPORTED_ERR", success);
    }
}
Also used : DOMException(org.w3c.dom.DOMException) DocumentType(org.w3c.dom.DocumentType) Document(org.w3c.dom.Document)

Aggregations

DocumentType (org.w3c.dom.DocumentType)107 Document (org.w3c.dom.Document)68 DOMImplementation (org.w3c.dom.DOMImplementation)34 Node (org.w3c.dom.Node)21 DOMException (org.w3c.dom.DOMException)19 Element (org.w3c.dom.Element)16 NamedNodeMap (org.w3c.dom.NamedNodeMap)14 NodeList (org.w3c.dom.NodeList)12 ArrayList (java.util.ArrayList)10 IDOMDocument (org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument)8 Entity (org.w3c.dom.Entity)8 IOException (java.io.IOException)7 CMDocument (org.eclipse.wst.xml.core.internal.contentmodel.CMDocument)6 DocumentBuilder (javax.xml.parsers.DocumentBuilder)5 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)4 Transformer (javax.xml.transform.Transformer)4 TransformerFactory (javax.xml.transform.TransformerFactory)4 DOMSource (javax.xml.transform.dom.DOMSource)4 StreamResult (javax.xml.transform.stream.StreamResult)4 Attr (org.w3c.dom.Attr)4