FileDocCategorySizeDatePackage
createDocument04.javaAPI DocAndroid 1.5 API4105Wed May 06 22:41:04 BST 2009org.w3c.domts.level2.core

createDocument04

public final class createDocument04 extends org.w3c.domts.DOMTestCase
The "createDocument(namespaceURI,qualifiedName,doctype)" method for a DOMImplementation should raise WRONG_DOCUMENT_ERR DOMException if parameter doctype was created from a different implementation. Invoke method createDocument(namespaceURI,qualifiedName,doctype) on a domimplementation that is different from this domimplementation. Doctype is the type of this document. Method should raise WRONG_DOCUMENT_ERR DOMException.
author
NIST
author
Mary Brady
see
http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-258A00AF')/constant[@name='WRONG_DOCUMENT_ERR'])
see
http://www.w3.org/TR/DOM-Level-2-Core/core#Level-2-Core-DOM-createDocument
see
http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('Level-2-Core-DOM-createDocument')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='WRONG_DOCUMENT_ERR'])

Fields Summary
Constructors Summary
public createDocument04(org.w3c.domts.DOMTestDocumentBuilderFactory factory)
Constructor.

param
factory document factory, may not be null
throws
org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration

      super(factory);

    //
    //   check if loaded documents are supported for content type
    //
    String contentType = getContentType();
    preload(contentType, "staffNS", false);
    preload(contentType, "staffNS", false);
    
Methods Summary
public java.lang.StringgetTargetURI()
Gets URI that identifies the test.

return
uri identifier of test

      return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/createDocument04";
   
public static voidmain(java.lang.String[] args)
Runs this test from the command line.

param
args command line arguments

        DOMTestCase.doMain(createDocument04.class, args);
   
public voidrunTest()
Runs the test case.

throws
Throwable Any uncaught exception causes test to fail

      String namespaceURI = "http://www.ecommerce.org/schema";
      String qualifiedName = "namespaceURI:x";
      Document doc;
      DocumentType docType;
      DOMImplementation domImpl;
      Document aNewDoc;
      doc = (Document) load("staffNS", false);
      aNewDoc = (Document) load("staffNS", false);
      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);
      }