Search in sources :

Example 36 with DOMException

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

the class DocumentCreateAttributeNS method testCreateAttributeNS4.

public void testCreateAttributeNS4() throws Throwable {
    Document doc;
    String namespaceURI = "http://www.w3.org/DOM/Test/Level2";
    String qualifiedName;
    List<String> qualifiedNames = new ArrayList<String>();
    qualifiedNames.add("_:");
    qualifiedNames.add(":0a");
    qualifiedNames.add(":");
    qualifiedNames.add("a:b:c");
    qualifiedNames.add("_::a");
    doc = (Document) load("staffNS", builder);
    for (int indexN1004E = 0; indexN1004E < qualifiedNames.size(); indexN1004E++) {
        qualifiedName = (String) qualifiedNames.get(indexN1004E);
        {
            //     Our exception priorities differ from the spec
            try {
                doc.createAttributeNS(namespaceURI, qualifiedName);
                fail();
            } catch (DOMException ex) {
            }
        // END android-changed
        }
    }
}
Also used : DOMException(org.w3c.dom.DOMException) ArrayList(java.util.ArrayList) Document(org.w3c.dom.Document)

Example 37 with DOMException

use of org.w3c.dom.DOMException 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 38 with DOMException

use of org.w3c.dom.DOMException 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 39 with DOMException

use of org.w3c.dom.DOMException 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)

Example 40 with DOMException

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

the class CreateElementNS method testCreateElementNS4.

public void testCreateElementNS4() throws Throwable {
    String namespaceURI = "http://www.w3.org/XML/1998/namespaces";
    String qualifiedName = "xml:element1";
    Document doc;
    doc = (Document) load("staffNS", builder);
    {
        boolean success = false;
        try {
            doc.createElementNS(namespaceURI, qualifiedName);
        } catch (DOMException ex) {
            success = (ex.code == DOMException.NAMESPACE_ERR);
        }
        assertTrue("throw_NAMESPACE_ERR", success);
    }
}
Also used : DOMException(org.w3c.dom.DOMException) Document(org.w3c.dom.Document)

Aggregations

DOMException (org.w3c.dom.DOMException)323 Document (org.w3c.dom.Document)165 Element (org.w3c.dom.Element)131 Node (org.w3c.dom.Node)73 NodeList (org.w3c.dom.NodeList)57 DocumentBuilder (javax.xml.parsers.DocumentBuilder)42 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)42 Attr (org.w3c.dom.Attr)40 DOMImplementation (org.w3c.dom.DOMImplementation)37 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)28 FrameworkException (org.structr.common.error.FrameworkException)27 IOException (java.io.IOException)26 NamedNodeMap (org.w3c.dom.NamedNodeMap)25 DocumentType (org.w3c.dom.DocumentType)19 ArrayList (java.util.ArrayList)17 Text (org.w3c.dom.Text)17 DOMNode (org.structr.web.entity.dom.DOMNode)16 XPathExpressionException (javax.xml.xpath.XPathExpressionException)15 SAXException (org.xml.sax.SAXException)13 TransformerException (javax.xml.transform.TransformerException)12