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