Search in sources :

Example 66 with DOMImplementation

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

the class CreateDocument method testCreateDocument6.

public void testCreateDocument6() throws Throwable {
    String namespaceURI = "http://ecommerce.org/schema";
    String qualifiedName = "xml:local";
    Document doc;
    DocumentType docType = null;
    DOMImplementation domImpl;
    doc = (Document) load("staffNS", builder);
    domImpl = doc.getImplementation();
    boolean success = false;
    try {
        domImpl.createDocument(namespaceURI, qualifiedName, docType);
    } catch (DOMException ex) {
        success = (ex.code == DOMException.NAMESPACE_ERR);
    }
    assertTrue("throw_NAMESPACE_ERR", success);
}
Also used : DOMException(org.w3c.dom.DOMException) DocumentType(org.w3c.dom.DocumentType) DOMImplementation(org.w3c.dom.DOMImplementation) Document(org.w3c.dom.Document)

Example 67 with DOMImplementation

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

the class CreateDocument method testCreateDocument8.

public void testCreateDocument8() throws Throwable {
    String namespaceURI = "http://www.example.org/schema";
    DocumentType docType = null;
    DOMImplementation domImpl;
    domImpl = builder.getDOMImplementation();
    //     Our exception priorities differ from the spec
    try {
        domImpl.createDocument(namespaceURI, "", docType);
        fail();
    } catch (DOMException ex) {
    }
// END android-changed
}
Also used : DOMException(org.w3c.dom.DOMException) DocumentType(org.w3c.dom.DocumentType) DOMImplementation(org.w3c.dom.DOMImplementation)

Example 68 with DOMImplementation

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

the class CreateDocumentType method testCreateDocumentType4.

public void testCreateDocumentType4() throws Throwable {
    String publicId = "http://www.example.com/";
    String systemId = "myDoc.dtd";
    DOMImplementation domImpl;
    domImpl = builder.getDOMImplementation();
    {
        boolean success = false;
        try {
            domImpl.createDocumentType("", publicId, systemId);
        } catch (DOMException ex) {
            success = (ex.code == DOMException.NAMESPACE_ERR);
        }
        assertTrue("throw_NAMESPACE_ERR", success);
    }
}
Also used : DOMException(org.w3c.dom.DOMException) DOMImplementation(org.w3c.dom.DOMImplementation)

Example 69 with DOMImplementation

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

the class CreateDocumentType method testCreateDocumentType2.

public void testCreateDocumentType2() throws Throwable {
    String publicId = "http://www.localhost.com/";
    String systemId = "myDoc.dtd";
    String qualifiedName;
    Document doc;
    DOMImplementation domImpl;
    List<String> illegalQNames = new ArrayList<String>();
    illegalQNames.add("edi:{");
    illegalQNames.add("edi:}");
    illegalQNames.add("edi:~");
    illegalQNames.add("edi:'");
    illegalQNames.add("edi:!");
    illegalQNames.add("edi:@");
    illegalQNames.add("edi:#");
    illegalQNames.add("edi:$");
    illegalQNames.add("edi:%");
    illegalQNames.add("edi:^");
    illegalQNames.add("edi:&");
    illegalQNames.add("edi:*");
    illegalQNames.add("edi:(");
    illegalQNames.add("edi:)");
    illegalQNames.add("edi:+");
    illegalQNames.add("edi:=");
    illegalQNames.add("edi:[");
    illegalQNames.add("edi:]");
    illegalQNames.add("edi:\\");
    illegalQNames.add("edi:/");
    illegalQNames.add("edi:;");
    illegalQNames.add("edi:`");
    illegalQNames.add("edi:<");
    illegalQNames.add("edi:>");
    illegalQNames.add("edi:,");
    illegalQNames.add("edi:a ");
    illegalQNames.add("edi:\"");
    doc = (Document) load("staffNS", builder);
    for (int indexN1009A = 0; indexN1009A < illegalQNames.size(); indexN1009A++) {
        qualifiedName = (String) illegalQNames.get(indexN1009A);
        domImpl = doc.getImplementation();
        {
            boolean success = false;
            try {
                domImpl.createDocumentType(qualifiedName, publicId, systemId);
            } catch (DOMException ex) {
                success = (ex.code == DOMException.INVALID_CHARACTER_ERR);
            }
            assertTrue("throw_INVALID_CHARACTER_ERR", success);
        }
    }
}
Also used : DOMException(org.w3c.dom.DOMException) ArrayList(java.util.ArrayList) DOMImplementation(org.w3c.dom.DOMImplementation) Document(org.w3c.dom.Document)

Example 70 with DOMImplementation

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

the class CreateDocumentType method testCreateDocumentType3.

public void testCreateDocumentType3() throws Throwable {
    String qualifiedName = "prefix:myDoc";
    String publicId = "http://www.localhost.com";
    String systemId = "myDoc.dtd";
    Document doc;
    DOMImplementation domImpl;
    DocumentType newType = null;
    String nodeName;
    String nodeValue;
    doc = (Document) load("staffNS", builder);
    domImpl = doc.getImplementation();
    newType = domImpl.createDocumentType(qualifiedName, publicId, systemId);
    nodeName = newType.getNodeName();
    assertEquals("nodeName", "prefix:myDoc", nodeName);
    nodeValue = newType.getNodeValue();
    assertNull("nodeValue", nodeValue);
}
Also used : DOMImplementation(org.w3c.dom.DOMImplementation) DocumentType(org.w3c.dom.DocumentType) Document(org.w3c.dom.Document)

Aggregations

DOMImplementation (org.w3c.dom.DOMImplementation)82 Document (org.w3c.dom.Document)67 DOMException (org.w3c.dom.DOMException)35 Element (org.w3c.dom.Element)34 DocumentType (org.w3c.dom.DocumentType)28 DocumentBuilder (javax.xml.parsers.DocumentBuilder)25 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)22 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)22 ArrayList (java.util.ArrayList)8 TransformerException (javax.xml.transform.TransformerException)6 DOMImplementationRegistry (org.w3c.dom.bootstrap.DOMImplementationRegistry)6 DOMImplementationLS (org.w3c.dom.ls.DOMImplementationLS)6 IOException (java.io.IOException)5 Transformer (javax.xml.transform.Transformer)5 DOMSource (javax.xml.transform.dom.DOMSource)5 StreamResult (javax.xml.transform.stream.StreamResult)5 Node (org.w3c.dom.Node)5 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 NodeList (org.w3c.dom.NodeList)4 ByteArrayInputStream (java.io.ByteArrayInputStream)3