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 "getElementsByTagNameNS(namespaceURI,localName)" method returns a NodeList 35 * of all descendant Elements with a given local name and namespace URI in the 36 * order in which they are encountered in a preorder traversal of this Element tree. 37 * 38 * Create a NodeList of all the descendant elements of the document element 39 * using the "http://www.nist.gov" as the namespaceURI and the special value "*" as the 40 * localName. 41 * The method should return a NodeList of elements that have "http://www.nist.gov 42 * as a namespace URI. 43 * Derived from getElementsByTagNameNS03 44 * @author Curt Arnold 45 * @author Curt Arnold 46 * @see <a href="http://www.w3.org/TR/DOM-Level-2-Core/core#ID-1938918D">http://www.w3.org/TR/DOM-Level-2-Core/core#ID-1938918D</a> 47 */ 48 public final class getElementsByTagNameNS10 extends DOMTestCase { 49 50 /** 51 * Constructor. 52 * @param factory document factory, may not be null 53 * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration 54 */ 55 public getElementsByTagNameNS10(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { 56 57 org.w3c.domts.DocumentBuilderSetting[] settings = 58 new org.w3c.domts.DocumentBuilderSetting[] { 59 org.w3c.domts.DocumentBuilderSetting.namespaceAware 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", false); 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 Element docElem; 78 NodeList elementList; 79 Node child; 80 String childName; 81 java.util.List result = new java.util.ArrayList(); 82 83 java.util.List expectedResult = new java.util.ArrayList(); 84 expectedResult.add("employee"); 85 expectedResult.add("employeeId"); 86 expectedResult.add("name"); 87 expectedResult.add("position"); 88 expectedResult.add("salary"); 89 expectedResult.add("gender"); 90 expectedResult.add("address"); 91 expectedResult.add("emp:employee"); 92 expectedResult.add("emp:employeeId"); 93 expectedResult.add("emp:position"); 94 expectedResult.add("emp:salary"); 95 expectedResult.add("emp:gender"); 96 expectedResult.add("emp:address"); 97 expectedResult.add("address"); 98 99 doc = (Document) load("staffNS", false); 100 docElem = doc.getDocumentElement(); 101 elementList = docElem.getElementsByTagNameNS("http://www.nist.gov", "*"); 102 for (int indexN1007E = 0; indexN1007E < elementList.getLength(); indexN1007E++) { 103 child = (Node) elementList.item(indexN1007E); 104 childName = child.getNodeName(); 105 result.add(childName); 106 } 107 assertEquals("nodeNames", expectedResult, result); 108 } 109 /** 110 * Gets URI that identifies the test. 111 * @return uri identifier of test 112 */ 113 public String getTargetURI() { 114 return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/getElementsByTagNameNS10"; 115 } 116 /** 117 * Runs this test from the command line. 118 * @param args command line arguments 119 */ 120 public static void main(final String[] args) { 121 DOMTestCase.doMain(getElementsByTagNameNS10.class, args); 122 } 123 } 124 125