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 "setAttributeNS(namespaceURI,qualifiedName,value)" method raises a 48 * NAMESPACE_ERR DOMException if the specified 49 * qualifiedName has a prefix and the namespaceURI is null. 50 * 51 * Attempt to add a new attribute on the first employee node. 52 * An exception should be raised since the "qualifiedName" has a 53 * prefix and the namespaceURI is null. 54 * @author NIST 55 * @author Mary Brady 56 * @see <a href="http://www.w3.org/TR/DOM-Level-2-Core/core#ID-ElSetAttrNS">http://www.w3.org/TR/DOM-Level-2-Core/core#ID-ElSetAttrNS</a> 57 * @see <a href="http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-ElSetAttrNS')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NAMESPACE_ERR'])">http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-ElSetAttrNS')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NAMESPACE_ERR'])</a> 58 */ 59 public final class elementsetattributensurinull extends DOMTestCase { 60 61 /** 62 * Constructor. 63 * @param factory document factory, may not be null 64 * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration 65 */ 66 public elementsetattributensurinull(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { 67 super(factory); 68 69 // 70 // check if loaded documents are supported for content type 71 // 72 String contentType = getContentType(); 73 preload(contentType, "staff", true); 74 } 75 76 /** 77 * Runs the test case. 78 * @throws Throwable Any uncaught exception causes test to fail 79 */ 80 public void runTest() throws Throwable { 81 String namespaceURI = null; 82 83 String qualifiedName = "emp:qualifiedName"; 84 Document doc; 85 NodeList elementList; 86 Node testAddr; 87 doc = (Document) load("staff", true); 88 elementList = doc.getElementsByTagName("employee"); 89 testAddr = elementList.item(0); 90 91 { 92 boolean success = false; 93 try { 94 ((Element) /*Node */testAddr).setAttributeNS(namespaceURI, qualifiedName, "newValue"); 95 } catch (DOMException ex) { 96 success = (ex.code == DOMException.NAMESPACE_ERR); 97 } 98 assertTrue("throw_NAMESPACE_ERR", success); 99 } 100 } 101 /** 102 * Gets URI that identifies the test. 103 * @return uri identifier of test 104 */ 105 public String getTargetURI() { 106 return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/elementsetattributensurinull"; 107 } 108 /** 109 * Runs this test from the command line. 110 * @param args command line arguments 111 */ 112 public static void main(final String[] args) { 113 DOMTestCase.doMain(elementsetattributensurinull.class, args); 114 } 115 } 116 117