Schema Validation Bug 327511 - implement the remaining schema types XForms requires. r=aaronr

This commit is contained in:
doronr%us.ibm.com 2006-02-21 22:01:15 +00:00
parent 834e80956b
commit 3b267d7b0d
5 changed files with 670 additions and 65 deletions

View File

@ -454,6 +454,51 @@ nsSchemaValidator::ValidateDerivedBuiltinType(const nsAString & aNodeValue,
break;
}
case nsISchemaBuiltinType::BUILTIN_TYPE_NORMALIZED_STRING: {
if (nsSchemaValidatorUtils::IsValidSchemaNormalizedString(aNodeValue)) {
rv = ValidateBuiltinTypeString(aNodeValue,
aDerived->length.value,
aDerived->length.isDefined,
aDerived->minLength.value,
aDerived->minLength.isDefined,
aDerived->maxLength.value,
aDerived->maxLength.isDefined,
&aDerived->enumerationList,
&isValid);
}
break;
}
case nsISchemaBuiltinType::BUILTIN_TYPE_TOKEN: {
if (nsSchemaValidatorUtils::IsValidSchemaToken(aNodeValue)) {
rv = ValidateBuiltinTypeString(aNodeValue,
aDerived->length.value,
aDerived->length.isDefined,
aDerived->minLength.value,
aDerived->minLength.isDefined,
aDerived->maxLength.value,
aDerived->maxLength.isDefined,
&aDerived->enumerationList,
&isValid);
}
break;
}
case nsISchemaBuiltinType::BUILTIN_TYPE_LANGUAGE: {
if (nsSchemaValidatorUtils::IsValidSchemaLanguage(aNodeValue)) {
rv = ValidateBuiltinTypeString(aNodeValue,
aDerived->length.value,
aDerived->length.isDefined,
aDerived->minLength.value,
aDerived->minLength.isDefined,
aDerived->maxLength.value,
aDerived->maxLength.isDefined,
&aDerived->enumerationList,
&isValid);
}
break;
}
case nsISchemaBuiltinType::BUILTIN_TYPE_BOOLEAN: {
rv = ValidateBuiltinTypeBoolean(aNodeValue, &isValid);
break;
@ -565,10 +610,8 @@ nsSchemaValidator::ValidateDerivedBuiltinType(const nsAString & aNodeValue,
case nsISchemaBuiltinType::BUILTIN_TYPE_NONPOSITIVEINTEGER: {
if (aDerived->maxExclusive.value.IsEmpty()) {
aDerived->maxExclusive.value.AssignLiteral("1");
}
if (aDerived->minInclusive.value.IsEmpty()) {
aDerived->minInclusive.value.AssignLiteral("0");
} else if (aDerived->maxInclusive.value.IsEmpty()) {
aDerived->maxInclusive.value.AssignLiteral("0");
}
rv = ValidateBuiltinTypeInteger(aNodeValue,
@ -586,10 +629,174 @@ nsSchemaValidator::ValidateDerivedBuiltinType(const nsAString & aNodeValue,
case nsISchemaBuiltinType::BUILTIN_TYPE_NEGATIVEINTEGER: {
if (aDerived->maxExclusive.value.IsEmpty()) {
aDerived->maxExclusive.value.AssignLiteral("0");
} else if (aDerived->maxInclusive.value.IsEmpty()) {
aDerived->maxInclusive.value.AssignLiteral("-1");
}
rv = ValidateBuiltinTypeInteger(aNodeValue,
aDerived->totalDigits.value,
aDerived->maxExclusive.value,
aDerived->minExclusive.value,
aDerived->maxInclusive.value,
aDerived->minInclusive.value,
&aDerived->enumerationList,
&isValid);
break;
}
/* http://w3.org/TR/xmlschema-2/#positiveInteger */
case nsISchemaBuiltinType::BUILTIN_TYPE_POSITIVEINTEGER: {
if (aDerived->minInclusive.value.IsEmpty()) {
aDerived->minInclusive.value.AssignLiteral("1");
} else if (aDerived->minExclusive.value.IsEmpty()) {
aDerived->minExclusive.value.AssignLiteral("0");
}
rv = ValidateBuiltinTypeInteger(aNodeValue,
aDerived->totalDigits.value,
aDerived->maxExclusive.value,
aDerived->minExclusive.value,
aDerived->maxInclusive.value,
aDerived->minInclusive.value,
&aDerived->enumerationList,
&isValid);
break;
}
/* http://www.w3.org/TR/xmlschema-2/#long */
case nsISchemaBuiltinType::BUILTIN_TYPE_LONG: {
if (aDerived->maxInclusive.value.IsEmpty()) {
aDerived->maxInclusive.value.AssignLiteral("9223372036854775807");
}
if (aDerived->minInclusive.value.IsEmpty()) {
aDerived->minInclusive.value.AssignLiteral("-1");
aDerived->minInclusive.value.AssignLiteral("-9223372036854775808");
}
rv = ValidateBuiltinTypeInteger(aNodeValue,
aDerived->totalDigits.value,
aDerived->maxExclusive.value,
aDerived->minExclusive.value,
aDerived->maxInclusive.value,
aDerived->minInclusive.value,
&aDerived->enumerationList,
&isValid);
break;
}
/* http://www.w3.org/TR/xmlschema-2/#int */
case nsISchemaBuiltinType::BUILTIN_TYPE_INT: {
if (aDerived->maxInclusive.value.IsEmpty()) {
aDerived->maxInclusive.value.AssignLiteral("2147483647");
}
if (aDerived->minInclusive.value.IsEmpty()) {
aDerived->minInclusive.value.AssignLiteral("-2147483648");
}
rv = ValidateBuiltinTypeInteger(aNodeValue,
aDerived->totalDigits.value,
aDerived->maxExclusive.value,
aDerived->minExclusive.value,
aDerived->maxInclusive.value,
aDerived->minInclusive.value,
&aDerived->enumerationList,
&isValid);
break;
}
/* http://www.w3.org/TR/xmlschema-2/#short */
case nsISchemaBuiltinType::BUILTIN_TYPE_SHORT: {
if (aDerived->maxInclusive.value.IsEmpty()) {
aDerived->maxInclusive.value.AssignLiteral("32767");
}
if (aDerived->minInclusive.value.IsEmpty()) {
aDerived->minInclusive.value.AssignLiteral("-32768");
}
rv = ValidateBuiltinTypeInteger(aNodeValue,
aDerived->totalDigits.value,
aDerived->maxExclusive.value,
aDerived->minExclusive.value,
aDerived->maxInclusive.value,
aDerived->minInclusive.value,
&aDerived->enumerationList,
&isValid);
break;
}
/* http://www.w3.org/TR/xmlschema-2/#unsignedLong */
case nsISchemaBuiltinType::BUILTIN_TYPE_UNSIGNEDLONG: {
if (aDerived->maxInclusive.value.IsEmpty()) {
aDerived->maxInclusive.value.AssignLiteral("18446744073709551615");
}
if (aDerived->minInclusive.value.IsEmpty()) {
aDerived->minInclusive.value.AssignLiteral("0");
}
rv = ValidateBuiltinTypeInteger(aNodeValue,
aDerived->totalDigits.value,
aDerived->maxExclusive.value,
aDerived->minExclusive.value,
aDerived->maxInclusive.value,
aDerived->minInclusive.value,
&aDerived->enumerationList,
&isValid);
break;
}
/* http://www.w3.org/TR/xmlschema-2/#unsignedInt */
case nsISchemaBuiltinType::BUILTIN_TYPE_UNSIGNEDINT: {
if (aDerived->maxInclusive.value.IsEmpty()) {
aDerived->maxInclusive.value.AssignLiteral("4294967295");
}
if (aDerived->minInclusive.value.IsEmpty()) {
aDerived->minInclusive.value.AssignLiteral("0");
}
rv = ValidateBuiltinTypeInteger(aNodeValue,
aDerived->totalDigits.value,
aDerived->maxExclusive.value,
aDerived->minExclusive.value,
aDerived->maxInclusive.value,
aDerived->minInclusive.value,
&aDerived->enumerationList,
&isValid);
break;
}
/* http://www.w3.org/TR/xmlschema-2/#unsignedShort */
case nsISchemaBuiltinType::BUILTIN_TYPE_UNSIGNEDSHORT: {
if (aDerived->maxInclusive.value.IsEmpty()) {
aDerived->maxInclusive.value.AssignLiteral("65535");
}
if (aDerived->minInclusive.value.IsEmpty()) {
aDerived->minInclusive.value.AssignLiteral("0");
}
rv = ValidateBuiltinTypeInteger(aNodeValue,
aDerived->totalDigits.value,
aDerived->maxExclusive.value,
aDerived->minExclusive.value,
aDerived->maxInclusive.value,
aDerived->minInclusive.value,
&aDerived->enumerationList,
&isValid);
break;
}
/* http://www.w3.org/TR/xmlschema-2/#unsignedByte */
case nsISchemaBuiltinType::BUILTIN_TYPE_UNSIGNEDBYTE: {
if (aDerived->maxInclusive.value.IsEmpty()) {
aDerived->maxInclusive.value.AssignLiteral("255");
}
if (aDerived->minInclusive.value.IsEmpty()) {
aDerived->minInclusive.value.AssignLiteral("0");
}
rv = ValidateBuiltinTypeInteger(aNodeValue,
@ -745,6 +952,30 @@ nsSchemaValidator::ValidateBuiltinType(const nsAString & aNodeValue,
break;
}
case nsISchemaBuiltinType::BUILTIN_TYPE_NORMALIZED_STRING: {
if (nsSchemaValidatorUtils::IsValidSchemaNormalizedString(aNodeValue)) {
rv = ValidateBuiltinTypeString(aNodeValue, 0, PR_FALSE, 0, PR_FALSE, 0,
PR_FALSE, nsnull, &isValid);
}
break;
}
case nsISchemaBuiltinType::BUILTIN_TYPE_TOKEN: {
if (nsSchemaValidatorUtils::IsValidSchemaToken(aNodeValue)) {
rv = ValidateBuiltinTypeString(aNodeValue, 0, PR_FALSE, 0, PR_FALSE, 0,
PR_FALSE, nsnull, &isValid);
}
break;
}
case nsISchemaBuiltinType::BUILTIN_TYPE_LANGUAGE: {
if (nsSchemaValidatorUtils::IsValidSchemaLanguage(aNodeValue)) {
rv = ValidateBuiltinTypeString(aNodeValue, 0, PR_FALSE, 0, PR_FALSE, 0,
PR_FALSE, nsnull, &isValid);
}
break;
}
case nsISchemaBuiltinType::BUILTIN_TYPE_BOOLEAN: {
rv = ValidateBuiltinTypeBoolean(aNodeValue, &isValid);
break;
@ -803,24 +1034,105 @@ nsSchemaValidator::ValidateBuiltinType(const nsAString & aNodeValue,
/* http://w3.org/TR/xmlschema-2/#nonPositiveInteger */
case nsISchemaBuiltinType::BUILTIN_TYPE_NONPOSITIVEINTEGER: {
// nonPositiveInteger inherits from integer, with maxExclusive
// being 1
ValidateBuiltinTypeInteger(aNodeValue, nsnull, NS_LITERAL_STRING("1"),
EmptyString(), EmptyString(), EmptyString(),
nsnull, &isValid);
// nonPositiveInteger inherits from integer, with maxInclusive
// being 0
ValidateBuiltinTypeInteger(aNodeValue, nsnull, EmptyString(),
EmptyString(), NS_LITERAL_STRING("0"),
EmptyString(), nsnull, &isValid);
break;
}
/* http://www.w3.org/TR/xmlschema-2/#negativeInteger */
case nsISchemaBuiltinType::BUILTIN_TYPE_NEGATIVEINTEGER: {
// negativeInteger inherits from integer, with maxExclusive
// being 0 (only negative numbers)
ValidateBuiltinTypeInteger(aNodeValue, nsnull, NS_LITERAL_STRING("0"),
EmptyString(), EmptyString(), EmptyString(),
nsnull, &isValid);
// negativeInteger inherits from integer, with maxInclusive
// being -1 (only negative integers)
ValidateBuiltinTypeInteger(aNodeValue, nsnull, EmptyString(),
EmptyString(), NS_LITERAL_STRING("-1"),
EmptyString(), nsnull, &isValid);
break;
}
/* http://w3.org/TR/xmlschema-2/#positiveInteger */
case nsISchemaBuiltinType::BUILTIN_TYPE_POSITIVEINTEGER: {
// positiveInteger inherits from integer, with minInclusive
// being 1
ValidateBuiltinTypeInteger(aNodeValue, nsnull, EmptyString(),
EmptyString(), EmptyString(),
NS_LITERAL_STRING("1"), nsnull, &isValid);
break;
}
/* http://www.w3.org/TR/xmlschema-2/#long */
case nsISchemaBuiltinType::BUILTIN_TYPE_LONG: {
// maxInclusive is 9223372036854775807 and minInclusive is
// -9223372036854775808
ValidateBuiltinTypeInteger(aNodeValue, nsnull,
EmptyString(), EmptyString(),
NS_LITERAL_STRING("9223372036854775807"),
NS_LITERAL_STRING("-9223372036854775808"),
nsnull, &isValid);
}
/* http://www.w3.org/TR/xmlschema-2/#int */
case nsISchemaBuiltinType::BUILTIN_TYPE_INT: {
// maxInclusive is 2147483647 and minInclusive is -2147483648
ValidateBuiltinTypeInteger(aNodeValue, nsnull,
EmptyString(), EmptyString(),
NS_LITERAL_STRING("2147483647"),
NS_LITERAL_STRING("-2147483648"),
nsnull, &isValid);
}
/* http://www.w3.org/TR/xmlschema-2/#short */
case nsISchemaBuiltinType::BUILTIN_TYPE_SHORT: {
// maxInclusive is 32767 and minInclusive is -32768
ValidateBuiltinTypeInteger(aNodeValue, nsnull,
EmptyString(), EmptyString(),
NS_LITERAL_STRING("32767"),
NS_LITERAL_STRING("-32768"),
nsnull, &isValid);
}
/* http://www.w3.org/TR/xmlschema-2/#unsignedLong */
case nsISchemaBuiltinType::BUILTIN_TYPE_UNSIGNEDLONG: {
// maxInclusive is 18446744073709551615. and minInclusive is 0
ValidateBuiltinTypeInteger(aNodeValue, nsnull,
EmptyString(), EmptyString(),
NS_LITERAL_STRING("18446744073709551615"),
NS_LITERAL_STRING("0"),
nsnull, &isValid);
}
/* http://www.w3.org/TR/xmlschema-2/#unsignedInt */
case nsISchemaBuiltinType::BUILTIN_TYPE_UNSIGNEDINT: {
// maxInclusive is 4294967295. and minInclusive is 0
ValidateBuiltinTypeInteger(aNodeValue, nsnull,
EmptyString(), EmptyString(),
NS_LITERAL_STRING("4294967295"),
NS_LITERAL_STRING("0"),
nsnull, &isValid);
}
/* http://www.w3.org/TR/xmlschema-2/#unsignedShort */
case nsISchemaBuiltinType::BUILTIN_TYPE_UNSIGNEDSHORT: {
// maxInclusive is 65535. and minInclusive is 0
ValidateBuiltinTypeInteger(aNodeValue, nsnull,
EmptyString(), EmptyString(),
NS_LITERAL_STRING("65535"),
NS_LITERAL_STRING("0"),
nsnull, &isValid);
}
/* http://www.w3.org/TR/xmlschema-2/#unsignedByte */
case nsISchemaBuiltinType::BUILTIN_TYPE_UNSIGNEDBYTE: {
// maxInclusive is 255. and minInclusive is 0
ValidateBuiltinTypeInteger(aNodeValue, nsnull,
EmptyString(), EmptyString(),
NS_LITERAL_STRING("255"),
NS_LITERAL_STRING("0"),
nsnull, &isValid);
}
case nsISchemaBuiltinType::BUILTIN_TYPE_BYTE: {
isValid = IsValidSchemaByte(aNodeValue, nsnull);
break;

View File

@ -87,8 +87,7 @@ nsSchemaValidatorUtils::IsValidSchemaInteger(const char* aString, long *aResult)
if (aResult)
*aResult = intValue;
return (!((intValue == LONG_MAX || intValue == LONG_MIN) && errno == ERANGE))
&& *pEnd == '\0';
return (*pEnd == '\0');
}
PRBool
@ -307,7 +306,7 @@ nsSchemaValidatorUtils::ParseSchemaDate(const nsAString & aStrValue,
fullDate.AppendLiteral("-");
fullDate.Append(year);
LOG(("\n Parsed date is %s", NS_ConvertUTF16toUTF8(fullDate).get()));
LOG((" Parsed date is %s", NS_ConvertUTF16toUTF8(fullDate).get()));
PRStatus status = PR_ParseTimeString(NS_ConvertUTF16toUTF8(fullDate).get(),
PR_TRUE, &dateTime);
@ -334,7 +333,7 @@ nsSchemaValidatorUtils::ParseSchemaDate(const nsAString & aStrValue,
}
}
LOG(("\n Date is %s \n", ((isValid) ? "Valid" : "Not Valid")));
LOG((" Date is %s", ((isValid) ? "Valid" : "Not Valid")));
return isValid;
}
@ -1177,6 +1176,7 @@ nsSchemaValidatorUtils::CompareDurations(nsISchemaDuration *aDuration1,
PRTime foo;
PRExplodedTime explodedTime, newTime1, newTime2;
// XXX: nspr doesn't handle pre-1900 dates and will return an error!
char* datetimeArray[] = { "1696-09-01T00:00:00Z", "1697-02-01T00:00:00Z",
"1903-03-01T00:00:00Z", "1903-07-01T00:00:00Z" };
PRBool indeterminate = PR_FALSE;
@ -1294,6 +1294,56 @@ nsSchemaValidatorUtils::AddDurationToDatetime(PRExplodedTime aDatetime,
return resultDatetime;
}
// http://www.w3.org/TR/xmlschema-2/#normalizedString
PRBool
nsSchemaValidatorUtils::IsValidSchemaNormalizedString(const nsAString &aStrValue)
{
PRBool isValid = PR_FALSE;
nsAutoString string(aStrValue);
// may not contain carriage return, line feed nor tab characters
if (string.FindCharInSet("\t\r\n") == kNotFound)
isValid = PR_TRUE;
return isValid;
}
// http://www.w3.org/TR/xmlschema-2/#token
PRBool
nsSchemaValidatorUtils::IsValidSchemaToken(const nsAString &aStrValue)
{
PRBool isValid = PR_FALSE;
nsAutoString string(aStrValue);
// may not contain carriage return, line feed, tab characters. Also can
// not contain leading/trailing whitespace and no internal sequences of
// two or more spaces.
if ((string.FindCharInSet("\t\r\n") == kNotFound) &&
(string.Find(NS_LITERAL_STRING(" ")) == kNotFound) &&
(string.First() != ' ') &&
(string.Last() != ' '))
isValid = PR_TRUE;
return isValid;
}
// http://www.w3.org/TR/xmlschema-2/#language
PRBool
nsSchemaValidatorUtils::IsValidSchemaLanguage(const nsAString &aStrValue)
{
PRBool isValid = PR_FALSE;
// pattern is defined in spec
nsAutoString pattern;
pattern.AssignLiteral("[a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*");
nsCOMPtr<nsISchemaValidatorRegexp> regexp = do_GetService(kREGEXP_CID);
nsresult rv = regexp->RunRegexp(aStrValue, pattern, "g", &isValid);
NS_ENSURE_SUCCESS(rv, rv);
return isValid;
}
PRBool
nsSchemaValidatorUtils::HandleEnumeration(const nsAString &aStrValue,
const nsStringArray &aEnumerationList)
@ -1388,7 +1438,7 @@ nsresult
nsSchemaValidatorUtils::GetDerivedSimpleType(nsISchemaSimpleType *aSimpleType,
nsSchemaDerivedSimpleType *aDerived)
{
PRBool done, hasEnumerations = PR_FALSE;
PRBool done = PR_FALSE, hasEnumerations = PR_FALSE;
nsCOMPtr<nsISchemaSimpleType> simpleType(aSimpleType);
PRUint16 simpleTypeValue;
PRUint32 facetCount;

View File

@ -42,8 +42,11 @@
#include "nsCOMPtr.h"
#include "nsString.h"
#include "nsISchema.h"
#include "nsISchemaDuration.h"
#include "nsCOMArray.h"
#include "nsIServiceManager.h"
#include "nsIComponentManager.h"
#include "nsISchemaDuration.h"
#include "nsISchemaValidatorRegexp.h"
struct nsSchemaGDay {
PRUint32 day; // day represented (1-31)
@ -96,6 +99,8 @@ const nsMonthShortHand monthShortHand[] = {
{ "12", "Dec" }
};
#define kREGEXP_CID "@mozilla.org/xmlextras/schemas/schemavalidatorregexp;1"
class nsSchemaStringFacet
{
public:
@ -146,6 +151,9 @@ public:
static PRBool IsValidSchemaInteger(const nsAString & aNodeValue, long *aResult);
static PRBool IsValidSchemaInteger(const char* aString, long *aResult);
static PRBool IsValidSchemaDouble(const nsAString & aNodeValue, double *aResult);
static PRBool IsValidSchemaDouble(const char* aString, double *aResult);
static PRBool ParseSchemaDate(const nsAString & aStrValue, char *rv_year,
char *rv_month, char *rv_day);
static PRBool ParseSchemaTime(const nsAString & aStrValue, char *rv_hour,
@ -182,6 +190,10 @@ public:
static PRExplodedTime AddDurationToDatetime(PRExplodedTime aDatetime,
nsISchemaDuration *aDuration);
static PRBool IsValidSchemaNormalizedString(const nsAString & aStrValue);
static PRBool IsValidSchemaToken(const nsAString & aStrValue);
static PRBool IsValidSchemaLanguage(const nsAString & aStrValue);
static PRBool HandleEnumeration(const nsAString &aStrValue,
const nsStringArray &aEnumerationList);
@ -196,9 +208,6 @@ private:
nsSchemaValidatorUtils();
~nsSchemaValidatorUtils();
static PRBool IsValidSchemaDouble(const nsAString & aNodeValue, double *aResult);
static PRBool IsValidSchemaDouble(const char* aString, double *aResult);
protected:
};

View File

@ -138,17 +138,6 @@
start = new Date();
/*
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);*/
if (1) {
validate("220", "integer-test-1", false);
validate("2", "integer-test-1", false);
@ -167,6 +156,23 @@
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", "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);
@ -207,6 +213,7 @@
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);
@ -230,6 +237,47 @@
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);
@ -256,7 +304,7 @@
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("----3", "gday-test-1", false);
validate("---03", "gday-test-2", false);
validate("---14", "gday-test-2", true);
@ -272,28 +320,28 @@
validate("---05", "gday-test-3", true);
validate("---21", "gday-test-3", true);
validate("--01--", "gmonth-test-1", true);
validate("--05--Z", "gmonth-test-1", true);
validate("--05---03:43", "gmonth-test-1", true);
validate("--05--a03: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-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-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("--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);
@ -487,11 +535,83 @@
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("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-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("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", true);
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);
}
end = new Date();

View File

@ -21,12 +21,59 @@
</restriction>
</simpleType>
<simpleType name="test-nonPositiveInteger">
<simpleType name="nonPositiveInteger-test-1">
<restriction base='nonPositiveInteger'>
<totalDigits value="3"/>
</restriction>
</simpleType>
<simpleType name="positiveInteger-test-1">
<restriction base='positiveInteger'>
<totalDigits value="3"/>
</restriction>
</simpleType>
<simpleType name="negativeInteger-test-1">
<restriction base='negativeInteger'>
<totalDigits value="3"/>
</restriction>
</simpleType>
<simpleType name='long-test-1'>
<restriction base='long'>
</restriction>
</simpleType>
<simpleType name='int-test-1'>
<restriction base='int'>
</restriction>
</simpleType>
<simpleType name='short-test-1'>
<restriction base='short'>
</restriction>
</simpleType>
<simpleType name='unsignedLong-test-1'>
<restriction base='unsignedLong'>
</restriction>
</simpleType>
<simpleType name='unsignedInt-test-1'>
<restriction base='unsignedInt'>
</restriction>
</simpleType>
<simpleType name='unsignedShort-test-1'>
<restriction base='unsignedShort'>
</restriction>
</simpleType>
<simpleType name='unsignedByte-test-1'>
<restriction base='unsignedByte'>
</restriction>
</simpleType>
<simpleType name="byte-test-1">
<restriction base='byte'>
</restriction>
@ -139,15 +186,15 @@
<simpleType name="gmonth-test-2">
<restriction base='gMonth'>
<maxExclusive value="--11--Z"/>
<minExclusive value="--05--"/>
<maxExclusive value="--11Z"/>
<minExclusive value="--05"/>
</restriction>
</simpleType>
<simpleType name="gmonth-test-3">
<restriction base='gMonth'>
<maxInclusive value="--11--"/>
<minInclusive value="--05--"/>
<maxInclusive value="--11"/>
<minInclusive value="--05"/>
</restriction>
</simpleType>
@ -284,7 +331,6 @@
</restriction>
</simpleType>
<simpleType name="anyuri-test-1">
<restriction base='anyURI'>
</restriction>
@ -339,7 +385,6 @@
</restriction>
</simpleType>
<simpleType name="list-test-1">
<list itemType="boolean"/>
</simpleType>
@ -367,7 +412,76 @@
</restriction>
</simpleType>
</union>
</simpleType>
</simpleType>
<simpleType name="TypeCode">
<restriction base="test:UrType">
<enumeration value="Applicanter"/>
<enumeration value="Applicant"/>
<enumeration value="Third_Party"/>
<enumeration value="Trustee"/>
<maxLength value="50"/>
</restriction>
</simpleType>
<simpleType name="UrType">
<restriction base="string">
</restriction>
</simpleType>
<simpleType name="IndividualRole">
<restriction base="test:TypeCode">
<enumeration value="Applicant"/>
<enumeration value="Third_Party"/>
<enumeration value="Trustee"/>
</restriction>
</simpleType>
<simpleType name='IndividualRoleList'>
<list itemType='test:IndividualRole'/>
</simpleType>
<simpleType name='IndividualRoleListType'>
<restriction base='test:IndividualRoleList'>
<maxLength value='4'/>
</restriction>
</simpleType>
<simpleType name='IndividualRoleListType2'>
<restriction base='test:IndividualRoleList'>
<length value='4'/>
</restriction>
</simpleType>
<simpleType name='IndividualRoleListType3'>
<restriction base='test:IndividualRoleList'>
<minLength value='4'/>
</restriction>
</simpleType>
<simpleType name="RoleUnion">
<union>
<simpleType>
<restriction base="test:IndividualRoleListType"/>
</simpleType>
<simpleType>
<restriction base="string">
<enumeration value="N/A"/>
</restriction>
</simpleType>
<simpleType>
<restriction base="string">
<maxLength value="4"/>
</restriction>
</simpleType>
</union>
</simpleType>
<simpleType name='IndividualRoleListType5'>
<restriction base='test:IndividualRoleList'>
<enumeration value='Applicant Trustee'/>
</restriction>
</simpleType>
<!-- complex types -->