Search in sources :

Example 51 with DocumentType

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

the class DocumentTypeInternalSubset method testGetInternalSubset.

/**
     * Runs the test case.
     *
     * @throws Throwable
     *             Any uncaught exception causes test to fail
     */
public void testGetInternalSubset() throws Throwable {
    Document doc;
    DocumentType docType;
    DOMImplementation domImpl;
    String internal;
    String nullNS = null;
    doc = (Document) load("staffNS", builder);
    domImpl = doc.getImplementation();
    docType = domImpl.createDocumentType("l2:root", nullNS, nullNS);
    internal = docType.getInternalSubset();
    assertNull("internalSubsetNull", internal);
}
Also used : DocumentType(org.w3c.dom.DocumentType) DOMImplementation(org.w3c.dom.DOMImplementation) Document(org.w3c.dom.Document)

Example 52 with DocumentType

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

the class ImportNode method testImportNode15.

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

Example 53 with DocumentType

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

the class ImportNode method testImportNode14.

// Assumes validation
//    public void testImportNode11() throws Throwable {
//        Document doc;
//        Document aNewDoc;
//        EntityReference entRef;
//        Node aNode;
//        String name;
//        Node child;
//        String childValue;
//        doc = (Document) load("staff", builder);
//        aNewDoc = (Document) load("staff", builder);
//        entRef = aNewDoc.createEntityReference("ent3");
//        assertNotNull("createdEntRefNotNull", entRef);
//        aNode = doc.importNode(entRef, true);
//        name = aNode.getNodeName();
//        assertEquals("entityName", "ent3", name);
//        child = aNode.getFirstChild();
//        assertNotNull("child", child);
//        childValue = child.getNodeValue();
//        assertEquals("childValue", "Texas", childValue);
//    }
// Assumes validation.
//    public void testImportNode12() throws Throwable {
//        Document doc;
//        Document aNewDoc;
//        DocumentType doc1Type;
//        NamedNodeMap entityList;
//        Entity entity2;
//        Entity entity1;
//        Document ownerDocument;
//        DocumentType docType;
//        String system;
//        String entityName;
//        Node child;
//        String childName;
//        doc = (Document) load("staffNS", builder);
//        aNewDoc = (Document) load("staffNS", builder);
//        doc1Type = aNewDoc.getDoctype();
//        entityList = doc1Type.getEntities();
//        assertNotNull("entitiesNotNull", entityList);
//        entity2 = (Entity) entityList.getNamedItem("ent4");
//        entity1 = (Entity) doc.importNode(entity2, true);
//        ownerDocument = entity1.getOwnerDocument();
//        docType = ownerDocument.getDoctype();
//        system = docType.getSystemId();
//        assertURIEquals("systemId", null, null, null, "staffNS.dtd", null,
//                null, null, null, system);
//        entityName = entity1.getNodeName();
//        assertEquals("entityName", "ent4", entityName);
//        child = entity1.getFirstChild();
//        assertNotNull("notnull", child);
//        childName = child.getNodeName();
//        assertEquals("childName", "entElement1", childName);
//    }
// Assumes validation
//    public void testImportNode13() throws Throwable {
//        Document doc;
//        Document aNewDoc;
//        DocumentType doc1Type;
//        NamedNodeMap notationList;
//        Notation notation;
//        Notation aNode;
//        Document ownerDocument;
//        DocumentType docType;
//        String system;
//        String publicVal;
//        doc = (Document) load("staffNS", builder);
//        aNewDoc = (Document) load("staffNS", builder);
//        doc1Type = aNewDoc.getDoctype();
//        notationList = doc1Type.getNotations();
//        assertNotNull("notationsNotNull", notationList);
//        notation = (Notation) notationList.getNamedItem("notation1");
//        aNode = (Notation) doc.importNode(notation, false);
//        ownerDocument = aNode.getOwnerDocument();
//        docType = ownerDocument.getDoctype();
//        system = docType.getSystemId();
//        assertURIEquals("systemId", null, null, null, "staffNS.dtd", null,
//                null, null, null, system);
//        publicVal = aNode.getPublicId();
//        assertEquals("publicId", "notation1File", publicVal);
//        system = aNode.getSystemId();
//        assertNull("notationSystemId", system);
//    }
public void testImportNode14() throws Throwable {
    Document doc;
    Document aNewDoc;
    ProcessingInstruction pi;
    ProcessingInstruction aNode;
    Document ownerDocument;
    DocumentType docType;
    String system;
    String target;
    String data;
    doc = (Document) load("staffNS", builder);
    aNewDoc = (Document) load("staffNS", builder);
    pi = aNewDoc.createProcessingInstruction("target1", "data1");
    aNode = (ProcessingInstruction) doc.importNode(pi, false);
    ownerDocument = aNode.getOwnerDocument();
    assertNotNull("ownerDocumentNotNull", ownerDocument);
    docType = ownerDocument.getDoctype();
    system = docType.getSystemId();
    assertURIEquals("systemId", null, null, null, "staffNS.dtd", null, null, null, null, system);
    target = aNode.getTarget();
    assertEquals("piTarget", "target1", target);
    data = aNode.getData();
    assertEquals("piData", "data1", data);
}
Also used : DocumentType(org.w3c.dom.DocumentType) Document(org.w3c.dom.Document) ProcessingInstruction(org.w3c.dom.ProcessingInstruction)

