Search in sources :

Example 16 with DocumentType

use of org.w3c.dom.DocumentType 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 17 with DocumentType

use of org.w3c.dom.DocumentType 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 18 with DocumentType

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

the class DOMImplementationCreateDocument method testCreateDocument7.

public void testCreateDocument7() throws Throwable {
    Document doc;
    DOMImplementation domImpl;
    String namespaceURI = "http://www.w3.org/DOMTest/level2";
    DocumentType docType = null;
    doc = (Document) load("staffNS", builder);
    domImpl = doc.getImplementation();
    {
        boolean success = false;
        try {
            domImpl.createDocument(namespaceURI, ":", docType);
        } catch (DOMException ex) {
            success = (ex.code == DOMException.NAMESPACE_ERR);
        }
        assertTrue("domimplementationcreatedocument07", success);
    }
}
Also used : DOMException(org.w3c.dom.DOMException) DOMImplementation(org.w3c.dom.DOMImplementation) DocumentType(org.w3c.dom.DocumentType) Document(org.w3c.dom.Document)

Example 19 with DocumentType

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

the class DOMImplementationCreateDocument method testCreateDocument4.

public void testCreateDocument4() throws Throwable {
    Document doc;
    DOMImplementation domImpl;
    String namespaceURI = null;
    String qualifiedName = "dom:root";
    DocumentType docType = null;
    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("domimplementationcreatedocument04", success);
    }
}
Also used : DOMException(org.w3c.dom.DOMException) DOMImplementation(org.w3c.dom.DOMImplementation) DocumentType(org.w3c.dom.DocumentType) Document(org.w3c.dom.Document)

Example 20 with DocumentType

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

the class ImportNode method testImportNode8.

// Assumes validation.
//    public void testImportNode7() throws Throwable {
//        Document doc;
//        Document aNewDoc;
//        Element element;
//        Node aNode;
//        NamedNodeMap attributes;
//        String name;
//        Node attr;
//        String lname;
//        String namespaceURI = "http://www.nist.gov";
//        String qualifiedName = "emp:employee";
//        doc = (Document) load("staffNS", builder);
//        aNewDoc = (Document) load("staff", builder);
//        element = aNewDoc.createElementNS(namespaceURI, qualifiedName);
//        aNode = doc.importNode(element, false);
//        attributes = aNode.getAttributes();
//        assertEquals("throw_Size", 1, attributes.getLength());
//        name = aNode.getNodeName();
//        assertEquals("nodeName", "emp:employee", name);
//        attr = attributes.item(0);
//        lname = attr.getLocalName();
//        assertEquals("lname", "defaultAttr", lname);
//    }
public void testImportNode8() throws Throwable {
    Document doc;
    Document aNewDoc;
    DocumentFragment docFrag;
    Node aNode;
    boolean hasChild;
    Document ownerDocument;
    DocumentType docType;
    String system;
    doc = (Document) load("staffNS", builder);
    aNewDoc = (Document) load("staffNS", builder);
    docFrag = aNewDoc.createDocumentFragment();
    aNode = doc.importNode(docFrag, false);
    hasChild = aNode.hasChildNodes();
    assertFalse("hasChild", hasChild);
    ownerDocument = aNode.getOwnerDocument();
    docType = ownerDocument.getDoctype();
    system = docType.getSystemId();
    assertURIEquals("system", null, null, null, "staffNS.dtd", null, null, null, null, system);
}
Also used : Node(org.w3c.dom.Node) DocumentType(org.w3c.dom.DocumentType) Document(org.w3c.dom.Document) DocumentFragment(org.w3c.dom.DocumentFragment)

Aggregations

DocumentType (org.w3c.dom.DocumentType)107 Document (org.w3c.dom.Document)68 DOMImplementation (org.w3c.dom.DOMImplementation)34 Node (org.w3c.dom.Node)21 DOMException (org.w3c.dom.DOMException)19 Element (org.w3c.dom.Element)16 NamedNodeMap (org.w3c.dom.NamedNodeMap)14 NodeList (org.w3c.dom.NodeList)12 ArrayList (java.util.ArrayList)10 IDOMDocument (org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument)8 Entity (org.w3c.dom.Entity)8 IOException (java.io.IOException)7 CMDocument (org.eclipse.wst.xml.core.internal.contentmodel.CMDocument)6 DocumentBuilder (javax.xml.parsers.DocumentBuilder)5 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)4 Transformer (javax.xml.transform.Transformer)4 TransformerFactory (javax.xml.transform.TransformerFactory)4 DOMSource (javax.xml.transform.dom.DOMSource)4 StreamResult (javax.xml.transform.stream.StreamResult)4 Attr (org.w3c.dom.Attr)4