Search in sources :

Example 6 with DOMImplementation

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

the class DOMImplementationCreateDocumentType method testCreateDocumentType1.

/**
     * Runs the test case.
     *
     * @throws Throwable
     *             Any uncaught exception causes test to fail
     */
public void testCreateDocumentType1() throws Throwable {
    Document doc;
    DOMImplementation domImpl;
    DocumentType newDocType;
    Document ownerDocument;
    String qualifiedName = "test:root";
    String publicId;
    String systemId;
    List<String> publicIds = new ArrayList<String>();
    publicIds.add("1234");
    publicIds.add("test");
    List<String> systemIds = new ArrayList<String>();
    systemIds.add("");
    systemIds.add("test");
    doc = (Document) load("staffNS", builder);
    domImpl = doc.getImplementation();
    for (int indexN1005D = 0; indexN1005D < publicIds.size(); indexN1005D++) {
        publicId = (String) publicIds.get(indexN1005D);
        for (int indexN10061 = 0; indexN10061 < systemIds.size(); indexN10061++) {
            systemId = (String) systemIds.get(indexN10061);
            newDocType = domImpl.createDocumentType(qualifiedName, publicId, systemId);
            assertNotNull("domimplementationcreatedocumenttype01_newDocType", newDocType);
            ownerDocument = newDocType.getOwnerDocument();
            assertNull("domimplementationcreatedocumenttype01_ownerDocument", ownerDocument);
        }
    }
}
Also used : ArrayList(java.util.ArrayList) DOMImplementation(org.w3c.dom.DOMImplementation) DocumentType(org.w3c.dom.DocumentType) Document(org.w3c.dom.Document)

Example 7 with DOMImplementation

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

the class CreateDocument method testCreateDocument7.

public void testCreateDocument7() throws Throwable {
    String namespaceURI = "http://www.ecommerce.org/schema";
    String qualifiedName = "y:x";
    Document doc;
    DocumentType docType = null;
    DOMImplementation domImpl;
    Document aNewDoc;
    String nodeName;
    String nodeValue;
    doc = (Document) load("staffNS", builder);
    domImpl = doc.getImplementation();
    aNewDoc = domImpl.createDocument(namespaceURI, qualifiedName, docType);
    nodeName = aNewDoc.getNodeName();
    nodeValue = aNewDoc.getNodeValue();
    assertEquals("nodeName", "#document", nodeName);
    assertNull("nodeValue", nodeValue);
}
Also used : DocumentType(org.w3c.dom.DocumentType) DOMImplementation(org.w3c.dom.DOMImplementation) Document(org.w3c.dom.Document)

Example 8 with DOMImplementation

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

the class CreateDocument method testCreateDocument1.

/**
     * Runs the test case.
     *
     * @throws Throwable
     *             Any uncaught exception causes test to fail
     */
