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-2004 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 method removeNamedItemNS removes a node specified by local name and namespace 35 * A removed attribute may be known to have a default value when this map contains the 36 * attributes attached to an element, as returned by the attributes attribute of the Node 37 * interface. If so, an attribute immediately appears containing the default value as well 38 * as the corresponding namespace URI, local name, and prefix when applicable. 39 * 40 * Retreive a default attribute node. Remove it from the NodeMap. Check if a new one immediately 41 * appears containing the default value. 42 * @author IBM 43 * @author Neil Delima 44 * @see <a href="http://www.w3.org/TR/DOM-Level-2-Core/core#ID-D58B193">http://www.w3.org/TR/DOM-Level-2-Core/core#ID-D58B193</a> 45 * @see <a href="http://www.w3.org/Bugs/Public/show_bug.cgi?id=259">http://www.w3.org/Bugs/Public/show_bug.cgi?id=259</a> 46 */ 47 public final class namednodemapremovenameditemns02 extends DOMTestCase { 48 49 /** 50 * Constructor. 51 * @param factory document factory, may not be null 52 * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration 53 */ 54 public namednodemapremovenameditemns02(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { 55 56 org.w3c.domts.DocumentBuilderSetting[] settings = 57 new org.w3c.domts.DocumentBuilderSetting[] { 58 org.w3c.domts.DocumentBuilderSetting.namespaceAware, 59 org.w3c.domts.DocumentBuilderSetting.validating 60 }; 61 DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); 62 setFactory(testFactory); 63 64 // 65 // check if loaded documents are supported for content type 66 // 67 String contentType = getContentType(); 68 preload(contentType, "staffNS", true); 69 } 70 71 /** 72 * Runs the test case. 73 * @throws Throwable Any uncaught exception causes test to fail 74 */ 75 public void runTest() throws Throwable { 76 Document doc; 77 NamedNodeMap attributes; 78 Node element; 79 Attr attribute; 80 NodeList elementList; 81 String attrValue; 82 String nullNS = null; 83 84 doc = (Document) load("staffNS", true); 85 elementList = doc.getElementsByTagNameNS("http://www.nist.gov", "employee"); 86 element = elementList.item(1); 87 attributes = element.getAttributes(); 88 attribute = (Attr) attributes.removeNamedItemNS(nullNS, "defaultAttr"); 89 attribute = (Attr) attributes.getNamedItemNS(nullNS, "defaultAttr"); 90 attrValue = attribute.getNodeValue(); 91 assertNotNull("namednodemapremovenameditemns02", attribute); 92 assertEquals("namednodemapremovenameditemns02_attrValue", "defaultVal", attrValue); 93 } 94 /** 95 * Gets URI that identifies the test. 96 * @return uri identifier of test 97 */ 98 public String getTargetURI() { 99 return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/namednodemapremovenameditemns02"; 100 } 101 /** 102 * Runs this test from the command line. 103 * @param args command line arguments 104 */ 105 public static void main(final String[] args) { 106 DOMTestCase.doMain(namednodemapremovenameditemns02.class, args); 107 } 108 } 109 110