Search in sources :

Example 11 with DocumentType

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

the class ImportNode method _testImportNode1.

/**
     * Runs the test case.
     *
     * @throws Throwable
     *             Any uncaught exception causes test to fail
     */
public void _testImportNode1() throws Throwable {
    Document doc;
    Document aNewDoc;
    Attr newAttr;
    Text importedChild;
    Node aNode;
    Document ownerDocument;
    Element attrOwnerElement;
    DocumentType docType;
    String system;
    boolean specified;
    NodeList childList;
    String nodeName;
    Node child;
    String childValue;
    List<String> expectedResult = new ArrayList<String>();
    expectedResult.add("elem:attr1");
    expectedResult.add("importedText");
    doc = (Document) load("staffNS", builder);
    aNewDoc = (Document) load("staffNS", builder);
    newAttr = aNewDoc.createAttribute("elem:attr1");
    importedChild = aNewDoc.createTextNode("importedText");
    aNode = newAttr.appendChild(importedChild);
    aNode = doc.importNode(newAttr, false);
    ownerDocument = aNode.getOwnerDocument();
    docType = ownerDocument.getDoctype();
    system = docType.getSystemId();
    assertNotNull("aNode", aNode);
    assertURIEquals("systemId", null, null, null, "staffNS.dtd", null, null, null, null, system);
    attrOwnerElement = ((Attr) /* Node */
    aNode).getOwnerElement();
    assertNull("ownerElement", attrOwnerElement);
    specified = ((Attr) /* Node */
    aNode).getSpecified();
    assertTrue("specified", specified);
    childList = aNode.getChildNodes();
    assertEquals("childList", 1, childList.getLength());
    nodeName = aNode.getNodeName();
    assertEquals("nodeName", "elem:attr1", nodeName);
    child = aNode.getFirstChild();
    childValue = child.getNodeValue();
    assertEquals("childValue", "importedText", childValue);
}
Also used : Node(org.w3c.dom.Node) Element(org.w3c.dom.Element) NodeList(org.w3c.dom.NodeList) ArrayList(java.util.ArrayList) DocumentType(org.w3c.dom.DocumentType) Text(org.w3c.dom.Text) Document(org.w3c.dom.Document) Attr(org.w3c.dom.Attr)

Example 12 with DocumentType

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

the class DocumentGetElementsByTagnameNS method testGetElementsByTagNameNS1.

/**
     * Runs the test case.
     *
     * @throws Throwable
     *             Any uncaught exception causes test to fail
     */
public void testGetElementsByTagNameNS1() throws Throwable {
    Document doc;
    Document newDoc;
    DocumentType docType = null;
    DOMImplementation domImpl;
    NodeList childList;
    String nullNS = null;
    doc = (Document) load("staffNS", builder);
    domImpl = doc.getImplementation();
    newDoc = domImpl.createDocument(nullNS, "root", docType);
    childList = newDoc.getElementsByTagNameNS("*", "*");
    assertEquals("documentgetelementsbytagnameNS01", 1, childList.getLength());
}
Also used : NodeList(org.w3c.dom.NodeList) DocumentType(org.w3c.dom.DocumentType) DOMImplementation(org.w3c.dom.DOMImplementation) Document(org.w3c.dom.Document)

Example 13 with DocumentType

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

the class DocumentImportNode method testImportNode8.

public void testImportNode8() throws Throwable {
    Document doc;
    DocumentType docType;
    DOMImplementation domImpl;
    String nullNS = null;
    doc = (Document) load("staffNS", builder);
    domImpl = doc.getImplementation();
    docType = domImpl.createDocumentType("test:root", nullNS, nullNS);
    {
        boolean success = false;
        try {
            doc.importNode(docType, true);
        } catch (DOMException ex) {
            success = (ex.code == DOMException.NOT_SUPPORTED_ERR);
        }
        assertTrue("throw_NOT_SUPPORTED_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 14 with DocumentType

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

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

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