1 2 /* 3 This Java source file was generated by test-to-java.xsl 4 and is a derived work from the source document. 5 The source document contained the following notice: 6 7 8 9 Copyright (c) 2001 World Wide Web Consortium, 10 (Massachusetts Institute of Technology, Institut National de 11 Recherche en Informatique et en Automatique, Keio University). All 12 Rights Reserved. This program is distributed under the W3C's Software 13 Intellectual Property License. This program is distributed in the 14 hope that it will be useful, but WITHOUT ANY WARRANTY; without even 15 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 16 PURPOSE. 17 18 See W3C License http://www.w3.org/Consortium/Legal/ for more details. 19 20 21 */ 22 23 package org.w3c.domts.level2.core; 24 25 import org.w3c.dom.*; 26 27 28 import org.w3c.domts.DOMTestCase; 29 import org.w3c.domts.DOMTestDocumentBuilderFactory; 30 31 32 33 /** 34 * The "createDocument(namespaceURI,qualifiedName,doctype)" method for a 35 * DOMImplementation should raise NAMESPACE_ERR DOMException 36 * if qualifiedName has the "xml" prefix and namespaceURI different from 37 * "http://www.w3.org/XML/1998/namespace" 38 * 39 * Invoke method createDocument(namespaceURI,qualifiedName,doctype) on 40 * this domimplementation with qualifiedName "xml:local" 41 * and namespaceURI as the string 42 * "http://www.ecommerce.org/schema" (which is different from the required 43 * "http://www.w3.org/XML/1998/namespace"). Method should raise 44 * NAMESPACE_ERR DOMException. 45 * @author NIST 46 * @author Mary Brady 47 * @see <a href="http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-258A00AF')/constant[@name='NAMESPACE_ERR'])">http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-258A00AF')/constant[@name='NAMESPACE_ERR'])</a> 48 * @see <a href="http://www.w3.org/TR/DOM-Level-2-Core/core#Level-2-Core-DOM-createDocument">http://www.w3.org/TR/DOM-Level-2-Core/core#Level-2-Core-DOM-createDocument</a> 49 * @see <a href="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(.,':')='NAMESPACE_ERR'])">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(.,':')='NAMESPACE_ERR'])</a> 50 */ 51 public final class createDocument06 extends DOMTestCase { 52 53 /** 54 * Constructor. 55 * @param factory document factory, may not be null 56 * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration 57 */ 58 public createDocument06(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { 59 super(factory); 60 61 // 62 // check if loaded documents are supported for content type 63 // 64 String contentType = getContentType(); 65 preload(contentType, "staffNS", false); 66 } 67 68 /** 69 * Runs the test case. 70 * @throws Throwable Any uncaught exception causes test to fail 71 */ 72 public void runTest() throws Throwable { 73 String namespaceURI = "http://ecommerce.org/schema"; 74 String qualifiedName = "xml:local"; 75 Document doc; 76 DocumentType docType = null; 77 78 DOMImplementation domImpl; 79 Document aNewDoc; 80 doc = (Document) load("staffNS", false); 81 domImpl = doc.getImplementation(); 82 83 { 84 boolean success = false; 85 try { 86 aNewDoc = domImpl.createDocument(namespaceURI, qualifiedName, docType); 87 } catch (DOMException ex) { 88 success = (ex.code == DOMException.NAMESPACE_ERR); 89 } 90 assertTrue("throw_NAMESPACE_ERR", success); 91 } 92 } 93 /** 94 * Gets URI that identifies the test. 95 * @return uri identifier of test 96 */ 97 public String getTargetURI() { 98 return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/createDocument06"; 99 } 100 /** 101 * Runs this test from the command line. 102 * @param args command line arguments 103 */ 104 public static void main(final String[] args) { 105 DOMTestCase.doMain(createDocument06.class, args); 106 } 107 } 108 109