public void testCreateDocument1() throws Throwable {
    String namespaceURI = "http://www.ecommerce.org/";
    String malformedName = "prefix::local";
    Document doc;
    DocumentType docType = null;
    DOMImplementation domImpl;
    doc = (Document) load("staffNS", builder);
    domImpl = doc.getImplementation();
    boolean success = false;
    try {
        domImpl.createDocument(namespaceURI, malformedName, 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 9 with DOMImplementation

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

the class CreateDocument method testCreateDocument5.

//    public void testCreateDocument3() throws Throwable {
//        String namespaceURI = "http://www.ecommerce.org/schema";
//        String qualifiedName = "namespaceURI:x";
//        Document doc;
//        DocumentType docType;
//        DOMImplementation domImpl;
//
//        doc = (Document) load("staffNS", builder);
//        docType = doc.getDoctype();
//        domImpl = doc.getImplementation();
//
//        boolean success = false;
//        try {
//            domImpl.createDocument(namespaceURI, qualifiedName, docType);
//        } catch (DOMException ex) {
//            success = (ex.code == DOMException.WRONG_DOCUMENT_ERR);
//        }
//        assertTrue("throw_WRONG_DOCUMENT_ERR", success);
//
//    }
//    public void testCreateDocument4() throws Throwable {
//        String namespaceURI = "http://www.ecommerce.org/schema";
//        String qualifiedName = "namespaceURI:x";
//        Document doc;
//        DocumentType docType;
//        DOMImplementation domImpl;
//        Document aNewDoc;
//        doc = (Document) load("staffNS", builder);
//        aNewDoc = (Document) load("staffNS", builder);
//        docType = doc.getDoctype();
//        domImpl = aNewDoc.getImplementation();
//
//        boolean success = false;
//        try {
//            aNewDoc = domImpl.createDocument(namespaceURI, qualifiedName,
//                    docType);
//        } catch (DOMException ex) {
//            success = (ex.code == DOMException.WRONG_DOCUMENT_ERR);
//        }
//        assertTrue("throw_WRONG_DOCUMENT_ERR", success);
//
//    }
public void testCreateDocument5() throws Throwable {
    String namespaceURI = "http://www.ecommerce.org/schema";
    String qualifiedName;
    Document doc;
    DocumentType docType = null;
    DOMImplementation domImpl;
    List<String> illegalQNames = new ArrayList<String>();
    illegalQNames.add("namespaceURI:{");
    illegalQNames.add("namespaceURI:}");
    illegalQNames.add("namespaceURI:~");
    illegalQNames.add("namespaceURI:'");
    illegalQNames.add("namespaceURI:!");
    illegalQNames.add("namespaceURI:@");
    illegalQNames.add("namespaceURI:#");
    illegalQNames.add("namespaceURI:$");
    illegalQNames.add("namespaceURI:%");
    illegalQNames.add("namespaceURI:^");
    illegalQNames.add("namespaceURI:&");
    illegalQNames.add("namespaceURI:*");
    illegalQNames.add("namespaceURI:(");
    illegalQNames.add("namespaceURI:)");
    illegalQNames.add("namespaceURI:+");
    illegalQNames.add("namespaceURI:=");
    illegalQNames.add("namespaceURI:[");
    illegalQNames.add("namespaceURI:]");
    illegalQNames.add("namespaceURI:\\");
    illegalQNames.add("namespaceURI:/");
    illegalQNames.add("namespaceURI:;");
    illegalQNames.add("namespaceURI:`");
    illegalQNames.add("namespaceURI:<");
    illegalQNames.add("namespaceURI:>");
    illegalQNames.add("namespaceURI:,");
    illegalQNames.add("namespaceURI:a ");
    illegalQNames.add("namespaceURI:\"");
    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.createDocument(namespaceURI, qualifiedName, docType);
        } 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) DocumentType(org.w3c.dom.DocumentType) DOMImplementation(org.w3c.dom.DOMImplementation) Document(org.w3c.dom.Document)

Example 10 with DOMImplementation

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

the class CreateDocumentType method testCreateDocumentType1.

/**
     * Runs the test case.
     *
     * @throws Throwable
     *             Any uncaught exception causes test to fail
     */
public void testCreateDocumentType1() throws Throwable {
    String publicId = "STAFF";
    String systemId = "staff.xml";
    String malformedName = "prefix::local";
    Document doc;
    DOMImplementation domImpl;
    doc = (Document) load("staffNS", builder);
    domImpl = doc.getImplementation();
    {
        boolean success = false;
        try {
            domImpl.createDocumentType(malformedName, 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) Document(org.w3c.dom.Document)

Aggregations

DOMImplementation (org.w3c.dom.DOMImplementation)73 Document (org.w3c.dom.Document)61 DOMException (org.w3c.dom.DOMException)35 Element (org.w3c.dom.Element)32 DocumentType (org.w3c.dom.DocumentType)28 DocumentBuilder (javax.xml.parsers.DocumentBuilder)23 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)22 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)20 ArrayList (java.util.ArrayList)7 TransformerException (javax.xml.transform.TransformerException)6 Transformer (javax.xml.transform.Transformer)4 DOMSource (javax.xml.transform.dom.DOMSource)4 StreamResult (javax.xml.transform.stream.StreamResult)4 NodeList (org.w3c.dom.NodeList)4 DOMImplementationRegistry (org.w3c.dom.bootstrap.DOMImplementationRegistry)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 IOException (java.io.IOException)3 Node (org.w3c.dom.Node)3 DOMImplementationLS (org.w3c.dom.ls.DOMImplementationLS)3 BufferedImage (java.awt.image.BufferedImage)2