extra: import at 3.0.1 beta 1
[mozilla-extra.git] / extensions / schema-validation / tests / schema.html
blobc1b2771062544050ebe6c52a1b42507823a51760
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">
3 <head>
4 <title></title>
5 <style>
6 .passed {background-color:lightgreen;}
7 .failed {background-color:red;}
9 td {
10 padding:3px;
12 </style>
13 <script>
14 var myValidator = null;
15 var counter;
16 var failCounter = 0;
17 var results;
18 var start;
19 var end;
21 function getValidator() {
22 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
23 if (!myValidator)
24 myValidator = Components.classes["@mozilla.org/xmlextras/schemas/schemavalidator;1"]
25 .getService(Components.interfaces.nsISchemaValidator);
26 return myValidator;
29 function validateDOMNode(aNodeValue, aType, aNSPrefix, aIsValid) {
30 var rv = false;
32 var x = dp.parseFromString('<test xmlns:test="http://www.mozilla.org/schema/test" xmlns:testi="http://www.mozilla.org/schema/test_imported" xmlns="http://www.mozilla.org/schema/test" xmlns:xsi="http://www.w3.org/1999/XMLSchema" xsi:type="' + aNSPrefix + ":" + aType + '">' + aNodeValue + '</test>', "text/xml");
34 rv = getValidator().validate(x.documentElement);
36 counter++;
37 results[results.length] = {type: aType, nodevalue: aNodeValue, rv: rv, isvalid: aIsValid};
40 function validateString(aNodeValue, aType, aIsValid) {
41 var rv = getValidator().validateString(aNodeValue, aType, "http://www.mozilla.org/schema/test");
43 counter++;
44 results[results.length] = {type: aType, nodevalue: aNodeValue, rv: rv, isvalid: aIsValid};
47 function validateStringNS(aNodeValue, aType, aNS, aIsValid) {
48 var rv = getValidator().validateString(aNodeValue, aType, aNS);
50 counter++;
51 results[results.length] = {type: aType, nodevalue: aNodeValue, rv: rv, isvalid: aIsValid};
54 function validateSimpleTypeString(aNodeValue, aType, aIsValid) {
55 var rv = getValidator().validateString(aNodeValue, aType, "http://www.w3.org/1999/XMLSchema");
57 counter++;
58 results[results.length] = {type: aType, nodevalue: aNodeValue, rv: rv, isvalid: aIsValid};
61 function validate(aNodeValue, aType, aIsValid){
62 validateString(aNodeValue, aType, aIsValid);
65 function validateComplexType(aNodeValue, aType, aIsValid){
66 var rv = false;
68 var x = dp.parseFromString(aNodeValue, "application/xml")
69 rv = getValidator().validate(x.documentElement);
71 counter++;
72 results[results.length] = {type: aType, nodevalue: aNodeValue, rv: rv, isvalid: aIsValid};
75 function displayResults(){
76 var tbody = document.createElement("tbody");
77 var tr, td, textNode;
78 for (var run = 0; run < results.length; run++){
79 tr = document.createElement("tr");
81 td = document.createElement("td");
82 textNode = document.createTextNode(run + 1);
83 td.appendChild(textNode);
84 tr.appendChild(td);
86 td = document.createElement("td");
87 textNode = document.createTextNode(results[run].type);
88 td.appendChild(textNode);
89 tr.appendChild(td);
91 td = document.createElement("td");
92 textNode = document.createTextNode(results[run].nodevalue);
93 td.appendChild(textNode);
94 tr.appendChild(td);
96 td = document.createElement("td");
97 textNode = document.createTextNode(results[run].rv);
98 td.appendChild(textNode);
99 tr.appendChild(td);
101 td = document.createElement("td");
102 textNode = document.createTextNode(results[run].isvalid);
103 td.appendChild(textNode);
104 tr.appendChild(td);
106 td = document.createElement("td");
107 textNode = document.createTextNode((results[run].rv == results[run].isvalid) ? "Passed" : "Failed");
108 td.appendChild(textNode);
109 td.className = (results[run].rv == results[run].isvalid) ? "passed" : "failed";
110 tr.appendChild(td);
112 tbody.appendChild(tr);
114 if (results[run].rv!=results[run].isvalid)
115 failCounter++;
117 document.getElementById("resultTable").replaceChild(tbody, document.getElementById("results"));
120 var dp = new DOMParser();
121 var schema;
123 function test() {
124 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
126 try{
127 myValidator = Components.classes["@mozilla.org/schemavalidator;1"].createInstance(Components.interfaces.nsISchemaValidator);
129 }catch(e){ alert(e) }
131 var schemaLoader = Components.classes["@mozilla.org/schemavalidator/schemaloader;1"]
132 .getService(Components.interfaces.nsISVSchemaLoader);
133 try {
134 // SchemaLoader.Load() wants a URI
135 schema = schemaLoader.load(document.URL + "/../schema.xsd");
136 myValidator.loadSchema(schema);
137 } catch(e){alert(e)}
139 //schema collection
140 var schemaCollection = schema.collection;
142 document.getElementById("results").innerHTML = "";
143 counter = 0;
144 failCounter = 0;
145 results = new Array();
147 start = new Date();
149 try {
150 var x = myValidator.validateBuiltinTypeDuration("P200Y30M23DT21H456M3234.345S");
151 alert(x.getSeconds() + " " + x.getFractionSeconds());
152 } catch (e) {
153 alert("invalid")
157 if (1) {
158 validate("220", "integer-test-1", false);
159 validate("2", "integer-test-1", false);
160 validate("-220", "integer-test-1", false);
162 validate("5", "integer-test-1", false);
163 validate("101", "integer-test-1", false);
164 validate("1013", "integer-test-1", false);
165 validate("56", "integer-test-1", true);
167 validate("220", "integer-test-2", false);
168 validate("3", "integer-test-2", false);
169 validate("-56", "integer-test-2", false);
170 validate("-40", "integer-test-2", true);
171 validate("-1", "integer-test-2", true);
172 validate("-34", "integer-test-2", true);
173 validate("002", "integer-test-2", true);
175 validate("-1", "nonPositiveInteger-test-1", true);
176 validate("0", "nonPositiveInteger-test-1", true);
177 validate("1", "nonPositiveInteger-test-1", false);
178 validate("-3452", "nonPositiveInteger-test-1", false);
180 validate("-1", "nonNegativeInteger-test-1", false);
181 validate("0", "nonNegativeInteger-test-1", true);
182 validate("1", "nonNegativeInteger-test-1", true);
183 validate("501", "nonNegativeInteger-test-1", false);
184 validate("499", "nonNegativeInteger-test-1", true);
186 validate("-1", "negativeInteger-test-1", true);
187 validate("-22", "negativeInteger-test-1", true);
188 validate("0", "negativeInteger-test-1", false);
189 validate("1", "negativeInteger-test-1", false);
190 validate("-3452", "negativeInteger-test-1", false);
192 validate("1", "positiveInteger-test-1", true);
193 validate("22", "positiveInteger-test-1", true);
194 validate("0", "positiveInteger-test-1", false);
195 validate("-12", "positiveInteger-test-1", false);
196 validate("3452", "positiveInteger-test-1", false);
198 validate("127", "byte-test-1", true);
199 validate("-128", "byte-test-1", true);
200 validate("-12", "byte-test-1", true);
201 validate("5", "byte-test-1", true);
202 validate("129", "byte-test-1", false);
203 validate("-135", "byte-test-1", false);
205 validate("127", "byte-test-2", false);
206 validate("40", "byte-test-2", false);
207 validate("-40", "byte-test-2", false);
208 validate("38", "byte-test-2", true);
209 validate("-1", "byte-test-2", true);
211 validate("127", "byte-test-3", false);
212 validate("40", "byte-test-3", true);
213 validate("-40", "byte-test-3", true);
214 validate("38", "byte-test-3", true);
215 validate("-1", "byte-test-3", true);
217 validate("-1", "float-test-1", false);
218 validate("1.230", "float-test-1", true);
219 validate("2.23022", "float-test-1", true);
220 validate("3.34", "float-test-1", false);
221 validate("3.340", "float-test-1", false);
222 validate("3.5", "float-test-1", false);
223 validate("0.1", "float-test-1", false);
224 validate("0.98", "float-test-1", false);
225 validate("1.02", "float-test-1", true);
226 validate("2011.0E-3", "float-test-1", true);
228 validate("8.342", "float-test-2", false);
229 validate("-3.46", "float-test-2", false);
230 validate("3.34", "float-test-2", true);
231 validate("2.34", "float-test-2", true);
232 validate("-1.98", "float-test-2", true);
233 validate("-1.99", "float-test-2", false);
234 validate("-5.32", "float-test-2", false);
236 validate("-INF", "float-test-3", true);
237 validate("INF", "float-test-3", false);
238 validate("NaN", "float-test-3", false);
239 validate("4.21e4", "float-test-3", true);
241 validate("-1", "double-test-1", false);
242 validate("1.230", "double-test-1", true);
243 validate("3.34", "double-test-1", false);
244 validate("0.98", "double-test-1", false);
245 validate("2011.0E-3", "double-test-1", true);
247 validate("1.98e-14", "double-test-2", false);
248 validate("0", "double-test-2", false);
249 validate("1.230", "double-test-2", true);
250 validate("1.230E42", "double-test-2", true);
252 validate("-INF", "double-test-3", true);
253 validate("NaN", "double-test-3", true);
254 validate("a3a", "double-test-3", false);
255 validate("3a", "double-test-3", false);
257 validate("-INF", "double-test-4", true);
258 validate("INF", "double-test-4", false);
259 validate("NaN", "double-test-4", false);
260 validate("1.0E12", "double-test-4", true);
261 validate("-0", "double-test-4", true);
263 validate("220.343434", "decimal-test-1", true);
264 validate("220.3434a34", "decimal-test-1", false);
265 validate("220.343.34", "decimal-test-1", false);
266 validate("0.2", "decimal-test-1", true);
268 validate("220.343435", "decimal-test-2", false);
269 validate("220.3434342", "decimal-test-2", true);
270 validate("220.3434502", "decimal-test-2", false);
271 validate("100.32", "decimal-test-2", false);
272 validate("30.34", "decimal-test-2", false);
273 validate("100.34", "decimal-test-2", false);
274 validate("110.34", "decimal-test-2", true);
275 validate("100.345", "decimal-test-2", true);
277 validate("220.34345", "decimal-test-3", true);
278 validate("220.3434342", "decimal-test-3", true);
279 validate("220.3434502", "decimal-test-3", false);
280 validate("100.32", "decimal-test-3", false);
281 validate("30.34", "decimal-test-3", false);
282 validate("100.34", "decimal-test-3", true);
283 validate("110.34", "decimal-test-3", true);
284 validate("100.345", "decimal-test-3", true);
286 validate("100.32", "decimal-test-4", true);
287 validate("1002.32", "decimal-test-4", false);
288 validate("100.322", "decimal-test-4", false);
290 validate("220", "long-test-1", true);
291 validate("-220", "long-test-1", true);
292 validate("9223372036854775807", "long-test-1", true);
293 validate("-9223372036854775808", "long-test-1", true);
294 validate("-9223372036854775809", "long-test-1", false);
295 validate("9223372036854775808", "long-test-1", false);
297 validate("220", "int-test-1", true);
298 validate("-220", "int-test-1", true);
299 validate("2147483647", "int-test-1", true);
300 validate("-2147483648", "int-test-1", true);
301 validate("2147483648", "int-test-1", false);
302 validate("-2147483649", "int-test-1", false);
304 validate("220", "short-test-1", true);
305 validate("-220", "short-test-1", true);
306 validate("32767", "short-test-1", true);
307 validate("-32768", "short-test-1", true);
308 validate("32768", "short-test-1", false);
309 validate("-32769", "short-test-1", false);
311 validate("220", "unsignedLong-test-1", true);
312 validate("-220", "unsignedLong-test-1", false);
313 validate("18446744073709551615", "unsignedLong-test-1", true);
314 validate("18446744073709551616", "unsignedLong-test-1", false);
316 validate("220", "unsignedInt-test-1", true);
317 validate("-220", "unsignedInt-test-1", false);
318 validate("4294967295", "unsignedInt-test-1", true);
319 validate("4294967296", "unsignedInt-test-1", false);
321 validate("220", "unsignedShort-test-1", true);
322 validate("-220", "unsignedShort-test-1", false);
323 validate("65535", "unsignedShort-test-1", true);
324 validate("65536", "unsignedShort-test-1", false);
326 validate("220", "unsignedByte-test-1", true);
327 validate("-220", "unsignedByte-test-1", false);
328 validate("255", "unsignedByte-test-1", true);
329 validate("256", "unsignedByte-test-1", false);
331 validate("bla", "string-test-1", false);
332 validate("blaadadad", "string-test-1", false);
333 validate("bla22", "string-test-1", true);
335 validate("bla", "string-test-2", false);
336 validate("bladftrhhkeptjg,gjklg", "string-test-2", false);
337 validate("testingtesting", "string-test-2", true);
339 validate("test", "string-test-3", true);
340 validate("test2", "string-test-3", true);
341 validate("test3", "string-test-3", false);
343 validate("bla", "boolean-test-1", false);
344 validate("11", "boolean-test-1", false);
345 validate("1", "boolean-test-1", true);
346 validate("0", "boolean-test-1", true);
347 validate("true", "boolean-test-1", true);
348 validate("false", "boolean-test-1", true);
349 validate("TRue", "boolean-test-1", false );
351 validate("---30+23:20", "gday-test-1", true);
352 validate("---30+2a:20", "gday-test-1", false);
353 validate("---30+23:a0", "gday-test-1", false);
354 validate("---30", "gday-test-1", true);
355 validate("---30Z", "gday-test-1", true);
356 validate("---3", "gday-test-1", false);
357 validate("----3", "gday-test-1", false);
359 validate("---03", "gday-test-2", false);
360 validate("---14", "gday-test-2", true);
361 validate("---25", "gday-test-2", false);
362 validate("---05", "gday-test-2", false);
363 validate("---21", "gday-test-2", false);
364 validate("---30a23:20", "gday-test-1", false);
366 validate("---07", "gday-test-3", true);
368 validate("---03", "gday-test-3", false);
369 validate("---25", "gday-test-3", false);
370 validate("---05", "gday-test-3", true);
371 validate("---21", "gday-test-3", true);
373 validate("--01", "gmonth-test-1", true);
374 validate("--05Z", "gmonth-test-1", true);
375 validate("--05-03:43", "gmonth-test-1", true);
376 validate("--05a03:43", "gmonth-test-1", false);
377 validate("--12", "gmonth-test-1", true);
378 validate("--32", "gmonth-test-1", false);
379 validate("---2", "gmonth-test-1", false);
380 validate("--543", "gmonth-test-1", false);
382 validate("--01", "gmonth-test-2", false);
383 validate("--05", "gmonth-test-2", false);
384 validate("--06", "gmonth-test-2", true);
385 validate("--10", "gmonth-test-2", true);
386 validate("--11", "gmonth-test-2", false);
387 validate("--12", "gmonth-test-2", false);
389 validate("--01", "gmonth-test-3", false);
390 validate("--05", "gmonth-test-3", true);
391 validate("--06", "gmonth-test-3", true);
392 validate("--10", "gmonth-test-3", true);
393 validate("--11", "gmonth-test-3", true);
394 validate("--12", "gmonth-test-3", false);
396 validate("1989", "gyear-test-1", true);
397 validate("1234-13:43", "gyear-test-1", true);
398 validate("0771", "gyear-test-1", true);
399 validate("23331", "gyear-test-1", true);
400 validate("0000Z", "gyear-test-1", false);
401 validate("12a4-13:43", "gyear-test-1", false);
402 validate("1214-1a:43", "gyear-test-1", false);
403 validate("0", "gyear-test-1", false);
405 validate("1456", "gyear-test-2", false);
406 validate("1900", "gyear-test-2", true);
407 validate("6934", "gyear-test-2", true);
408 validate("10000", "gyear-test-2", true);
409 validate("10344", "gyear-test-2", false);
411 validate("1456Z", "gyear-test-3", false);
412 validate("1900", "gyear-test-3", false);
413 validate("6934Z", "gyear-test-3", true);
414 validate("10000", "gyear-test-3", false);
415 validate("10344", "gyear-test-3", false);
417 validate("-10344-11Z", "gyearmonth-test-1", true);
418 validate("-10344-13Z", "gyearmonth-test-1", false);
419 validate("-10344-12+12:34", "gyearmonth-test-1", true);
420 validate("-10344-12T", "gyearmonth-test-1", false);
421 validate("1999-12Z-", "gyearmonth-test-1", false);
423 validate("2000-11Z", "gyearmonth-test-2", true);
424 validate("10001-11Z", "gyearmonth-test-2", false);
425 validate("10000-11Z", "gyearmonth-test-2", false);
426 validate("10000-12-23:34", "gyearmonth-test-2", false);
427 validate("1995-11Z", "gyearmonth-test-2", true);
428 validate("1990-02Z", "gyearmonth-test-2", true);
429 validate("1990-01Z", "gyearmonth-test-2", false);
430 validate("1989-12Z", "gyearmonth-test-2", false);
432 validate("2000-11Z", "gyearmonth-test-3", true);
433 validate("10001-11Z", "gyearmonth-test-3", false);
434 validate("10001-12Z", "gyearmonth-test-3", false);
435 validate("10000-11Z", "gyearmonth-test-3", true);
436 validate("10000-12-23:34", "gyearmonth-test-3", false);
437 validate("1995-11Z", "gyearmonth-test-3", true);
438 validate("1990-03Z", "gyearmonth-test-3", true);
439 validate("1990-02Z", "gyearmonth-test-3", true);
440 validate("1989-12Z", "gyearmonth-test-3", false);
442 validate("--02-21", "gmonthday-test-1", true);
443 validate("--02-21a", "gmonthday-test-1", false);
444 validate("--02-21Z", "gmonthday-test-1", true);
445 validate("--02-21+11:33", "gmonthday-test-1", true);
446 validate("--02-21a11:33", "gmonthday-test-1", false);
447 validate("--02-21444342424242424", "gmonthday-test-1", false);
449 validate("--08-11Z", "gmonthday-test-2", false);
450 validate("--08-03Z", "gmonthday-test-2", false);
451 validate("--08-02Z", "gmonthday-test-2", true);
452 validate("--05-11Z", "gmonthday-test-2", true);
453 validate("--02-22Z", "gmonthday-test-2", true);
454 validate("--02-21", "gmonthday-test-2", false);
455 validate("--02-01-12:45", "gmonthday-test-2", false);
457 validate("--08-11Z", "gmonthday-test-3", false);
458 validate("--08-03Z", "gmonthday-test-3", true);
459 validate("--08-02Z", "gmonthday-test-3", true);
460 validate("--05-11Z", "gmonthday-test-3", true);
461 validate("--02-22Z", "gmonthday-test-3", true);
462 validate("--02-21", "gmonthday-test-3", true);
463 validate("--02-01-12:45", "gmonthday-test-3", false);
465 validate("2004-02-28T24:21:03Z", "datetime-test-1", true);
466 validate("2004-02-28T25:21:03Z", "datetime-test-1", false);
467 validate("2004-02-28T22:61:03Z", "datetime-test-1", false);
468 validate("-2004-02-28T12:21:03.434Z", "datetime-test-1", true);
469 validate("-2004-02-28T12:21:03-04:00", "datetime-test-1", true);
470 validate("-2004-02-30T12:21:03Z", "datetime-test-1", false);
471 validate("2004-02-28ZT24:21:03Z", "datetime-test-1", false);
472 validate("2004-02-28+06:00T24:21:03Z", "datetime-test-1", false);
474 validate("2004-02-11T12:21:03Z", "datetime-test-2", true);
475 validate("2004-02-18T00:00:00Z", "datetime-test-2", true);
476 validate("2004-02-18T12:21:03Z", "datetime-test-2", false);
477 validate("2004-02-30T12:21:03Z", "datetime-test-2", false);
478 validate("2002-06-29T12:21:03Z", "datetime-test-2", true);
479 validate("2001-02-18T12:21:03Z", "datetime-test-2", false);
480 validate("2001-01-18T12:21:03Z", "datetime-test-2", false);
481 validate("2002-02-30T12:21:03Z", "datetime-test-2", false);
483 validate("2004-02-18T12:21:03Z", "datetime-test-3", true);
484 validate("2004-02-18T00:00:00Z", "datetime-test-3", true);
485 validate("2004-02-18T12:22:03Z", "datetime-test-3", false);
486 validate("2004-02-21T12:22:03Z", "datetime-test-3", false);
487 validate("2001-02-18T12:21:03Z", "datetime-test-3", true);
488 validate("2002-02-18T12:21:03Z", "datetime-test-3", true);
489 validate("2001-02-18T12:20:03Z", "datetime-test-3", false);
490 validate("2001-01-18T22:20:03Z", "datetime-test-3", false);
491 validate("2004-02-18T12:21:03-02:00", "datetime-test-3", false);
492 validate("2004-02-18T12:21:03+02:00", "datetime-test-3", true);
493 validate("2004-02-18T12:21:03+00:23", "datetime-test-3", true);
494 validate("2004-02-18T12:21:03+14:00", "datetime-test-3", true);
495 validate("2003-02-18T12:21:03-00:45", "datetime-test-3", true);
497 validate("2001-01-18", "date-test-1", true);
498 validate("2001-0a-18", "date-test-1", false);
499 validate("2001-01-36", "date-test-1", false);
500 validate("2001-01-1", "date-test-1", false);
501 validate("2001-1-11", "date-test-1", false);
502 validate("201-01-11", "date-test-1", false);
503 // leap year test
504 validate("2000-02-29", "date-test-1", true);
505 validate("2001-02-29", "date-test-1", false);
506 // timezone test
507 validate("2001-01-18Z", "date-test-1", true);
508 validate("2001-01-18A", "date-test-1", false);
509 validate("2001-01-18Z2", "date-test-1", false);
510 validate("2007-01-01-06:00", "date-test-1", true);
511 validate("2007-01-01+06:00", "date-test-1", true);
512 validate("2007-01-01A06:00", "date-test-1", false);
513 validate("2007-01-01-06:00Z", "date-test-1", false);
514 validate("2007-01-01Z-06:00", "date-test-1", false);
516 validate("2004-02-17", "date-test-2", true);
517 validate("2004-02-18", "date-test-2", false);
518 validate("2003-02-18", "date-test-2", true);
519 validate("2001-02-18", "date-test-2", false);
520 validate("2001-02-17", "date-test-2", false);
522 validate("2004-02-17", "date-test-3", true);
523 validate("2004-02-18", "date-test-3", true);
524 validate("2004-02-19", "date-test-3", false);
525 validate("2003-02-18", "date-test-3", true);
526 validate("2001-02-18", "date-test-3", true);
527 validate("2001-02-17", "date-test-3", false);
529 validate("32:03:32", "time-test-1", false);
530 validate("12:03:32.2a3", "time-test-1", false);
531 validate("24:03:32", "time-test-1", true);
532 validate("24:03:32-04:40", "time-test-1", true);
533 validate("24:03:32.34", "time-test-1", true);
534 validate("24:03:32.3a4", "time-test-1", false);
536 validate("12:30:46", "time-test-2", true);
537 validate("18:22:00", "time-test-2", true);
538 validate("12:30:45", "time-test-2", false);
539 validate("22:30:45", "time-test-2", false);
540 validate("21:30:45", "time-test-2", true);
542 validate("12:30:43", "time-test-3", false);
543 validate("18:22:00", "time-test-3", true);
544 validate("12:30:45", "time-test-3", true);
545 validate("22:34:45", "time-test-3", false);
546 validate("22:30:45", "time-test-3", true);
547 validate("21:30:45", "time-test-3", true);
549 validate("http://www.foo.com", "anyuri-test-1", true);
550 validate("", "anyuri-test-1", true);
551 validate("f", "anyuri-test-1", true);
552 validate("bar..com", "anyuri-test-1", true);
553 // XXX This should probably not validate
554 validate("http://ftp://#.#?###.", "anyuri-test-1", true);
556 validate("http://www.foo.com", "anyuri-test-2", true);
557 validate("http://www.f.com", "anyuri-test-2", false);
558 validate("http://www.fa.com", "anyuri-test-2", true);
560 validate("http://www.f.com", "anyuri-test-3", false);
561 validate("http://www.fa.com", "anyuri-test-3", true);
563 validate("VGhpcyBpcyBhIHRlc3Q=", "base64-test-1", true);
564 validate(" VGhpcyBpcyBhIHRlQ= ", "base64-test-1", false);
566 validate("VGhpcyBpcyBhIHRlc3Q=", "base64-test-2", true);
567 validate("VGhpcyBpcyBhIHRlc3Qh", "base64-test-2", false);
569 validate("VGhpcyBpcyBhIHRlc3Q=", "base64-test-3", true);
570 validate("VGhpcyBpcyBhIHRlc3Qh", "base64-test-3", false);
571 validate("aGk=", "base64-test-3", false);
572 validate("aGkh", "base64-test-3", true);
573 validate("aGkgdGhlcmUh", "base64-test-3", true);
575 validate("0FB7", "hexbinary-test-1", true);
576 validate("0FB72", "hexbinary-test-1", false);
577 validate("023-", "hexbinary-test-1", false);
578 validate("0HB7", "hexbinary-test-1", false);
580 validate("58758", "better-us-zipcode", true);
581 validate("a758", "better-us-zipcode", false);
583 validate("P200Y30M", "duration-test-1", true);
584 validate("200Y30M", "duration-test-1", false);
585 validate("P200Y30Ma", "duration-test-1", false);
586 validate("P200Y30MD", "duration-test-1", false);
587 validate("P200Y30MT", "duration-test-1", false);
588 validate("P200Y30M45H", "duration-test-1", false);
589 validate("P200Y30M20S20Y", "duration-test-1", false);
590 validate("P200Y20D30M", "duration-test-1", false);
591 validate("P200Y30MT20S5H", "duration-test-1", false);
592 validate("P200Y30MT21H32.34S", "duration-test-1", true);
593 validate("P200Y30MT21H32.34.2S", "duration-test-1", false);
594 validate("P200Y30M23DT21H456M3234S", "duration-test-1", true);
595 validate("P200Y30MT21H32.3a4S", "duration-test-1", false);
596 validate("P200Y-20M", "duration-test-1", false);
597 validate("P214748364Y", "duration-test-1", true);
598 validate("P2147583647Y", "duration-test-1", false);
599 validate("P21475836433337Y", "duration-test-1", false);
601 validate("P150D", "duration-test-2", false);
602 validate("P149D", "duration-test-2", true);
603 validate("P28D", "duration-test-2", false);
604 validate("P32D", "duration-test-2", true);
605 validate("P27D", "duration-test-2", false);
607 validate("P150D", "duration-test-3", false);
608 validate("P149D", "duration-test-3", true);
609 validate("P28D", "duration-test-3", false);
610 validate("P32D", "duration-test-3", true);
611 validate("P27D", "duration-test-3", false);
613 validate("test:foo", "qname-test-1", true);
614 validate(":fooasdad", "qname-test-1", false);
615 validate("n:s", "qname-test-1", true);
616 validate("test:123456789", "qname-test-1", false);
618 validate("test:foo", "name-test-1", true);
619 validate(":fooasdad", "name-test-1", true);
620 validate("n:s", "name-test-1", true);
621 validate("-test", "name-test-1", false);
622 validate("t", "name-test-1", false);
624 validate("foo", "ncname-test-1", true);
625 validate("_fooasdad", "ncname-test-1", true);
626 validate("1foo", "ncname-test-1", false);
627 validate("test:foo", "ncname-test-1", false);
628 validate("t", "ncname-test-1", false);
630 validate("t123", "id-test-1", true);
631 validate("n:s", "id-test-1", false);
632 validate("-test", "id-test-1", false);
633 validate("t", "id-test-1", false);
635 validate("t123", "idref-test-1", true);
636 validate("n:s", "idref-test-1", false);
637 validate("-test", "idref-test-1", false);
638 validate("t", "idref-test-1", false);
640 validate("t123", "idrefs-test-1", true);
641 validate("ns _123", "idrefs-test-1", true);
642 validate("test \tfoo", "idrefs-test-1", true);
643 validate("test t123 u456 v789", "idrefs-test-1", false);
645 validate("t123", "nmtoken-test-1", true);
646 validate("n:s-1", "nmtoken-test-1", true);
647 validate("tes t", "nmtoken-test-1", false);
648 validate("t", "nmtoken-test-1", false);
650 validate("t123", "nmtokens-test-1", true);
651 validate("ns _123", "nmtokens-test-1", true);
652 validate("test \tfoo", "nmtokens-test-1", true);
653 validate("test t123 u456 v789", "nmtokens-test-1", false);
655 validate("true false 0 1", "list-test-1", true);
656 validate("true false e 1", "list-test-1", false);
658 validate("100 33 4", "list-test-2", true);
659 validate("100 333 4", "list-test-2", false);
661 validate("50", "union-test-1", true);
662 validate("N/A", "union-test-1", true);
663 validate("#REF!", "union-test-1", false);
665 validateSimpleTypeString("bla", "normalizedString", true);
666 validateSimpleTypeString("bla ", "normalizedString", false);
668 validateSimpleTypeString("bla", "token", true);
669 validateSimpleTypeString("bla ", "token", false);
670 validateSimpleTypeString("bla ", "token", false);
671 validateSimpleTypeString(" bla ", "token", false);
672 validateSimpleTypeString("bla afaf", "token", true);
673 validateSimpleTypeString("bla afaf", "token", false);
675 validateSimpleTypeString("en-US", "language", true);
676 validateSimpleTypeString("fr", "language", true);
677 validateSimpleTypeString("2", "language", false);
679 validate("Applicant", "IndividualRole", true);
680 validate("Applicanter", "IndividualRole", false);
681 validate("Applicant1", "IndividualRole", false);
683 validate("Applicant Trustee", "IndividualRoleList", true);
684 validate("Applicant Trustee Foo", "IndividualRoleList", false);
686 validate("Applicant Trustee", "IndividualRoleListType", true);
687 validate("Applicant Trustee Foo", "IndividualRoleListType", false);
688 validate("Applicant Trustee Trustee Applicant", "IndividualRoleListType", true);
689 validate("Applicant Trustee Trustee Applicant Trustee", "IndividualRoleListType", false);
691 validate("Applicant Trustee Trustee Applicant", "IndividualRoleListType2", true);
692 validate("Applicant Trustee Trustee", "IndividualRoleListType2", false);
693 validate("Applicant Trustee", "IndividualRoleListType2", false);
695 validate("Applicant Trustee Trustee Applicant", "IndividualRoleListType3", true);
696 validate("Applicant Trustee Trustee", "IndividualRoleListType3", false);
698 validate("Applicant Trustee Supplier", "IndividualRoleListType5", false);
699 validate("Applicant Trustee", "IndividualRoleListType5", true);
701 validateStringNS("220", "import-integer-test-1", "http://www.mozilla.org/schema/test_imported", false);
702 validateStringNS("6", "import-integer-test-1", "http://www.mozilla.org/schema/test_imported", true);
704 validateStringNS("-220", "import-integer-test-2", "http://www.mozilla.org/schema/test_imported2", false);
705 validateStringNS( "-2", "import-integer-test-2", "http://www.mozilla.org/schema/test_imported2", true);
707 validateStringNS("220", "include-integer-test-1", "http://www.mozilla.org/schema/test_imported", false);
708 validateStringNS("6", "include-integer-test-1", "http://www.mozilla.org/schema/test_imported", true);
710 validateStringNS("220", "include-integer-test-2", "http://www.mozilla.org/schema/test_imported", false);
711 validateStringNS("6", "include-integer-test-2", "http://www.mozilla.org/schema/test_imported", true);
713 validateStringNS("220", "include-integer-test-3", "http://www.mozilla.org/schema/test_imported", false);
714 validateStringNS("6", "include-integer-test-3", "http://www.mozilla.org/schema/test_imported", true);
717 end = new Date();
719 // final result
720 displayResults();
721 document.getElementById("finalResults").innerHTML = counter + " Tests Completed, with " + failCounter + " Failures" +
722 ". Seconds: " + ((end-start) / 1000);
724 </script>
725 </head>
726 <body>
728 <button onclick="test()">Do</button>
730 <div id="finalResults"></div>
732 <table border=1 cellpadding=0 cellspacing=0 width="100%" id="resultTable" style="font-size:0.8em;">
733 <thead>
734 <td>#</td>
735 <td>Type</td>
736 <td>Value</td>
737 <td>Is Valid?</td>
738 <td>Should be Valid?</td>
739 <td>Result</td>
740 </thead>
741 <tbody id="results" />
742 </table>
743 </body>
744 </html>