1 2/* 3This Java source file was generated by test-to-java.xsl 4and is a derived work from the source document. 5The source document contained the following notice: 6 7 8 9Copyright (c) 2001-2003 World Wide Web Consortium, 10(Massachusetts Institute of Technology, Institut National de 11Recherche en Informatique et en Automatique, Keio University). All 12Rights Reserved. This program is distributed under the W3C's Software 13Intellectual Property License. This program is distributed in the 14hope that it will be useful, but WITHOUT ANY WARRANTY; without even 15the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 16PURPOSE. 17 18See W3C License http://www.w3.org/Consortium/Legal/ for more details. 19 20 21*/ 22 23package org.w3c.domts.level2.core; 24 25import org.w3c.dom.*; 26 27 28import org.w3c.domts.DOMTestCase; 29import org.w3c.domts.DOMTestDocumentBuilderFactory; 30 31 32 33/** 34 * The "removeAttributeNS(namespaceURI,localName)" removes an attribute by 35 * local name and namespace URI. If the removed attribute has a 36 * default value it is immediately replaced. The replacing attribute has the same 37 * namespace URI and local name, as well as the original prefix. 38 * 39 * Retrieve the attribute named "emp:local" from emp:address 40 * node, then remove the "emp:local" 41 * attribute by invoking the "removeAttributeNS(namespaceURI,localName)" method. 42 * The "emp:local" attribute has a default value defined in the 43 * DTD file, that value should immediately replace the old 44 * value. 45* @author NIST 46* @author Mary Brady 47* @see <a href="http://www.w3.org/TR/DOM-Level-2-Core/core#ID-ElRemAtNS">http://www.w3.org/TR/DOM-Level-2-Core/core#ID-ElRemAtNS</a> 48* @see <a href="http://www.w3.org/Bugs/Public/show_bug.cgi?id=238">http://www.w3.org/Bugs/Public/show_bug.cgi?id=238</a> 49*/ 50public final class removeAttributeNS02 extends DOMTestCase { 51 52 /** 53 * Constructor. 54 * @param factory document factory, may not be null 55 * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration 56 */ 57 public removeAttributeNS02(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { 58 59 org.w3c.domts.DocumentBuilderSetting[] settings = 60 new org.w3c.domts.DocumentBuilderSetting[] { 61org.w3c.domts.DocumentBuilderSetting.namespaceAware, 62org.w3c.domts.DocumentBuilderSetting.validating 63 }; 64 DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); 65 setFactory(testFactory); 66 67 // 68 // check if loaded documents are supported for content type 69 // 70 String contentType = getContentType(); 71 preload(contentType, "staffNS", true); 72 } 73 74 /** 75 * Runs the test case. 76 * @throws Throwable Any uncaught exception causes test to fail 77 */ 78 public void runTest() throws Throwable { 79 Document doc; 80 NodeList elementList; 81 Node testAddr; 82 Attr addrAttr; 83 String attr; 84 String namespaceURI; 85 String localName; 86 String prefix; 87 doc = (Document) load("staffNS", true); 88 elementList = doc.getElementsByTagName("emp:address"); 89 testAddr = elementList.item(0); 90 ((Element) /*Node */testAddr).removeAttributeNS("http://www.nist.gov", "local1"); 91 elementList = doc.getElementsByTagName("emp:address"); 92 testAddr = elementList.item(0); 93 addrAttr = ((Element) /*Node */testAddr).getAttributeNodeNS("http://www.nist.gov", "local1"); 94 attr = ((Element) /*Node */testAddr).getAttributeNS("http://www.nist.gov", "local1"); 95 namespaceURI = addrAttr.getNamespaceURI(); 96 localName = addrAttr.getLocalName(); 97 prefix = testAddr.getPrefix(); 98 assertEquals("attr", "FALSE", attr); 99 assertEquals("uri", "http://www.nist.gov", namespaceURI); 100 assertEquals("lname", "local1", localName); 101 assertEquals("prefix", "emp", prefix); 102 } 103 /** 104 * Gets URI that identifies the test. 105 * @return uri identifier of test 106 */ 107 public String getTargetURI() { 108 return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/removeAttributeNS02"; 109 } 110 /** 111 * Runs this test from the command line. 112 * @param args command line arguments 113 */ 114 public static void main(final String[] args) { 115 DOMTestCase.doMain(removeAttributeNS02.class, args); 116 } 117} 118 119