1 <!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
2 <html xmlns=
"http://www.w3.org/1999/xhtml" xml:
lang=
"en" lang=
"en">
6 .passed {background-color:lightgreen;}
7 .failed {background-color:red;}
14 var myValidator
= null;
22 function getValidator() {
23 netscape
.security
.PrivilegeManager
.enablePrivilege('UniversalXPConnect');
25 myValidator
= Components
.classes
["@mozilla.org/xmlextras/schemas/schemavalidator;1"]
26 .getService(Components
.interfaces
.nsISchemaValidator
);
30 function validateComplexType(aID
, aType
, aIsValid
){
34 var xmlHTTP
= new XMLHttpRequest();
35 xmlHTTP
.open("GET", document
.URL
+ "/../schema-complex-test.xml", false);
37 gXMLDoc
= xmlHTTP
.responseXML
;
40 var elm
= gXMLDoc
.getElementById(aID
);
42 alert("No element found!");
44 //elm.removeAttribute("id");
45 rv
= getValidator().validate(elm
);
49 results
[results
.length
] = {type
: aType
, nodevalue
: aID
, rv
: rv
, isvalid
: aIsValid
};
52 function validateFile(aFile
, aSchema
, aIsValid
) {
53 netscape
.security
.PrivilegeManager
.enablePrivilege('UniversalXPConnect');
56 var myValidator
= Components
.classes
["@mozilla.org/schemavalidator;1"].createInstance(Components
.interfaces
.nsISchemaValidator
);
57 } catch(e
){ alert(e
) }
59 var schemaLoader
= Components
.classes
["@mozilla.org/schemavalidator/schemaloader;1"]
60 .getService(Components
.interfaces
.nsISVSchemaLoader
);
62 schema
= schemaLoader
.load(aSchema
);
63 myValidator
.loadSchema(schema
);
68 var xmlHTTP
= new XMLHttpRequest();
69 xmlHTTP
.open("GET", aFile
, false);
71 xmlDoc
= xmlHTTP
.responseXML
;
73 xmlDoc
.documentElement
.removeAttributeNS("http://www.w3.org/2001/XMLSchema-instance", "schemaLocation");
74 rv
= getValidator().validate(xmlDoc
.documentElement
);
77 results
[results
.length
] = {type
: "file", nodevalue
: "", rv
: rv
, isvalid
: aIsValid
};
80 function displayResults(){
81 var tbody
= document
.createElement("tbody");
83 for (var run
= 0; run
< results
.length
; run
++){
84 tr
= document
.createElement("tr");
86 td
= document
.createElement("td");
87 textNode
= document
.createTextNode(run
+ 1);
88 td
.appendChild(textNode
);
91 td
= document
.createElement("td");
92 textNode
= document
.createTextNode(results
[run
].type
);
93 td
.appendChild(textNode
);
96 td
= document
.createElement("td");
97 textNode
= document
.createTextNode(results
[run
].nodevalue
);
98 td
.appendChild(textNode
);
101 td
= document
.createElement("td");
102 textNode
= document
.createTextNode(results
[run
].rv
);
103 td
.appendChild(textNode
);
106 td
= document
.createElement("td");
107 textNode
= document
.createTextNode(results
[run
].isvalid
);
108 td
.appendChild(textNode
);
111 td
= document
.createElement("td");
112 textNode
= document
.createTextNode((results
[run
].rv
== results
[run
].isvalid
) ? "Passed" : "Failed");
113 td
.appendChild(textNode
);
114 td
.className
= (results
[run
].rv
== results
[run
].isvalid
) ? "passed" : "failed";
117 tbody
.appendChild(tr
);
119 if (results
[run
].rv
!=results
[run
].isvalid
)
122 document
.getElementById("resultTable").replaceChild(tbody
, document
.getElementById("results"));
125 var dp
= new DOMParser();
129 netscape
.security
.PrivilegeManager
.enablePrivilege('UniversalXPConnect');
132 myValidator
= Components
.classes
["@mozilla.org/schemavalidator;1"].createInstance(Components
.interfaces
.nsISchemaValidator
);
133 } catch(e
){ alert(e
) }
135 var schemaLoader
= Components
.classes
["@mozilla.org/schemavalidator/schemaloader;1"]
136 .getService(Components
.interfaces
.nsISVSchemaLoader
);
138 // SchemaLoader.Load() wants a URI
139 schema
= schemaLoader
.load(document
.URL
+ "/../schema.xsd");
140 //alert(schema.attributeFormDefaultQualified)
141 myValidator
.loadSchema(schema
);
145 var schemaCollection
= schema
.collection
;
147 document
.getElementById("results").innerHTML
= "";
150 results
= new Array();
155 validateComplexType("balance-1", "balance-1", true);
156 validateComplexType("balance-2", "balance-2", false);
157 validateComplexType("balance-3", "balance-3", false);
158 validateComplexType("balance-4", "balance-4", false);
159 validateComplexType("balance-5", "balance-5", true);
161 validateComplexType("balance2-1", "balance2-1", true);
162 validateComplexType("balance2-2", "balance2-2", false);
163 validateComplexType("balance2-3", "balance2-3", false);
164 validateComplexType("balance2-4", "balance2-4", false);
166 validateComplexType("balance3-1", "balance3-1", true);
167 validateComplexType("balance3-2", "balance3-2", true);
168 validateComplexType("balance3-3", "balance3-3", false);
169 validateComplexType("balance3-4", "balance3-4", true);
170 validateComplexType("balance3-5", "balance3-5", false);
172 validateComplexType("balance4-1", "balance4-1", true);
173 validateComplexType("balance4-2", "balance4-2", true);
174 validateComplexType("balance4-3", "balance4-3", false);
175 validateComplexType("balance4-4", "balance4-4", false);
177 validateComplexType("balance5-1", "balance5-1", true);
178 validateComplexType("balance5-2", "balance5-2", false);
179 validateComplexType("balance5-3", "balance5-3", true);
180 validateComplexType("balance5-4", "balance5-4", true);
181 validateComplexType("balance5-5", "balance5-5", false);
182 validateComplexType("balance5-6", "balance5-6", false);
184 validateComplexType("balance6-1", "balance6-1", true);
185 validateComplexType("balance6-2", "balance6-2", true);
186 validateComplexType("balance6-3", "balance6-3", true);
187 validateComplexType("balance6-4", "balance6-4", true);
188 validateComplexType("balance6-5", "balance6-5", false);
189 validateComplexType("balance6-6", "balance6-6", true);
190 validateComplexType("balance6-7", "balance6-7", true);
191 validateComplexType("balance6-8", "balance6-8", true);
192 validateComplexType("balance6-9", "balance6-9", false);
194 validateComplexType("balance7-1", "balance7-1", false);
195 validateComplexType("balance7-2", "balance7-2", true);
196 validateComplexType("balance7-3", "balance7-3", false);
197 validateComplexType("balance7-4", "balance7-4", true);
198 validateComplexType("balance7-5", "balance7-5", false);
199 validateComplexType("balance7-6", "balance7-6", true);
200 validateComplexType("balance7-7", "balance7-7", true);
201 validateComplexType("balance7-8", "balance7-8", true);
202 validateComplexType("balance7-9", "balance7-9", false);
203 validateComplexType("balance7-10", "balance7-10", false);
204 validateComplexType("balance7-11", "balance7-11", false);
206 validateComplexType("balance8-1", "balance8-1", true);
207 validateComplexType("balance8-2", "balance8-2", true);
208 validateComplexType("balance8-3", "balance8-3", false);
209 validateComplexType("balance8-4", "balance8-4", true);
210 validateComplexType("balance8-5", "balance8-5", true);
211 validateComplexType("balance8-6", "balance8-6", false);
212 validateComplexType("balance8-7", "balance8-7", false);
214 validateComplexType("balance9-1", "balance9-1", true);
215 validateComplexType("balance9-2", "balance9-2", false);
216 validateComplexType("balance9-3", "balance9-3", false);
217 validateComplexType("balance9-4", "balance9-4", true);
218 validateComplexType("balance9-5", "balance9-5", false);
219 validateComplexType("balance9-6", "balance9-6", false);
221 validateComplexType("balance10-1", "balance10-1", false);
222 validateComplexType("balance10-2", "balance10-2", false);
223 validateComplexType("balance10-3", "balance10-3", false);
225 validateComplexType("balance11-1", "balance11-1", true);
226 validateComplexType("balance11-2", "balance11-2", false);
228 validateComplexType("balance12-1", "balance12-1", true);
229 validateComplexType("balance12-2", "balance12-2", true);
230 validateComplexType("balance12-3", "balance12-3", false);
231 validateComplexType("balance12-4", "balance12-4", false);
232 validateComplexType("balance12-5", "balance12-5", false);
234 validateComplexType("t1", "t1", true);
235 validateComplexType("t2", "t2", false);
236 validateComplexType("t3", "t3", true);
237 validateComplexType("t4", "t4", false);
238 validateComplexType("t5", "t5", false);
239 validateComplexType("t6", "t6", true);
240 validateComplexType("t7", "t7", false);
241 validateComplexType("t8", "t8", false);
242 validateComplexType("t9", "t9", false);
243 validateComplexType("t10", "t10", false);
244 validateComplexType("t11", "t11", true);
245 validateComplexType("t12", "t12", true);
246 validateComplexType("t13", "t13", false);
248 validateComplexType("author-1", "author-1", true);
249 validateComplexType("author-2", "author-2", false);
250 validateComplexType("author-3", "author-3", false);
251 validateComplexType("author-4", "author-4", false);
252 validateComplexType("author-5", "author-5", true);
253 validateComplexType("author-6", "author-6", false);
254 validateComplexType("author-7", "author-7", false);
255 validateComplexType("author-8", "author-8", false);
257 validateComplexType("author-2-1", "author-2-1", true);
258 validateComplexType("author-2-2", "author-2-2", false);
259 validateComplexType("author-2-3", "author-2-3", false);
261 validateComplexType("author-3-1", "author-3-1", true);
262 validateComplexType("author-3-2", "author-3-2", true);
264 validateComplexType("author-4-1", "author-4-1", true);
266 validateComplexType("balance-attrgroup-1-1", "balance-attrgroup-1-1", true);
267 validateComplexType("balance-attrgroup-1-2", "balance-attrgroup-1-2", true);
268 validateComplexType("balance-attrgroup-1-3", "balance-attrgroup-1-3", false);
269 validateComplexType("balance-attrgroup-1-4", "balance-attrgroup-1-4", false);
271 validateComplexType("group-1", "group-1", true);
272 validateComplexType("group-2", "group-2", true);
273 validateComplexType("group-3", "group-3", false);
274 validateComplexType("group-4", "group-4", false);
276 validateComplexType("deriv-ext-1-1", "deriv-ext-1-1", true);
277 validateComplexType("deriv-ext-1-2", "deriv-ext-1-2", false);
278 validateComplexType("deriv-ext-1-3", "deriv-ext-1-3", false);
280 validateComplexType("deriv-res-1-1", "deriv-res-1-1", true);
281 validateComplexType("deriv-res-1-2", "deriv-res-1-2", false);
283 validateComplexType("deriv-res-2-1", "deriv-res-2-1", true);
284 validateComplexType("deriv-res-2-2", "deriv-res-2-2", false);
286 validateComplexType("deriv-ext-complex-1-1", "deriv-ext-complex-1-1", true);
287 validateComplexType("deriv-ext-complex-1-2", "deriv-ext-complex-1-2", false);
289 validateComplexType("deriv-ext-restriction-1-1", "deriv-ext-restriction-1-1", true);
290 validateComplexType("deriv-ext-restriction-1-2", "deriv-ext-restriction-1-2", false);
291 validateComplexType("deriv-ext-restriction-1-3", "deriv-ext-restriction-1-3", true);
293 validateComplexType("empty-complex-1-1", "empty-complex-1-1", true);
294 validateComplexType("empty-complex-1-2", "empty-complex-1-2", true);
295 validateComplexType("empty-complex-1-3", "empty-complex-1-3", false);
296 validateComplexType("empty-complex-1-4", "empty-complex-1-4", false);
298 validateComplexType("empty-complex-2-1", "empty-complex-2-1", true);
299 validateComplexType("empty-complex-2-2", "empty-complex-2-2", true);
306 document
.getElementById("finalResults").innerHTML
= counter
+ " Tests Completed, with " + failCounter
+ " Failures" +
307 ". Seconds: " + ((end
-start
) / 1000);
313 <button onclick=
"test()">Do
</button>
315 <div id=
"finalResults"></div>
317 <table border=
1 cellpadding=
0 cellspacing=
0 width=
"100%" id=
"resultTable" style=
"font-size:0.8em;">
323 <td>Should be Valid?
</td>
326 <tbody id=
"results" />