Example 54 with DocumentType

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

the class ImportNode method testImportNode3.

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

Example 55 with DocumentType

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

the class ImportNode method testImportNode5.

public void testImportNode5() throws Throwable {
    Document doc;
    Document aNewDoc;
    Element element;
    Node aNode;
    boolean hasChild;
    Document ownerDocument;
    DocumentType docType;
    String system;
    String name;
    NodeList addresses;
    doc = (Document) load("staffNS", builder);
    aNewDoc = (Document) load("staffNS", builder);
    addresses = aNewDoc.getElementsByTagName("emp:address");
    element = (Element) addresses.item(0);
    assertNotNull("empAddressNotNull", element);
    aNode = doc.importNode(element, false);
    hasChild = aNode.hasChildNodes();
    assertFalse("hasChild", hasChild);
    ownerDocument = aNode.getOwnerDocument();
    docType = ownerDocument.getDoctype();
    system = docType.getSystemId();
    assertURIEquals("dtdSystemId", null, null, null, "staffNS.dtd", null, null, null, null, system);
    name = aNode.getNodeName();
    assertEquals("nodeName", "emp:address", name);
}
Also used : Element(org.w3c.dom.Element) Node(org.w3c.dom.Node) NodeList(org.w3c.dom.NodeList) DocumentType(org.w3c.dom.DocumentType) Document(org.w3c.dom.Document)

Aggregations

DocumentType (org.w3c.dom.DocumentType)75 Document (org.w3c.dom.Document)57 DOMImplementation (org.w3c.dom.DOMImplementation)28 DOMException (org.w3c.dom.DOMException)18 NamedNodeMap (org.w3c.dom.NamedNodeMap)12 Node (org.w3c.dom.Node)12 Element (org.w3c.dom.Element)11 NodeList (org.w3c.dom.NodeList)8 ArrayList (java.util.ArrayList)7 Entity (org.w3c.dom.Entity)7 IOException (java.io.IOException)5 Attr (org.w3c.dom.Attr)4 Text (org.w3c.dom.Text)4 SAXParseException (org.xml.sax.SAXParseException)4 URL (java.net.URL)3 URLConnection (java.net.URLConnection)3 DocumentBuilder (javax.xml.parsers.DocumentBuilder)3 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)3 DocumentImpl (org.apache.harmony.xml.dom.DocumentImpl)3 XMLString (org.apache.xml.utils.XMLString)3