OLD | NEW |
1 | |
2 /* | 1 /* |
3 Copyright © 2001-2004 World Wide Web Consortium, | 2 Copyright © 2001-2004 World Wide Web Consortium, |
4 (Massachusetts Institute of Technology, European Research Consortium | 3 (Massachusetts Institute of Technology, European Research Consortium |
5 for Informatics and Mathematics, Keio University). All | 4 for Informatics and Mathematics, Keio University). All |
6 Rights Reserved. This work is distributed under the W3C® Software License [1] i
n the | 5 Rights Reserved. This work is distributed under the W3C® Software License [1] i
n the |
7 hope that it will be useful, but WITHOUT ANY WARRANTY; without even | 6 hope that it will be useful, but WITHOUT ANY WARRANTY; without even |
8 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 7 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
9 | 8 |
10 [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 | 9 [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 |
11 */ | 10 */ |
12 | 11 |
13 | |
14 // expose test function names | 12 // expose test function names |
15 function exposeTestFunctionNames() | 13 function exposeTestFunctionNames() |
16 { | 14 { |
17 return ['XPathNSResolver_lookupNamespaceURI_nist_dmstc']; | 15 return ['XPathNSResolver_lookupNamespaceURI_nist_dmstc']; |
18 } | 16 } |
19 | 17 |
20 var docsLoaded = -1000000; | 18 var docsLoaded = -1000000; |
21 var builder = null; | 19 var builder = null; |
22 | 20 |
23 // | 21 // |
24 // This function is called by the testing framework before | 22 // This function is called by the testing framework before |
25 // running the test suite. | 23 // running the test suite. |
26 // | 24 // |
27 // If there are no configuration exceptions, asynchronous | 25 // If there are no configuration exceptions, asynchronous |
28 // document loading is started. Otherwise, the status | 26 // document loading is started. Otherwise, the status |
29 // is set to complete and the exception is immediately | 27 // is set to complete and the exception is immediately |
30 // raised when entering the body of the test. | 28 // raised when entering the body of the test. |
31 // | 29 // |
32 function setUpPage() { | 30 function setUpPage() { |
33 setUpPageStatus = 'running'; | 31 setUpPageStatus = 'running'; |
34 try { | 32 try { |
35 // | 33 // |
36 // creates test document builder, may throw exception | 34 // creates test document builder, may throw exception |
37 // | 35 // |
38 builder = createConfiguredBuilder(); | 36 builder = createConfiguredBuilder(); |
39 | 37 |
40 docsLoaded = 0; | 38 docsLoaded = 0; |
41 | 39 |
42 var docRef = null; | 40 var docRef = null; |
43 if (typeof(this.doc) != 'undefined') { | 41 if (typeof(this.doc) != 'undefined') { |
44 docRef = this.doc; | 42 docRef = this.doc; |
45 } | 43 } |
46 docsLoaded += preload(docRef, "doc", "staffNS"); | 44 docsLoaded += preload(docRef, "doc", "staffNS"); |
47 | 45 |
48 if (docsLoaded == 1) { | 46 if (docsLoaded == 1) { |
49 setUpPageStatus = 'complete'; | 47 setUpPageStatus = 'complete'; |
50 } | 48 } |
51 } catch(ex) { | 49 } catch(ex) { |
52 » catchInitializationError(builder, ex); | 50 catchInitializationError(builder, ex); |
53 setUpPageStatus = 'complete'; | 51 setUpPageStatus = 'complete'; |
54 } | 52 } |
55 } | 53 } |
56 | 54 |
57 | |
58 | |
59 // | 55 // |
60 // This method is called on the completion of | 56 // This method is called on the completion of |
61 // each asychronous load started in setUpTests. | 57 // each asychronous load started in setUpTests. |
62 // | 58 // |
63 // When every synchronous loaded document has completed, | 59 // When every synchronous loaded document has completed, |
64 // the page status is changed which allows the | 60 // the page status is changed which allows the |
65 // body of the test to be executed. | 61 // body of the test to be executed. |
66 function loadComplete() { | 62 function loadComplete() { |
67 if (++docsLoaded == 1) { | 63 if (++docsLoaded == 1) { |
68 setUpPageStatus = 'complete'; | 64 setUpPageStatus = 'complete'; |
69 } | 65 } |
70 } | 66 } |
71 | 67 |
| 68 /** |
| 69 * |
| 70 Interate over all employee elements with xmlns:dmstc attribute |
| 71 in the test document, creating nsresolvers checking that |
| 72 for all children the prefix 'nist' resolves to |
| 73 http://www.nist.gov and that prefix 'dmstc' resolves to the same |
| 74 value as employee.getAttribute('xmlns:dmstc'). |
72 | 75 |
73 /** | |
74 * | |
75 Interate over all employee elements with xmlns:dmstc attribute | |
76 in the test document, creating nsresolvers checking that | |
77 for all children the prefix 'nist' resolves to | |
78 http://www.nist.gov and that prefix 'dmstc' resolves to the same | |
79 value as employee.getAttribute('xmlns:dmstc'). | |
80 | |
81 * @author Bob Clary | 76 * @author Bob Clary |
82 * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-XPath-20030331/xpath#XPathEvalua
tor | 77 * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-XPath-20030331/xpath#XPathEvalua
tor |
83 * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-XPath-20030331/xpath#XPathEvalua
tor-createNSResolver | 78 * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-XPath-20030331/xpath#XPathEvalua
tor-createNSResolver |
84 * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-XPath-20030331/xpath#XPathNSReso
lver | 79 * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-XPath-20030331/xpath#XPathNSReso
lver |
85 * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-XPath-20030331/xpath#XPathNSReso
lver-lookupNamespaceURI | 80 * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-XPath-20030331/xpath#XPathNSReso
lver-lookupNamespaceURI |
86 */ | 81 */ |
87 function XPathNSResolver_lookupNamespaceURI_nist_dmstc() { | 82 function XPathNSResolver_lookupNamespaceURI_nist_dmstc() { |
88 var success; | 83 var success; |
89 if(checkInitialization(builder, "XPathNSResolver_lookupNamespaceURI_nist_dms
tc") != null) return; | 84 if(checkInitialization(builder, "XPathNSResolver_lookupNamespaceURI_nist_dms
tc") != null) return; |
90 var doc; | 85 var doc; |
91 var resolver; | 86 var resolver; |
92 var evaluator; | 87 var evaluator; |
93 var lookupNamespaceURI; | 88 var lookupNamespaceURI; |
94 var namespaceURI; | 89 var namespaceURI; |
95 var child; | 90 var child; |
96 var children; | 91 var children; |
97 var employee; | 92 var employee; |
98 var employees; | 93 var employees; |
99 | 94 |
100 var docRef = null; | 95 var docRef = null; |
101 if (typeof(this.doc) != 'undefined') { | 96 if (typeof(this.doc) != 'undefined') { |
102 docRef = this.doc; | 97 docRef = this.doc; |
103 } | 98 } |
104 doc = load(docRef, "doc", "staffNS"); | 99 doc = load(docRef, "doc", "staffNS"); |
105 employees = doc.getElementsByTagNameNS("*","employee"); | 100 employees = doc.getElementsByTagNameNS("*","employee"); |
106 evaluator = createXPathEvaluator(doc); | 101 evaluator = createXPathEvaluator(doc); |
107 for(var indexN65633 = 0;indexN65633 < employees.length; indexN65633++) { | 102 for(var indexN65633 = 0;indexN65633 < employees.length; indexN65633++) { |
108 employee = employees.item(indexN65633); | 103 employee = employees.item(indexN65633); |
109 namespaceURI = employee.getAttribute("xmlns:dmstc"); | 104 namespaceURI = employee.getAttribute("xmlns:dmstc"); |
110 children = employee.getElementsByTagNameNS("*","*"); | 105 children = employee.getElementsByTagNameNS("*","*"); |
111 for(var indexN65650 = 0;indexN65650 < children.length; indexN65650++) { | 106 for(var indexN65650 = 0;indexN65650 < children.length; indexN65650++) { |
112 child = children.item(indexN65650); | 107 child = children.item(indexN65650); |
113 resolver = evaluator.createNSResolver(child); | 108 resolver = evaluator.createNSResolver(child); |
114 lookupNamespaceURI = resolver.lookupNamespaceURI("dmstc"); | 109 lookupNamespaceURI = resolver.lookupNamespaceURI("dmstc"); |
115 assertEquals("dmstcequal",namespaceURI,lookupNamespaceURI); | 110 assertEquals("dmstcequal",namespaceURI,lookupNamespaceURI); |
116 lookupNamespaceURI = resolver.lookupNamespaceURI("nist"); | 111 lookupNamespaceURI = resolver.lookupNamespaceURI("nist"); |
117 assertEquals("nistequal","http://www.nist.gov",lookupNamespaceURI); | 112 assertEquals("nistequal","http://www.nist.gov",lookupNamespaceURI); |
118 | 113 |
119 » } | 114 } |
120 | 115 |
121 » } | 116 } |
122 | 117 |
123 } | 118 } |
124 | 119 |
125 | |
126 | |
127 | |
128 function runTest() { | 120 function runTest() { |
129 XPathNSResolver_lookupNamespaceURI_nist_dmstc(); | 121 XPathNSResolver_lookupNamespaceURI_nist_dmstc(); |
130 } | 122 } |
OLD | NEW |