RetroZilla/extensions/schema-validation/tests/schema.html
2015-10-20 23:03:22 -04:00

746 lines
32 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title></title>
<style>
.passed {background-color:lightgreen;}
.failed {background-color:red;}
td {
padding:3px;
}
</style>
<script>
var myValidator = null;
var counter;
var failCounter = 0;
var results;
var start;
var end;
function getValidator() {
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
if (!myValidator)
myValidator = Components.classes["@mozilla.org/xmlextras/schemas/schemavalidator;1"]
.getService(Components.interfaces.nsISchemaValidator);
return myValidator;
}
function validateDOMNode(aNodeValue, aType, aNSPrefix, aIsValid) {
var rv = false;
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");
rv = getValidator().validate(x.documentElement);
counter++;
results[results.length] = {type: aType, nodevalue: aNodeValue, rv: rv, isvalid: aIsValid};
}
function validateString(aNodeValue, aType, aIsValid) {
var rv = getValidator().validateString(aNodeValue, aType, "http://www.mozilla.org/schema/test");
counter++;
results[results.length] = {type: aType, nodevalue: aNodeValue, rv: rv, isvalid: aIsValid};
}
function validateStringNS(aNodeValue, aType, aNS, aIsValid) {
var rv = getValidator().validateString(aNodeValue, aType, aNS);
counter++;
results[results.length] = {type: aType, nodevalue: aNodeValue, rv: rv, isvalid: aIsValid};
}
function validateSimpleTypeString(aNodeValue, aType, aIsValid) {
var rv = getValidator().validateString(aNodeValue, aType, "http://www.w3.org/1999/XMLSchema");
counter++;
results[results.length] = {type: aType, nodevalue: aNodeValue, rv: rv, isvalid: aIsValid};
}
function validate(aNodeValue, aType, aIsValid){
validateString(aNodeValue, aType, aIsValid);
}
function validateComplexType(aNodeValue, aType, aIsValid){
var rv = false;
var x = dp.parseFromString(aNodeValue, "application/xml")
rv = getValidator().validate(x.documentElement);
counter++;
results[results.length] = {type: aType, nodevalue: aNodeValue, rv: rv, isvalid: aIsValid};
}
function displayResults(){
var tbody = document.createElement("tbody");
var tr, td, textNode;
for (var run = 0; run < results.length; run++){
tr = document.createElement("tr");
td = document.createElement("td");
textNode = document.createTextNode(run + 1);
td.appendChild(textNode);
tr.appendChild(td);
td = document.createElement("td");
textNode = document.createTextNode(results[run].type);
td.appendChild(textNode);
tr.appendChild(td);
td = document.createElement("td");
textNode = document.createTextNode(results[run].nodevalue);
td.appendChild(textNode);
tr.appendChild(td);
td = document.createElement("td");
textNode = document.createTextNode(results[run].rv);
td.appendChild(textNode);
tr.appendChild(td);
td = document.createElement("td");
textNode = document.createTextNode(results[run].isvalid);
td.appendChild(textNode);
tr.appendChild(td);
td = document.createElement("td");
textNode = document.createTextNode((results[run].rv == results[run].isvalid) ? "Passed" : "Failed");
td.appendChild(textNode);
td.className = (results[run].rv == results[run].isvalid) ? "passed" : "failed";
tr.appendChild(td);
tbody.appendChild(tr);
if (results[run].rv!=results[run].isvalid)
failCounter++;
}
document.getElementById("resultTable").replaceChild(tbody, document.getElementById("results"));
}
var dp = new DOMParser();
var schema;
function test() {
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
try{
myValidator = Components.classes["@mozilla.org/schemavalidator;1"].createInstance(Components.interfaces.nsISchemaValidator);
}catch(e){ alert(e) }
var schemaLoader = Components.classes["@mozilla.org/xmlextras/schemas/schemaloader;1"]
.getService(Components.interfaces.nsISchemaLoader);
try {
// SchemaLoader.Load() wants a URI
schema = schemaLoader.load(document.URL + "/../schema.xsd");
myValidator.loadSchema(schema);
} catch(e){alert(e)}
//schema collection
var schemaCollection = schema.collection;
document.getElementById("results").innerHTML = "";
counter = 0;
failCounter = 0;
results = new Array();
start = new Date();
/*
try {
var x = myValidator.validateBuiltinTypeDuration("P200Y30M23DT21H456M3234.345S");
alert(x.getSeconds() + " " + x.getFractionSeconds());
} catch (e) {
alert("invalid")
}
*/
if (1) {
validate("220", "integer-test-1", false);
validate("2", "integer-test-1", false);
validate("-220", "integer-test-1", false);
validate("5", "integer-test-1", false);
validate("101", "integer-test-1", false);
validate("1013", "integer-test-1", false);
validate("56", "integer-test-1", true);
validate("220", "integer-test-2", false);
validate("3", "integer-test-2", false);
validate("-56", "integer-test-2", false);
validate("-40", "integer-test-2", true);
validate("-1", "integer-test-2", true);
validate("-34", "integer-test-2", true);
validate("002", "integer-test-2", true);
validate("-1", "nonPositiveInteger-test-1", true);
validate("0", "nonPositiveInteger-test-1", true);
validate("1", "nonPositiveInteger-test-1", false);
validate("-3452", "nonPositiveInteger-test-1", false);
validate("-1", "nonNegativeInteger-test-1", false);
validate("0", "nonNegativeInteger-test-1", true);
validate("1", "nonNegativeInteger-test-1", true);
validate("501", "nonNegativeInteger-test-1", false);
validate("499", "nonNegativeInteger-test-1", true);
validate("-1", "negativeInteger-test-1", true);
validate("-22", "negativeInteger-test-1", true);
validate("0", "negativeInteger-test-1", false);
validate("1", "negativeInteger-test-1", false);
validate("-3452", "negativeInteger-test-1", false);
validate("1", "positiveInteger-test-1", true);
validate("22", "positiveInteger-test-1", true);
validate("0", "positiveInteger-test-1", false);
validate("-12", "positiveInteger-test-1", false);
validate("3452", "positiveInteger-test-1", false);
validate("127", "byte-test-1", true);
validate("-128", "byte-test-1", true);
validate("-12", "byte-test-1", true);
validate("5", "byte-test-1", true);
validate("129", "byte-test-1", false);
validate("-135", "byte-test-1", false);
validate("127", "byte-test-2", false);
validate("40", "byte-test-2", false);
validate("-40", "byte-test-2", false);
validate("38", "byte-test-2", true);
validate("-1", "byte-test-2", true);
validate("127", "byte-test-3", false);
validate("40", "byte-test-3", true);
validate("-40", "byte-test-3", true);
validate("38", "byte-test-3", true);
validate("-1", "byte-test-3", true);
validate("-1", "float-test-1", false);
validate("1.230", "float-test-1", true);
validate("2.23022", "float-test-1", true);
validate("3.34", "float-test-1", false);
validate("3.340", "float-test-1", false);
validate("3.5", "float-test-1", false);
validate("0.1", "float-test-1", false);
validate("0.98", "float-test-1", false);
validate("1.02", "float-test-1", true);
validate("2011.0E-3", "float-test-1", true);
validate("8.342", "float-test-2", false);
validate("-3.46", "float-test-2", false);
validate("3.34", "float-test-2", true);
validate("2.34", "float-test-2", true);
validate("-1.98", "float-test-2", true);
validate("-1.99", "float-test-2", false);
validate("-5.32", "float-test-2", false);
validate("-INF", "float-test-3", true);
validate("INF", "float-test-3", false);
validate("NaN", "float-test-3", false);
validate("4.21e4", "float-test-3", true);
validate("-1", "double-test-1", false);
validate("1.230", "double-test-1", true);
validate("3.34", "double-test-1", false);
validate("0.98", "double-test-1", false);
validate("2011.0E-3", "double-test-1", true);
validate("1.98e-14", "double-test-2", false);
validate("0", "double-test-2", false);
validate("1.230", "double-test-2", true);
validate("1.230E42", "double-test-2", true);
validate("-INF", "double-test-3", true);
validate("NaN", "double-test-3", true);
validate("a3a", "double-test-3", false);
validate("3a", "double-test-3", false);
validate("-INF", "double-test-4", true);
validate("INF", "double-test-4", false);
validate("NaN", "double-test-4", false);
validate("1.0E12", "double-test-4", true);
validate("-0", "double-test-4", true);
validate("220.343434", "decimal-test-1", true);
validate("220.3434a34", "decimal-test-1", false);
validate("220.343.34", "decimal-test-1", false);
validate("0.2", "decimal-test-1", true);
validate("220.343435", "decimal-test-2", false);
validate("220.3434342", "decimal-test-2", true);
validate("220.3434502", "decimal-test-2", false);
validate("100.32", "decimal-test-2", false);
validate("30.34", "decimal-test-2", false);
validate("100.34", "decimal-test-2", false);
validate("110.34", "decimal-test-2", true);
validate("100.345", "decimal-test-2", true);
validate("220.34345", "decimal-test-3", true);
validate("220.3434342", "decimal-test-3", true);
validate("220.3434502", "decimal-test-3", false);
validate("100.32", "decimal-test-3", false);
validate("30.34", "decimal-test-3", false);
validate("100.34", "decimal-test-3", true);
validate("110.34", "decimal-test-3", true);
validate("100.345", "decimal-test-3", true);
validate("100.32", "decimal-test-4", true);
validate("1002.32", "decimal-test-4", false);
validate("100.322", "decimal-test-4", false);
validate("220", "long-test-1", true);
validate("-220", "long-test-1", true);
validate("9223372036854775807", "long-test-1", true);
validate("-9223372036854775808", "long-test-1", true);
validate("-9223372036854775809", "long-test-1", false);
validate("9223372036854775808", "long-test-1", false);
validate("220", "int-test-1", true);
validate("-220", "int-test-1", true);
validate("2147483647", "int-test-1", true);
validate("-2147483648", "int-test-1", true);
validate("2147483648", "int-test-1", false);
validate("-2147483649", "int-test-1", false);
validate("220", "short-test-1", true);
validate("-220", "short-test-1", true);
validate("32767", "short-test-1", true);
validate("-32768", "short-test-1", true);
validate("32768", "short-test-1", false);
validate("-32769", "short-test-1", false);
validate("220", "unsignedLong-test-1", true);
validate("-220", "unsignedLong-test-1", false);
validate("18446744073709551615", "unsignedLong-test-1", true);
validate("18446744073709551616", "unsignedLong-test-1", false);
validate("220", "unsignedInt-test-1", true);
validate("-220", "unsignedInt-test-1", false);
validate("4294967295", "unsignedInt-test-1", true);
validate("4294967296", "unsignedInt-test-1", false);
validate("220", "unsignedShort-test-1", true);
validate("-220", "unsignedShort-test-1", false);
validate("65535", "unsignedShort-test-1", true);
validate("65536", "unsignedShort-test-1", false);
validate("220", "unsignedByte-test-1", true);
validate("-220", "unsignedByte-test-1", false);
validate("255", "unsignedByte-test-1", true);
validate("256", "unsignedByte-test-1", false);
validate("bla", "string-test-1", false);
validate("blaadadad", "string-test-1", false);
validate("bla22", "string-test-1", true);
validate("bla", "string-test-2", false);
validate("bladftrhhkeptjg,gjklg", "string-test-2", false);
validate("testingtesting", "string-test-2", true);
validate("test", "string-test-3", true);
validate("test2", "string-test-3", true);
validate("test3", "string-test-3", false);
validate("bla", "boolean-test-1", false);
validate("11", "boolean-test-1", false);
validate("1", "boolean-test-1", true);
validate("0", "boolean-test-1", true);
validate("true", "boolean-test-1", true);
validate("false", "boolean-test-1", true);
validate("TRue", "boolean-test-1", false );
validate("---30+23:20", "gday-test-1", true);
validate("---30+2a:20", "gday-test-1", false);
validate("---30+23:a0", "gday-test-1", false);
validate("---30", "gday-test-1", true);
validate("---30Z", "gday-test-1", true);
validate("---3", "gday-test-1", false);
validate("----3", "gday-test-1", false);
validate("---03", "gday-test-2", false);
validate("---14", "gday-test-2", true);
validate("---25", "gday-test-2", false);
validate("---05", "gday-test-2", false);
validate("---21", "gday-test-2", false);
validate("---30a23:20", "gday-test-1", false);
validate("---07", "gday-test-3", true);
validate("---03", "gday-test-3", false);
validate("---25", "gday-test-3", false);
validate("---05", "gday-test-3", true);
validate("---21", "gday-test-3", true);
validate("--01", "gmonth-test-1", true);
validate("--05Z", "gmonth-test-1", true);
validate("--05-03:43", "gmonth-test-1", true);
validate("--05a03:43", "gmonth-test-1", false);
validate("--12", "gmonth-test-1", true);
validate("--32", "gmonth-test-1", false);
validate("---2", "gmonth-test-1", false);
validate("--543", "gmonth-test-1", false);
validate("--01", "gmonth-test-2", false);
validate("--05", "gmonth-test-2", false);
validate("--06", "gmonth-test-2", true);
validate("--10", "gmonth-test-2", true);
validate("--11", "gmonth-test-2", false);
validate("--12", "gmonth-test-2", false);
validate("--01", "gmonth-test-3", false);
validate("--05", "gmonth-test-3", true);
validate("--06", "gmonth-test-3", true);
validate("--10", "gmonth-test-3", true);
validate("--11", "gmonth-test-3", true);
validate("--12", "gmonth-test-3", false);
validate("1989", "gyear-test-1", true);
validate("1234-13:43", "gyear-test-1", true);
validate("0771", "gyear-test-1", true);
validate("23331", "gyear-test-1", true);
validate("0000Z", "gyear-test-1", false);
validate("12a4-13:43", "gyear-test-1", false);
validate("1214-1a:43", "gyear-test-1", false);
validate("0", "gyear-test-1", false);
validate("1456", "gyear-test-2", false);
validate("1900", "gyear-test-2", true);
validate("6934", "gyear-test-2", true);
validate("10000", "gyear-test-2", true);
validate("10344", "gyear-test-2", false);
validate("1456Z", "gyear-test-3", false);
validate("1900", "gyear-test-3", false);
validate("6934Z", "gyear-test-3", true);
validate("10000", "gyear-test-3", false);
validate("10344", "gyear-test-3", false);
validate("-10344-11Z", "gyearmonth-test-1", true);
validate("-10344-13Z", "gyearmonth-test-1", false);
validate("-10344-12+12:34", "gyearmonth-test-1", true);
validate("-10344-12T", "gyearmonth-test-1", false);
validate("1999-12Z-", "gyearmonth-test-1", false);
validate("2000-11Z", "gyearmonth-test-2", true);
validate("10001-11Z", "gyearmonth-test-2", false);
validate("10000-11Z", "gyearmonth-test-2", false);
validate("10000-12-23:34", "gyearmonth-test-2", false);
validate("1995-11Z", "gyearmonth-test-2", true);
validate("1990-02Z", "gyearmonth-test-2", true);
validate("1990-01Z", "gyearmonth-test-2", false);
validate("1989-12Z", "gyearmonth-test-2", false);
validate("2000-11Z", "gyearmonth-test-3", true);
validate("10001-11Z", "gyearmonth-test-3", false);
validate("10001-12Z", "gyearmonth-test-3", false);
validate("10000-11Z", "gyearmonth-test-3", true);
validate("10000-12-23:34", "gyearmonth-test-3", false);
validate("1995-11Z", "gyearmonth-test-3", true);
validate("1990-03Z", "gyearmonth-test-3", true);
validate("1990-02Z", "gyearmonth-test-3", true);
validate("1989-12Z", "gyearmonth-test-3", false);
validate("--02-21", "gmonthday-test-1", true);
validate("--02-21a", "gmonthday-test-1", false);
validate("--02-21Z", "gmonthday-test-1", true);
validate("--02-21+11:33", "gmonthday-test-1", true);
validate("--02-21a11:33", "gmonthday-test-1", false);
validate("--02-21444342424242424", "gmonthday-test-1", false);
validate("--08-11Z", "gmonthday-test-2", false);
validate("--08-03Z", "gmonthday-test-2", false);
validate("--08-02Z", "gmonthday-test-2", true);
validate("--05-11Z", "gmonthday-test-2", true);
validate("--02-22Z", "gmonthday-test-2", true);
validate("--02-21", "gmonthday-test-2", false);
validate("--02-01-12:45", "gmonthday-test-2", false);
validate("--08-11Z", "gmonthday-test-3", false);
validate("--08-03Z", "gmonthday-test-3", true);
validate("--08-02Z", "gmonthday-test-3", true);
validate("--05-11Z", "gmonthday-test-3", true);
validate("--02-22Z", "gmonthday-test-3", true);
validate("--02-21", "gmonthday-test-3", true);
validate("--02-01-12:45", "gmonthday-test-3", false);
validate("2004-02-28T24:21:03Z", "datetime-test-1", true);
validate("2004-02-28T25:21:03Z", "datetime-test-1", false);
validate("2004-02-28T22:61:03Z", "datetime-test-1", false);
validate("-2004-02-28T12:21:03.434Z", "datetime-test-1", true);
validate("-2004-02-28T12:21:03-04:00", "datetime-test-1", true);
validate("-2004-02-30T12:21:03Z", "datetime-test-1", false);
validate("2004-02-28ZT24:21:03Z", "datetime-test-1", false);
validate("2004-02-28+06:00T24:21:03Z", "datetime-test-1", false);
validate("2004-02-11T12:21:03Z", "datetime-test-2", true);
validate("2004-02-18T00:00:00Z", "datetime-test-2", true);
validate("2004-02-18T12:21:03Z", "datetime-test-2", false);
validate("2004-02-30T12:21:03Z", "datetime-test-2", false);
validate("2002-06-29T12:21:03Z", "datetime-test-2", true);
validate("2001-02-18T12:21:03Z", "datetime-test-2", false);
validate("2001-01-18T12:21:03Z", "datetime-test-2", false);
validate("2002-02-30T12:21:03Z", "datetime-test-2", false);
validate("2004-02-18T12:21:03Z", "datetime-test-3", true);
validate("2004-02-18T00:00:00Z", "datetime-test-3", true);
validate("2004-02-18T12:22:03Z", "datetime-test-3", false);
validate("2004-02-21T12:22:03Z", "datetime-test-3", false);
validate("2001-02-18T12:21:03Z", "datetime-test-3", true);
validate("2002-02-18T12:21:03Z", "datetime-test-3", true);
validate("2001-02-18T12:20:03Z", "datetime-test-3", false);
validate("2001-01-18T22:20:03Z", "datetime-test-3", false);
validate("2004-02-18T12:21:03-02:00", "datetime-test-3", false);
validate("2004-02-18T12:21:03+02:00", "datetime-test-3", true);
validate("2004-02-18T12:21:03+00:23", "datetime-test-3", true);
validate("2004-02-18T12:21:03+14:00", "datetime-test-3", true);
validate("2003-02-18T12:21:03-00:45", "datetime-test-3", true);
validate("test:foo", "name-test-1", true);
validate(":fooasdad", "name-test-1", true);
validate("n:s", "name-test-1", true);
validate("-test", "name-test-1", false);
validate("t", "name-test-1", false);
validate("foo", "ncname-test-1", true);
validate("_fooasdad", "ncname-test-1", true);
validate("1foo", "ncname-test-1", false);
validate("test:foo", "ncname-test-1", false);
validate("t", "ncname-test-1", false);
validate("t123", "id-test-1", true);
validate("n:s", "id-test-1", false);
validate("-test", "id-test-1", false);
validate("t", "id-test-1", false);
validate("t123", "idref-test-1", true);
validate("n:s", "idref-test-1", false);
validate("-test", "idref-test-1", false);
validate("t", "idref-test-1", false);
validate("t123", "idrefs-test-1", true);
validate("ns _123", "idrefs-test-1", true);
validate("test \tfoo", "idrefs-test-1", true);
validate("test t123 u456 v789", "idrefs-test-1", false);
validate("t123", "nmtoken-test-1", true);
validate("n:s-1", "nmtoken-test-1", true);
validate("tes t", "nmtoken-test-1", false);
validate("t", "nmtoken-test-1", false);
validate("t123", "nmtokens-test-1", true);
validate("ns _123", "nmtokens-test-1", true);
validate("test \tfoo", "nmtokens-test-1", true);
validate("test t123 u456 v789", "nmtokens-test-1", false);
validate("2001-01-18", "date-test-1", true);
validate("2001-0a-18", "date-test-1", false);
validate("2001-01-36", "date-test-1", false);
validate("2001-01-1", "date-test-1", false);
validate("2001-1-11", "date-test-1", false);
validate("201-01-11", "date-test-1", false);
// leap year test
validate("2000-02-29", "date-test-1", true);
validate("2001-02-29", "date-test-1", false);
// timezone test
validate("2001-01-18Z", "date-test-1", true);
validate("2001-01-18A", "date-test-1", false);
validate("2001-01-18Z2", "date-test-1", false);
validate("2007-01-01-06:00", "date-test-1", true);
validate("2007-01-01+06:00", "date-test-1", true);
validate("2007-01-01A06:00", "date-test-1", false);
validate("2007-01-01-06:00Z", "date-test-1", false);
validate("2007-01-01Z-06:00", "date-test-1", false);
validate("2004-02-17", "date-test-2", true);
validate("2004-02-18", "date-test-2", false);
validate("2003-02-18", "date-test-2", true);
validate("2001-02-18", "date-test-2", false);
validate("2001-02-17", "date-test-2", false);
validate("2004-02-17", "date-test-3", true);
validate("2004-02-18", "date-test-3", true);
validate("2004-02-19", "date-test-3", false);
validate("2003-02-18", "date-test-3", true);
validate("2001-02-18", "date-test-3", true);
validate("2001-02-17", "date-test-3", false);
validate("32:03:32", "time-test-1", false);
validate("12:03:32.2a3", "time-test-1", false);
validate("24:03:32", "time-test-1", true);
validate("24:03:32-04:40", "time-test-1", true);
validate("24:03:32.34", "time-test-1", true);
validate("24:03:32.3a4", "time-test-1", false);
validate("12:30:46", "time-test-2", true);
validate("18:22:00", "time-test-2", true);
validate("12:30:45", "time-test-2", false);
validate("22:30:45", "time-test-2", false);
validate("21:30:45", "time-test-2", true);
validate("12:30:43", "time-test-3", false);
validate("18:22:00", "time-test-3", true);
validate("12:30:45", "time-test-3", true);
validate("22:34:45", "time-test-3", false);
validate("22:30:45", "time-test-3", true);
validate("21:30:45", "time-test-3", true);
validate("http://www.foo.com", "anyuri-test-1", true);
validate("", "anyuri-test-1", true);
validate("f", "anyuri-test-1", true);
validate("bar..com", "anyuri-test-1", true);
// XXX This should probably not validate
validate("http://ftp://#.#?###.", "anyuri-test-1", true);
validate("http://www.foo.com", "anyuri-test-2", true);
validate("http://www.f.com", "anyuri-test-2", false);
validate("http://www.fa.com", "anyuri-test-2", true);
validate("http://www.f.com", "anyuri-test-3", false);
validate("http://www.fa.com", "anyuri-test-3", true);
validate("VGhpcyBpcyBhIHRlc3Q=", "base64-test-1", true);
validate(" VGhpcyBpcyBhIHRlQ= ", "base64-test-1", false);
validate("VGhpcyBpcyBhIHRlc3Q=", "base64-test-2", true);
validate("VGhpcyBpcyBhIHRlc3Qh", "base64-test-2", false);
validate("VGhpcyBpcyBhIHRlc3Q=", "base64-test-3", true);
validate("VGhpcyBpcyBhIHRlc3Qh", "base64-test-3", false);
validate("aGk=", "base64-test-3", false);
validate("aGkh", "base64-test-3", true);
validate("aGkgdGhlcmUh", "base64-test-3", true);
validate("0FB7", "hexbinary-test-1", true);
validate("0FB72", "hexbinary-test-1", false);
validate("023-", "hexbinary-test-1", false);
validate("0HB7", "hexbinary-test-1", false);
validate("58758", "better-us-zipcode", true);
validate("a758", "better-us-zipcode", false);
validate("P200Y30M", "duration-test-1", true);
validate("200Y30M", "duration-test-1", false);
validate("P200Y30Ma", "duration-test-1", false);
validate("P200Y30MD", "duration-test-1", false);
validate("P200Y30MT", "duration-test-1", false);
validate("P200Y30M45H", "duration-test-1", false);
validate("P200Y30M20S20Y", "duration-test-1", false);
validate("P200Y20D30M", "duration-test-1", false);
validate("P200Y30MT20S5H", "duration-test-1", false);
validate("P200Y30MT21H32.34S", "duration-test-1", true);
validate("P200Y30MT21H32.34.2S", "duration-test-1", false);
validate("P200Y30M23DT21H456M3234S", "duration-test-1", true);
validate("P200Y30MT21H32.3a4S", "duration-test-1", false);
validate("P200Y-20M", "duration-test-1", false);
validate("P214748364Y", "duration-test-1", true);
validate("P2147583647Y", "duration-test-1", false);
validate("P21475836433337Y", "duration-test-1", false);
validate("P150D", "duration-test-2", false);
validate("P149D", "duration-test-2", true);
validate("P28D", "duration-test-2", false);
validate("P32D", "duration-test-2", true);
validate("P27D", "duration-test-2", false);
validate("P150D", "duration-test-3", false);
validate("P149D", "duration-test-3", true);
validate("P28D", "duration-test-3", false);
validate("P32D", "duration-test-3", true);
validate("P27D", "duration-test-3", false);
validate("test:foo", "qname-test-1", true);
validate(":fooasdad", "qname-test-1", false);
validate("n:s", "qname-test-1", true);
validate("test:123456789", "qname-test-1", false);
validate("true false 0 1", "list-test-1", true);
validate("true false e 1", "list-test-1", false);
validate("100 33 4", "list-test-2", true);
validate("100 333 4", "list-test-2", false);
validate("50", "union-test-1", true);
validate("N/A", "union-test-1", true);
validate("#REF!", "union-test-1", false);
validateSimpleTypeString("bla", "normalizedString", true);
validateSimpleTypeString("bla ", "normalizedString", false);
validateSimpleTypeString("bla", "token", true);
validateSimpleTypeString("bla ", "token", false);
validateSimpleTypeString("bla ", "token", false);
validateSimpleTypeString(" bla ", "token", false);
validateSimpleTypeString("bla afaf", "token", true);
validateSimpleTypeString("bla afaf", "token", false);
validateSimpleTypeString("en-US", "language", true);
validateSimpleTypeString("fr", "language", true);
validateSimpleTypeString("2", "language", false);
validate("Applicant", "IndividualRole", true);
validate("Applicanter", "IndividualRole", false);
validate("Applicant1", "IndividualRole", false);
validate("Applicant Trustee", "IndividualRoleList", true);
validate("Applicant Trustee Foo", "IndividualRoleList", false);
validate("Applicant Trustee", "IndividualRoleListType", true);
validate("Applicant Trustee Foo", "IndividualRoleListType", false);
validate("Applicant Trustee Trustee Applicant", "IndividualRoleListType", true);
validate("Applicant Trustee Trustee Applicant Trustee", "IndividualRoleListType", false);
validate("Applicant Trustee Trustee Applicant", "IndividualRoleListType2", true);
validate("Applicant Trustee Trustee", "IndividualRoleListType2", false);
validate("Applicant Trustee", "IndividualRoleListType2", false);
validate("Applicant Trustee Trustee Applicant", "IndividualRoleListType3", true);
validate("Applicant Trustee Trustee", "IndividualRoleListType3", false);
validate("Applicant Trustee Supplier", "IndividualRoleListType5", false);
validate("Applicant Trustee", "IndividualRoleListType5", true);
validateStringNS("220", "import-integer-test-1", "http://www.mozilla.org/schema/test_imported", false);
validateStringNS("6", "import-integer-test-1", "http://www.mozilla.org/schema/test_imported", true);
validateStringNS("-220", "import-integer-test-2", "http://www.mozilla.org/schema/test_imported2", false);
validateStringNS( "-2", "import-integer-test-2", "http://www.mozilla.org/schema/test_imported2", true);
validateStringNS("220", "include-integer-test-1", "http://www.mozilla.org/schema/test_imported", false);
validateStringNS("6", "include-integer-test-1", "http://www.mozilla.org/schema/test_imported", true);
validateStringNS("220", "include-integer-test-2", "http://www.mozilla.org/schema/test_imported", false);
validateStringNS("6", "include-integer-test-2", "http://www.mozilla.org/schema/test_imported", true);
validateStringNS("220", "include-integer-test-3", "http://www.mozilla.org/schema/test_imported", false);
validateStringNS("6", "include-integer-test-3", "http://www.mozilla.org/schema/test_imported", true);
}
end = new Date();
// final result
displayResults();
document.getElementById("finalResults").innerHTML = counter + " Tests Completed, with " + failCounter + " Failures" +
". Seconds: " + ((end-start) / 1000);
}
</script>
</head>
<body>
<button onclick="test()">Do</button>
<div id="finalResults"></div>
<table border=1 cellpadding=0 cellspacing=0 width="100%" id="resultTable" style="font-size:0.8em;">
<thead>
<td>#</td>
<td>Type</td>
<td>Value</td>
<td>Is Valid?</td>
<td>Should be Valid?</td>
<td>Result</td>
</thead>
<tbody id="results" />
</table>
</body>
</html>