Search in sources :

Example 46 with DocumentType

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

the class DOMImplementationCreateDocumentType method testCreateDocumentType2.

public void testCreateDocumentType2() throws Throwable {
    Document doc;
    DOMImplementation domImpl;
    DocumentType newDocType;
    Document ownerDocument;
    String publicId = "http://www.w3.org/DOM/Test/dom2.dtd";
    String systemId = "dom2.dtd";
    String qualifiedName;
    List<String> qualifiedNames = new ArrayList<String>();
    qualifiedNames.add("_:_");
    qualifiedNames.add("_:h0");
    qualifiedNames.add("_:test");
    qualifiedNames.add("_:_.");
    qualifiedNames.add("_:a-");
    qualifiedNames.add("l_:_");
    qualifiedNames.add("ns:_0");
    qualifiedNames.add("ns:a0");
    qualifiedNames.add("ns0:test");
    qualifiedNames.add("ns:EEE.");
    qualifiedNames.add("ns:_-");
    qualifiedNames.add("a.b:c");
    qualifiedNames.add("a-b:c.j");
    qualifiedNames.add("a-b:c");
    doc = (Document) load("staffNS", builder);
    domImpl = doc.getImplementation();
    for (int indexN10077 = 0; indexN10077 < qualifiedNames.size(); indexN10077++) {
        qualifiedName = (String) qualifiedNames.get(indexN10077);
        newDocType = domImpl.createDocumentType(qualifiedName, publicId, systemId);
        assertNotNull("domimplementationcreatedocumenttype02_newDocType", newDocType);
        ownerDocument = newDocType.getOwnerDocument();
        assertNull("domimplementationcreatedocumenttype02_ownerDocument", ownerDocument);
    }
}
Also used : ArrayList(java.util.ArrayList) DOMImplementation(org.w3c.dom.DOMImplementation) DocumentType(org.w3c.dom.DocumentType) Document(org.w3c.dom.Document)

Example 47 with DocumentType

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

the class DOMImplementationCreateDocumentType method testCreateDocumentType4.

public void testCreateDocumentType4() throws Throwable {
    Document doc;
    DOMImplementation domImpl;
    DocumentType newDocType;
    Document ownerDocument;
    String publicId = "http://www.w3.org/DOM/Test/dom2.dtd";
    String systemId = "dom2.dtd";
    String qualifiedName;
    List<String> qualifiedNames = new ArrayList<String>();
    qualifiedNames.add("_:_");
    qualifiedNames.add("_:h0");
    qualifiedNames.add("_:test");
    qualifiedNames.add("_:_.");
    qualifiedNames.add("_:a-");
    qualifiedNames.add("l_:_");
    qualifiedNames.add("ns:_0");
    qualifiedNames.add("ns:a0");
    qualifiedNames.add("ns0:test");
    qualifiedNames.add("ns:EEE.");
    qualifiedNames.add("ns:_-");
    qualifiedNames.add("a.b:c");
    qualifiedNames.add("a-b:c.j");
    qualifiedNames.add("a-b:c");
    doc = (Document) load("staffNS", builder);
    domImpl = doc.getImplementation();
    for (int indexN10077 = 0; indexN10077 < qualifiedNames.size(); indexN10077++) {
        qualifiedName = (String) qualifiedNames.get(indexN10077);
        newDocType = domImpl.createDocumentType(qualifiedName, publicId, systemId);
        assertNotNull("domimplementationcreatedocumenttype02_newDocType", newDocType);
        ownerDocument = newDocType.getOwnerDocument();
        assertNull("domimplementationcreatedocumenttype02_ownerDocument", ownerDocument);
    }
}
Also used : ArrayList(java.util.ArrayList) DOMImplementation(org.w3c.dom.DOMImplementation) DocumentType(org.w3c.dom.DocumentType) Document(org.w3c.dom.Document)

Example 48 with DocumentType

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

the class DocumentCreateAttributeNS method testCreateAttributeNS6.

public void testCreateAttributeNS6() throws Throwable {
    Document doc;
    Document newDoc;
    DocumentType docType = null;
    DOMImplementation domImpl;
    String namespaceURI = "http://www.w3.org/XML/1998 /namespace";
    String qualifiedName = "xml:root";
    doc = (Document) load("staffNS", builder);
    domImpl = doc.getImplementation();
    newDoc = domImpl.createDocument("http://www.w3.org/DOM/Test", "dom:doc", docType);
    {
        boolean success = false;
        try {
            newDoc.createAttributeNS(namespaceURI, qualifiedName);
        } catch (DOMException ex) {
            success = (ex.code == DOMException.NAMESPACE_ERR);
        }
        assertTrue("documentcreateattributeNS06", success);
    }
}
Also used : DOMException(org.w3c.dom.DOMException) DocumentType(org.w3c.dom.DocumentType) DOMImplementation(org.w3c.dom.DOMImplementation) Document(org.w3c.dom.Document)

Example 49 with DocumentType

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

the class DocumentCreateAttributeNS method testCreateAttributeNS5.

public void testCreateAttributeNS5() throws Throwable {
    Document doc;
    Document newDoc;
    DocumentType docType = null;
    DOMImplementation domImpl;
    String namespaceURI = null;
    String qualifiedName = "abc:def";
    doc = (Document) load("staffNS", builder);
    domImpl = doc.getImplementation();
    newDoc = domImpl.createDocument("http://www.w3.org/DOM/Test", "dom:doc", docType);
    {
        boolean success = false;
        try {
            newDoc.createAttributeNS(namespaceURI, qualifiedName);
        } catch (DOMException ex) {
            success = (ex.code == DOMException.NAMESPACE_ERR);
        }
        assertTrue("documentcreateattributeNS05", success);
    }
}
Also used : DOMException(org.w3c.dom.DOMException) DocumentType(org.w3c.dom.DocumentType) DOMImplementation(org.w3c.dom.DOMImplementation) Document(org.w3c.dom.Document)

Example 50 with DocumentType

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

the class HCNotationsSetNamedItemNS method testNotationsSetNamedItemNS.

/**
     * Runs the test case.
     *
     * @throws Throwable
     *             Any uncaught exception causes test to fail
     */
public void testNotationsSetNamedItemNS() throws Throwable {
    Document doc;
    NamedNodeMap notations;
    DocumentType docType;
    Element elem;
    doc = (Document) load("hc_staff", builder);
    docType = doc.getDoctype();
    if (!(("text/html".equals(getContentType())))) {
        assertNotNull("docTypeNotNull", docType);
        notations = docType.getNotations();
        assertNotNull("notationsNotNull", notations);
        elem = doc.createElementNS("http://www.w3.org/1999/xhtml", "br");
        try {
            notations.setNamedItemNS(elem);
            fail("throw_HIER_OR_NO_MOD_ERR");
        } catch (DOMException ex) {
            switch(ex.code) {
                case 3:
                    break;
                case 7:
                    break;
                default:
                    throw ex;
            }
        }
    }
}
Also used : DOMException(org.w3c.dom.DOMException) NamedNodeMap(org.w3c.dom.NamedNodeMap) Element(org.w3c.dom.Element) 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