Search in sources :

Example 16 with DOMModelImpl

use of org.eclipse.wst.xml.core.internal.document.DOMModelImpl in project webtools.sourceediting by eclipse.

the class DOMImplementationTests method testCreateDocumentUsedDoctype.

public void testCreateDocumentUsedDoctype() {
    final DOMModelImpl model = (DOMModelImpl) StructuredModelManager.getModelManager().createUnManagedStructuredModelFor(ContentTypeIdForXML.ContentTypeID_XML);
    final DocumentType doctype = model.createDocumentType("bar", "publicTest", "systemTest");
    IDOMDocument document = model.getDocument();
    document.appendChild(doctype);
    try {
        model.createDocument("http://eclipse.org", "foo:bar", doctype);
    } catch (DOMException e) {
        assertEquals("Wrong DOMExcetion thrown", DOMException.WRONG_DOCUMENT_ERR, e.code);
        return;
    }
    fail("Reusing the doctype from another document should have caused an exception");
}
Also used : DOMException(org.w3c.dom.DOMException) DOMModelImpl(org.eclipse.wst.xml.core.internal.document.DOMModelImpl) DocumentType(org.w3c.dom.DocumentType) IDOMDocument(org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument)

Example 17 with DOMModelImpl

use of org.eclipse.wst.xml.core.internal.document.DOMModelImpl in project webtools.sourceediting by eclipse.

the class DOMImplementationTests method testCreateDocumentMalformedQualifiedNames.

public void testCreateDocumentMalformedQualifiedNames() {
    final DOMModelImpl model = (DOMModelImpl) StructuredModelManager.getModelManager().createUnManagedStructuredModelFor(ContentTypeIdForXML.ContentTypeID_XML);
    final String[] names = { "foo:", "foo:.", "foo:-", "foo:bar:baz" };
    for (int i = 0; i < names.length; i++) {
        try {
            model.createDocument("http://eclipse.org", names[i], null);
        } catch (DOMException e) {
            assertEquals("Did not receive the correct DOMException for [" + names[i] + "]", DOMException.NAMESPACE_ERR, e.code);
            continue;
        }
        fail("Malformd qualified name [" + names[i] + "]");
    }
}
Also used : DOMException(org.w3c.dom.DOMException) DOMModelImpl(org.eclipse.wst.xml.core.internal.document.DOMModelImpl)

Example 18 with DOMModelImpl

use of org.eclipse.wst.xml.core.internal.document.DOMModelImpl in project webtools.sourceediting by eclipse.

the class DOMImplementationTests method testCreateDocumentIllegalNamespaceXML.

public void testCreateDocumentIllegalNamespaceXML() {
    final DOMModelImpl model = (DOMModelImpl) StructuredModelManager.getModelManager().createUnManagedStructuredModelFor(ContentTypeIdForXML.ContentTypeID_XML);
    try {
        model.createDocument("http://eclipse.org", "xml:bar", null);
    } catch (DOMException e) {
        assertEquals("Did not receive the correct DOMException", DOMException.NAMESPACE_ERR, e.code);
        return;
    }
    fail("No exceptions for illegal input");
}
Also used : DOMException(org.w3c.dom.DOMException) DOMModelImpl(org.eclipse.wst.xml.core.internal.document.DOMModelImpl)

Example 19 with DOMModelImpl

use of org.eclipse.wst.xml.core.internal.document.DOMModelImpl in project webtools.sourceediting by eclipse.

the class NodeImplTestCase method setUp.

/**
 * Sets up the test fixture.
 * (Called before every test case method.)
 */
protected void setUp() {
    DOMModelImpl model = new DOMModelImpl();
    document = model.getDocument();
    element = (NodeImpl) document.createElement("testelement");
    attribute = (AttrImpl) document.createAttribute("attribute");
}
Also used : DOMModelImpl(org.eclipse.wst.xml.core.internal.document.DOMModelImpl)

Aggregations

DOMModelImpl (org.eclipse.wst.xml.core.internal.document.DOMModelImpl)19 DOMException (org.w3c.dom.DOMException)7 IDOMDocument (org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument)6 IOException (java.io.IOException)5 InputStream (java.io.InputStream)5 IModelManager (org.eclipse.wst.sse.core.internal.provisional.IModelManager)5 IDOMModel (org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel)5 IStructuredDocument (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument)4 Document (org.w3c.dom.Document)4 Node (org.w3c.dom.Node)3 DocumentType (org.w3c.dom.DocumentType)2 Preferences (org.eclipse.core.runtime.Preferences)1 IDocumentPartitioner (org.eclipse.jface.text.IDocumentPartitioner)1 PageDirectiveAdapter (org.eclipse.jst.jsp.core.internal.document.PageDirectiveAdapter)1 JSPSourceParser (org.eclipse.jst.jsp.core.internal.parser.JSPSourceParser)1 StructuredTextPartitionerForJSP (org.eclipse.jst.jsp.core.internal.text.StructuredTextPartitionerForJSP)1 StructuredTextPartitionerForHTML (org.eclipse.wst.html.core.internal.text.StructuredTextPartitionerForHTML)1 IStructuredCleanupPreferences (org.eclipse.wst.sse.core.internal.cleanup.IStructuredCleanupPreferences)1 StructuredCleanupPreferences (org.eclipse.wst.sse.core.internal.cleanup.StructuredCleanupPreferences)1 IDOMNode (org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode)1