зеркало из https://github.com/mozilla/pjs.git
Bug 223097 - XML Schema Validation initial checkin, not built by default. Lives in extensions/schema-validation. r=jst for build changes.
This commit is contained in:
Родитель
e3a56eb14f
Коммит
c83f31dad5
|
@ -1472,6 +1472,11 @@ for extension in $MOZ_EXTENSIONS; do
|
|||
sql ) MAKEFILES_extensions="$MAKEFILES_extensions
|
||||
$MAKEFILES_sql"
|
||||
;;
|
||||
schema-validation ) MAKEFILES_extensions="$MAKEFILES_extensions
|
||||
extensions/schema-validation/Makefile
|
||||
extensions/schema-validation/public/Makefile
|
||||
extensions/schema-validation/src/Makefile
|
||||
" ;;
|
||||
esac
|
||||
done
|
||||
|
||||
|
|
|
@ -4097,7 +4097,7 @@ dnl ========================================================
|
|||
dnl = Enable compilation of specific extension modules
|
||||
dnl ========================================================
|
||||
|
||||
MOZ_EXTENSIONS_ALL=" cookie wallet content-packs xml-rpc xmlextras help p3p pref transformiix venkman inspector irc universalchardet typeaheadfind webservices spellcheck gnomevfs negotiateauth sroaming xmlterm datetime finger cview layout-debug tasks sql xforms"
|
||||
MOZ_EXTENSIONS_ALL=" cookie wallet content-packs xml-rpc xmlextras help p3p pref transformiix venkman inspector irc universalchardet typeaheadfind webservices spellcheck gnomevfs negotiateauth sroaming xmlterm datetime finger cview layout-debug tasks sql xforms schema-validation"
|
||||
|
||||
MOZ_ARG_ENABLE_STRING(extensions,
|
||||
[ --enable-extensions Enable extensions],
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
#
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# IBM Corporation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 2004
|
||||
# IBM Corporation. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
DEPTH = ../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = schema-validation
|
||||
DIRS = public src
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
#
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# IBM Corporation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 2004
|
||||
# IBM Corporation. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = schema-validation
|
||||
|
||||
XPIDLSRCS = \
|
||||
nsISchemaValidator.idl \
|
||||
nsISchemaValidatorRegexp.idl \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
#include "nsISupports.idl"
|
||||
#include "nsISchema.idl"
|
||||
#include "nsIDOMNode.idl"
|
||||
|
||||
[scriptable, uuid(eced2af3-fde9-4575-b5a4-e1c830b24611)]
|
||||
interface nsISchemaValidator : nsISupports {
|
||||
void loadSchema(in nsISchema aSchema);
|
||||
boolean validate(in nsIDOMNode aElement);
|
||||
boolean validateString(in AString aValue, in AString aType, in AString aNamespace);
|
||||
};
|
|
@ -0,0 +1,17 @@
|
|||
#include "nsISupports.idl"
|
||||
|
||||
[scriptable, uuid(26d69f7e-f7cf-423d-afb9-43d8a9ebf3ba)]
|
||||
interface nsISchemaValidatorRegexp : nsISupports {
|
||||
boolean runRegexp(in DOMString aString, in DOMString aRegexpString, in string aModifierString);
|
||||
};
|
||||
|
||||
%{ C++
|
||||
#define NS_SCHEMAVALIDATORREGEXP_CID \
|
||||
{ /* 26d69f7e-f7cf-423d-afb9-43d8a9ebf3ba */ \
|
||||
0x26d69f7e, 0xf7cf, 0x423d, \
|
||||
{0xaf, 0xb9, 0x43, 0xd8, 0xa9, 0xeb, 0xf3, 0xba}}
|
||||
|
||||
#define NS_SCHEMAVALIDATORREGEXP_CONTRACTID "@mozilla.org/xmlextras/schemas/schemavalidatorregexp;1"
|
||||
|
||||
|
||||
%}
|
|
@ -0,0 +1,80 @@
|
|||
#
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# IBM Corporation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 2004
|
||||
# IBM Corporation. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = schema-validation
|
||||
LIBRARY_NAME = schemavalidation
|
||||
EXPORT_LIBRARY = 1
|
||||
IS_COMPONENT = 1
|
||||
GRE_MODULE = 1
|
||||
MODULE_NAME = schema-validation
|
||||
REQUIRES = xpcom \
|
||||
string \
|
||||
dom \
|
||||
xpconnect \
|
||||
caps \
|
||||
widget \
|
||||
unicharutil \
|
||||
content \
|
||||
js \
|
||||
necko \
|
||||
xmlextras \
|
||||
websrvcs \
|
||||
$(NULL)
|
||||
|
||||
CPPSRCS = \
|
||||
nsSchemaValidatorModule.cpp \
|
||||
nsSchemaValidator.cpp \
|
||||
nsSchemaValidatorUtils.cpp \
|
||||
$(NULL)
|
||||
|
||||
EXTRA_DSO_LDOPTS = \
|
||||
$(LIBS_DIR) \
|
||||
$(MOZ_COMPONENT_LIBS) \
|
||||
$(ZLIB_LIBS) \
|
||||
$(MOZ_JS_LIBS) \
|
||||
$(MOZ_UNICHARUTIL_LIBS) \
|
||||
$(NULL)
|
||||
EXTRA_COMPONENTS = nsSchemaValidatorRegexp.js
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,226 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Schema Validation.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* IBM Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2004
|
||||
* IBM Corporation. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Doron Rosenberg <doronr@us.ibm.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef __nsSchemaValidator_h__
|
||||
#define __nsSchemaValidator_h__
|
||||
|
||||
#include "nsISchemaValidator.h"
|
||||
#include "nsISchema.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
typedef struct Schema_GDay {
|
||||
int day; // day represented (1-31)
|
||||
PRBool tz_negative; // is timezone negative
|
||||
int tz_hour; // timezone - hour (0-23) - null if not specified
|
||||
int tz_minute; // timezone - minute (0-59) - null if not specified
|
||||
} ;
|
||||
|
||||
typedef struct Schema_GMonth {
|
||||
int month; // month represented (1-12)
|
||||
PRBool tz_negative; // is timezone negative
|
||||
int tz_hour; // timezone - hour (0-23) - null if not specified
|
||||
int tz_minute; // timezone - minute (0-59) - null if not specified
|
||||
} ;
|
||||
|
||||
typedef struct Schema_GYear {
|
||||
long year; // year
|
||||
PRBool tz_negative; // is timezone negative
|
||||
int tz_hour; // timezone - hour (0-23) - null if not specified
|
||||
int tz_minute; // timezone - minute (0-59) - null if not specified
|
||||
} ;
|
||||
|
||||
typedef struct Schema_GYearMonth {
|
||||
Schema_GYear gYear;
|
||||
Schema_GMonth gMonth;
|
||||
} ;
|
||||
|
||||
typedef struct Schema_GMonthDay {
|
||||
Schema_GMonth gMonth;
|
||||
Schema_GDay gDay;
|
||||
} ;
|
||||
|
||||
typedef struct Schema_Duration {
|
||||
long years;
|
||||
long months;
|
||||
long days;
|
||||
long hours;
|
||||
long minutes;
|
||||
long seconds;
|
||||
long fractional_seconds;
|
||||
|
||||
Schema_Duration() {
|
||||
// -1 means not set
|
||||
years = -1;
|
||||
months = -1;
|
||||
days = -1;
|
||||
hours = -1;
|
||||
minutes = -1;
|
||||
seconds = -1;
|
||||
fractional_seconds = -1;
|
||||
}
|
||||
} ;
|
||||
|
||||
/* eced2af3-fde9-4575-b5a4-e1c830b24611 */
|
||||
#define NS_SCHEMAVALIDATOR_CID \
|
||||
{ 0xeced2af3, 0xfde9, 0x4575, \
|
||||
{0xb5, 0xa4, 0xe1, 0xc8, 0x30, 0xb2, 0x46, 0x11}}
|
||||
|
||||
#define NS_SCHEMAVALIDATOR_CONTRACTID "@mozilla.org/schemavalidator;1"
|
||||
|
||||
#define NS_ERROR_SCHEMAVALIDATOR_NO_SCHEMA_LOADED NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_SCHEMA, 1)
|
||||
#define NS_ERROR_SCHEMAVALIDATOR_NO_DOM_NODE_LOADED NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_SCHEMA, 2)
|
||||
#define NS_ERROR_SCHEMAVALIDATOR_NO_TYPE_FOUND NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_SCHEMA, 3)
|
||||
#define NS_ERROR_SCHEMAVALIDATOR_TYPE_NOT_FOUND NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_SCHEMA, 4)
|
||||
|
||||
class nsSchemaValidator : public nsISchemaValidator
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSISCHEMAVALIDATOR
|
||||
|
||||
nsSchemaValidator();
|
||||
|
||||
private:
|
||||
~nsSchemaValidator();
|
||||
|
||||
nsresult GetType(const nsAString & aType,
|
||||
const nsAString & aNamespace,
|
||||
nsISchemaType **aSchemaType);
|
||||
|
||||
// methods dealing with simpletypes
|
||||
nsresult ValidateSimpletype(const nsAString & aNodeValue, nsISchemaSimpleType *aSchemaSimpleType, PRBool *aResult);
|
||||
nsresult ValidateRestrictionSimpletype(const nsAString & aNodeValue, nsISchemaSimpleType *aSchemaSimpleType, PRBool *aResult);
|
||||
nsresult ValidateBuiltinType(const nsAString & aNodeValue, nsISchemaSimpleType *aSchemaSimpleType, PRBool *aResult);
|
||||
|
||||
// methods dealing with validation of built-in types
|
||||
nsresult ValidateBuiltinTypeString(const nsAString & aNodeValue,
|
||||
PRUint32 aLength, PRUint32 aMinLength, PRUint32 aMaxLength,
|
||||
PRBool *aResult);
|
||||
|
||||
nsresult ValidateBuiltinTypeBoolean(const nsAString & aNodeValue,
|
||||
PRBool *aResult);
|
||||
|
||||
nsresult ValidateBuiltinTypeGDay(const nsAString & aNodeValue,
|
||||
const nsAString & aMaxExclusive, const nsAString & aMinExclusive,
|
||||
const nsAString & aMaxInclusive, const nsAString & aMinInclusive,
|
||||
PRBool *aResult);
|
||||
PRBool IsValidSchemaGDay(const nsAString & aNodeValue, Schema_GDay *aResult);
|
||||
|
||||
PRBool IsValidSchemaGType(const nsAString & aNodeValue,
|
||||
long aMinValue, long aMaxValue, int *aResult);
|
||||
|
||||
nsresult ValidateBuiltinTypeGMonth(const nsAString & aNodeValue,
|
||||
const nsAString & aMaxExclusive, const nsAString & aMinExclusive,
|
||||
const nsAString & aMaxInclusive, const nsAString & aMinInclusive,
|
||||
PRBool *aResult);
|
||||
PRBool IsValidSchemaGMonth(const nsAString & aNodeValue, Schema_GMonth *aResult);
|
||||
|
||||
nsresult ValidateBuiltinTypeGYear(const nsAString & aNodeValue,
|
||||
const nsAString & aMaxExclusive, const nsAString & aMinExclusive,
|
||||
const nsAString & aMaxInclusive, const nsAString & aMinInclusive,
|
||||
PRBool *aResult);
|
||||
PRBool IsValidSchemaGYear(const nsAString & aNodeValue, Schema_GYear *aResult);
|
||||
|
||||
nsresult ValidateBuiltinTypeGYearMonth(const nsAString & aNodeValue,
|
||||
const nsAString & aMaxExclusive, const nsAString & aMinExclusive,
|
||||
const nsAString & aMaxInclusive, const nsAString & aMinInclusive,
|
||||
PRBool *aResult);
|
||||
PRBool IsValidSchemaGYearMonth(const nsAString & aNodeValue, Schema_GYearMonth *aYearMonth);
|
||||
|
||||
nsresult ValidateBuiltinTypeGMonthDay(const nsAString & aNodeValue,
|
||||
const nsAString & aMaxExclusive, const nsAString & aMinExclusive,
|
||||
const nsAString & aMaxInclusive, const nsAString & aMinInclusive,
|
||||
PRBool *aResult);
|
||||
PRBool IsValidSchemaGMonthDay(const nsAString & aNodeValue, Schema_GMonthDay *aYearMonth);
|
||||
|
||||
nsresult ValidateBuiltinTypeDateTime(const nsAString & aNodeValue,
|
||||
const nsAString & aMaxExclusive, const nsAString & aMinExclusive,
|
||||
const nsAString & aMaxInclusive, const nsAString & aMinInclusive,
|
||||
PRBool *aResult);
|
||||
int CompareSchemaDateTime(PRExplodedTime datetime1,
|
||||
PRBool isDateTime1Negative, PRTime datetime2,
|
||||
PRBool isDateTime2Negative);
|
||||
PRBool IsValidSchemaDateTime(const nsAString & aNodeValue, PRTime *aResult);
|
||||
|
||||
nsresult ValidateBuiltinTypeDate(const nsAString & aNodeValue,
|
||||
const nsAString & aMaxExclusive, const nsAString & aMinExclusive,
|
||||
const nsAString & aMaxInclusive, const nsAString & aMinInclusive,
|
||||
PRBool *aResult);
|
||||
PRBool IsValidSchemaDate(const nsAString & aNodeValue, PRTime *aResult);
|
||||
|
||||
nsresult ValidateBuiltinTypeTime(const nsAString & aNodeValue,
|
||||
const nsAString & aMaxExclusive, const nsAString & aMinExclusive,
|
||||
const nsAString & aMaxInclusive, const nsAString & aMinInclusive,
|
||||
PRBool *aResult);
|
||||
PRBool IsValidSchemaTime(const nsAString & aNodeValue, PRTime *aResult);
|
||||
|
||||
nsresult ValidateBuiltinTypeInteger(const nsAString & aNodeValue, PRUint32 aTotalDigits, const nsAString & aMaxExclusive,
|
||||
const nsAString & aMaxInclusive, const nsAString & aMinInclusive, const nsAString & aMinExclusive, PRBool *aResult);
|
||||
int CompareStrings(const nsAString & aString1, const nsAString & aString2);
|
||||
|
||||
nsresult ValidateBuiltinTypeFloat(const nsAString & aNodeValue, PRUint32 aTotalDigits, const nsAString & aMaxExclusive, const nsAString & aMinExclusive,
|
||||
const nsAString & aMaxInclusive, const nsAString & aMinInclusive, PRBool *aResult);
|
||||
PRBool IsValidSchemaFloat(const nsAString & aNodeValue, float *aResult);
|
||||
|
||||
nsresult ValidateBuiltinTypeByte(const nsAString & aNodeValue, PRUint32 aTotalDigits, const nsAString & aMaxExclusive,
|
||||
const nsAString & aMaxInclusive, const nsAString & aMinInclusive, const nsAString & aMinExclusive, PRBool *aResult);
|
||||
PRBool IsValidSchemaByte(const nsAString & aNodeValue, long *aResult);
|
||||
|
||||
nsresult ValidateBuiltinTypeDecimal(const nsAString & aNodeValue, PRUint32 aTotalDigits, const nsAString & aMaxExclusive, const nsAString & aMinExclusive,
|
||||
const nsAString & aMaxInclusive, const nsAString & aMinInclusive, PRBool *aResult);
|
||||
PRBool IsValidSchemaDecimal(const nsAString & aNodeValue, nsAString & aWholePart, nsAString & aFractionPart);
|
||||
int CompareFractionStrings(const nsAString & aString1, const nsAString & aString2);
|
||||
|
||||
nsresult ValidateBuiltinTypeAnyURI(const nsAString & aNodeValue,
|
||||
PRUint32 aLength, PRUint32 aMinLength, PRUint32 aMaxLength,
|
||||
PRBool *aResult);
|
||||
PRBool IsValidSchemaAnyURI(const nsAString & aString);
|
||||
|
||||
nsresult ValidateBuiltinTypeBase64Binary(const nsAString & aNodeValue,
|
||||
PRUint32 aLength, PRUint32 aMinLength, PRUint32 aMaxLength,
|
||||
PRBool *aResult);
|
||||
PRBool IsValidSchemaBase64Binary(const nsAString & aString, char** aDecodedString);
|
||||
|
||||
// helper methods
|
||||
void DumpBaseType(nsISchemaBuiltinType *aBuiltInType);
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsISchema> mSchema;
|
||||
};
|
||||
|
||||
#endif // __nsSchemaValidator_h__
|
|
@ -0,0 +1,60 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Schema Validation.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* IBM Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2004
|
||||
* IBM Corporation. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Doron Rosenberg <doronr@us.ibm.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsIGenericFactory.h"
|
||||
#include "nsSchemaValidator.h"
|
||||
|
||||
NS_DECL_CLASSINFO(nsSchemaValidator)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSchemaValidator)
|
||||
|
||||
static const nsModuleComponentInfo components[] = {
|
||||
{ "SchemaValidator",
|
||||
NS_SCHEMAVALIDATOR_CID,
|
||||
NS_SCHEMAVALIDATOR_CONTRACTID,
|
||||
nsSchemaValidatorConstructor }
|
||||
};
|
||||
|
||||
PR_STATIC_CALLBACK(nsresult)
|
||||
SchemaValidatorModuleCtor(nsIModule* aSelf)
|
||||
{
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMPL_NSGETMODULE_WITH_CTOR(nsSchemaValidatorModule, components, SchemaValidatorModuleCtor)
|
||||
|
|
@ -0,0 +1,91 @@
|
|||
const kSERVICE_CONTRACTID = "@mozilla.org/xmlextras/schemas/schemavalidatorregexp;1";
|
||||
const kSERVICE_CID = Components.ID("26d69f7e-f7cf-423d-afb9-43d8a9ebf3ba");
|
||||
const nsISupports = Components.interfaces.nsISupports;
|
||||
|
||||
function nsSchemaValidatorRegexp()
|
||||
{
|
||||
}
|
||||
|
||||
nsSchemaValidatorRegexp.prototype.runRegexp = function(aString, aRegexpString, aModifierString) {
|
||||
var rv = false;
|
||||
|
||||
// dump("\n String is: " + aString);
|
||||
// dump("\n Regexp is: " + aRegexpString);
|
||||
// dump("\n Modifier is: " + aModifierString);
|
||||
|
||||
var myRegExp = RegExp(aRegexpString, aModifierString);
|
||||
|
||||
if (aString.match(myRegExp)) {
|
||||
rv = true;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsSchemaValidatorRegexp.prototype.QueryInterface = function(iid) {
|
||||
if (!iid.equals(Components.interfaces.nsISchemaValidatorRegexp) &&
|
||||
!iid.equals(Components.interfaces.nsISchemaValidator) &&
|
||||
!iid.equals(nsISupports))
|
||||
throw Components.results.NS_ERROR_NO_INTERFACE;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* JS XPCOM component registration goop:
|
||||
*
|
||||
* We set ourselves up to observe the xpcom-startup category. This provides
|
||||
* us with a starting point.
|
||||
*/
|
||||
|
||||
var nsSchemaValidatorRegexpModule = new Object();
|
||||
|
||||
nsSchemaValidatorRegexpModule.registerSelf =
|
||||
function (compMgr, fileSpec, location, type)
|
||||
{
|
||||
compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
|
||||
compMgr.registerFactoryLocation(kSERVICE_CID,
|
||||
"nsSchemaValidatorRegexp",
|
||||
kSERVICE_CONTRACTID,
|
||||
fileSpec,
|
||||
location,
|
||||
type);
|
||||
}
|
||||
|
||||
nsSchemaValidatorRegexpModule.getClassObject =
|
||||
function (compMgr, cid, iid)
|
||||
{
|
||||
if (!cid.equals(kSERVICE_CID))
|
||||
throw Components.results.NS_ERROR_NO_INTERFACE;
|
||||
|
||||
if (!iid.equals(Components.interfaces.nsIFactory))
|
||||
throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
|
||||
|
||||
return nsSchemaValidatorRegexpFactory;
|
||||
}
|
||||
|
||||
nsSchemaValidatorRegexpModule.canUnload =
|
||||
function (compMgr)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
var nsSchemaValidatorRegexpFactory = new Object();
|
||||
|
||||
nsSchemaValidatorRegexpFactory.createInstance =
|
||||
function (outer, iid)
|
||||
{
|
||||
if (outer != null)
|
||||
throw Components.results.NS_ERROR_NO_AGGREGATION;
|
||||
|
||||
if (!iid.equals(Components.interfaces.nsISchemaValidatorRegexp) &&
|
||||
!iid.equals(nsISupports))
|
||||
throw Components.results.NS_ERROR_NO_INTERFACE;
|
||||
|
||||
return new nsSchemaValidatorRegexp();
|
||||
}
|
||||
|
||||
function NSGetModule(compMgr, fileSpec)
|
||||
{
|
||||
return nsSchemaValidatorRegexpModule;
|
||||
}
|
|
@ -0,0 +1,749 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Schema Validation.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* IBM Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2004
|
||||
* IBM Corporation. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Doron Rosenberg <doronr@us.ibm.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
// string includes
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsString.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
|
||||
#include "nsISchema.h"
|
||||
#include "nsSchemaValidator.h"
|
||||
#include "nsSchemaValidatorUtils.h"
|
||||
#include "nsISchemaValidatorRegexp.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "prprf.h"
|
||||
#include "prtime.h"
|
||||
|
||||
PRBool nsSchemaValidatorUtils::IsValidSchemaInteger(const nsAString & aNodeValue,
|
||||
long *aResult){
|
||||
PRBool isValid = PR_FALSE;
|
||||
NS_ConvertUTF16toUTF8 temp(aNodeValue);
|
||||
char * pEnd;
|
||||
long intValue = strtol(temp.get(), &pEnd, 10);
|
||||
|
||||
if (*pEnd == '\0')
|
||||
isValid = PR_TRUE;
|
||||
|
||||
if (aResult)
|
||||
*aResult = intValue;
|
||||
|
||||
return isValid;
|
||||
}
|
||||
|
||||
// overloaded, for char* rather than nsAString
|
||||
PRBool nsSchemaValidatorUtils::IsValidSchemaInteger(char* aString, long *aResult){
|
||||
PRBool isValid = PR_FALSE;
|
||||
char * pEnd;
|
||||
long intValue = strtol(aString, &pEnd, 10);
|
||||
|
||||
if (*pEnd == '\0')
|
||||
isValid = PR_TRUE;
|
||||
|
||||
if (aResult)
|
||||
*aResult = intValue;
|
||||
|
||||
return isValid;
|
||||
}
|
||||
|
||||
PRBool nsSchemaValidatorUtils::ParseSchemaDate(const char * strValue,
|
||||
char *rv_year, char *rv_month, char *rv_day)
|
||||
{
|
||||
PRBool isValid = PR_FALSE;
|
||||
PRBool isNegativeYear = PR_FALSE;
|
||||
|
||||
int run = 0;
|
||||
int length = strlen(strValue);
|
||||
PRBool doneParsing = PR_FALSE;
|
||||
|
||||
/*
|
||||
0 - year
|
||||
1 - Month MM
|
||||
2 - Day (DD)
|
||||
*/
|
||||
int parseState = 0;
|
||||
|
||||
char parseBuffer[80] = "";
|
||||
int bufferRun = 0;
|
||||
char year[80] = "";
|
||||
char month[3] = "";
|
||||
char day[3] = "";
|
||||
|
||||
PRTime dateTime;
|
||||
|
||||
char fulldate[86] = "";
|
||||
|
||||
// overflow check
|
||||
if (strlen(strValue) >= sizeof(fulldate))
|
||||
return PR_FALSE;
|
||||
|
||||
if (strValue[0] == '-') {
|
||||
isNegativeYear = PR_TRUE;
|
||||
run = 1;
|
||||
/* nspr can't handle negative years it seems.*/
|
||||
}
|
||||
/*
|
||||
http://www.w3.org/TR/xmlschema-2/#date
|
||||
(-)CCYY-MM-DDT
|
||||
*/
|
||||
#ifdef DEBUG
|
||||
printf("\n Validating Date part");
|
||||
#endif
|
||||
|
||||
while ( (run <= length) && (!doneParsing) ) {
|
||||
switch (parseState) {
|
||||
case 0: {
|
||||
// year
|
||||
if (strValue[run] == '-') {
|
||||
// finished
|
||||
parseState++;
|
||||
if (strlen(parseBuffer) < 4)
|
||||
doneParsing = PR_TRUE;
|
||||
|
||||
strcpy(year, parseBuffer);
|
||||
bufferRun = 0;
|
||||
} else {
|
||||
parseBuffer[bufferRun] = strValue[run];
|
||||
bufferRun++;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 1: {
|
||||
// month
|
||||
if (strValue[run] == '-') {
|
||||
// finished
|
||||
parseState++;
|
||||
|
||||
if (strlen(month) != 2)
|
||||
doneParsing = PR_TRUE;
|
||||
|
||||
bufferRun = 0;
|
||||
} else {
|
||||
if (bufferRun > 1)
|
||||
doneParsing = PR_TRUE;
|
||||
else {
|
||||
month[bufferRun] = strValue[run];
|
||||
bufferRun++;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 2: {
|
||||
// day
|
||||
if (strValue[run] == 'T') {
|
||||
// finished
|
||||
parseState++;
|
||||
|
||||
if (strlen(day) == 2)
|
||||
isValid = PR_TRUE;
|
||||
|
||||
doneParsing = PR_TRUE;
|
||||
} else {
|
||||
if (bufferRun > 1)
|
||||
doneParsing = PR_TRUE;
|
||||
else {
|
||||
day[bufferRun] = strValue[run];
|
||||
bufferRun++;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
run++;
|
||||
}
|
||||
|
||||
if (isValid) {
|
||||
nsCAutoString monthShorthand;
|
||||
nsSchemaValidatorUtils::GetMonthShorthand(month, monthShorthand);
|
||||
|
||||
// 22-AUG-1993
|
||||
sprintf(fulldate, "%s-%s-%s",day, monthShorthand.get(), year);
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("\n Parsed date is %s", fulldate);
|
||||
#endif
|
||||
PRStatus status = PR_ParseTimeString(fulldate,
|
||||
PR_TRUE, &dateTime);
|
||||
if (status == -1) {
|
||||
isValid = PR_FALSE;
|
||||
} else {
|
||||
// PRStatus will be 0 for feb 30th, but the returned day will be
|
||||
// different
|
||||
char * pEnd;
|
||||
long val = strtol(day, &pEnd, 10);
|
||||
|
||||
PRExplodedTime explodedDateTime;
|
||||
PR_ExplodeTime(dateTime, PR_GMTParameters, &explodedDateTime);
|
||||
|
||||
if (val != explodedDateTime.tm_mday) {
|
||||
isValid = PR_FALSE;
|
||||
}
|
||||
}
|
||||
strcpy(rv_day, day);
|
||||
strcpy(rv_month, month);
|
||||
strcpy(rv_year, year);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("\n Date is %s \n", ((isValid) ? "Valid" : "Not Valid"));
|
||||
#endif
|
||||
|
||||
return isValid;
|
||||
}
|
||||
|
||||
// parses a string as a schema time type and returns the parsed
|
||||
// hour/minute/second/fraction seconds as well as if its a valid
|
||||
// schema time type.
|
||||
PRBool nsSchemaValidatorUtils::ParseSchemaTime(const char * strValue,
|
||||
char *rv_hour, char *rv_minute, char *rv_second, char *rv_fraction_second)
|
||||
{
|
||||
PRBool isValid = PR_FALSE;
|
||||
|
||||
int run = 0;
|
||||
int length = strlen(strValue);
|
||||
PRBool doneParsing = PR_FALSE;
|
||||
|
||||
int parseState = 0;
|
||||
int bufferRun = 0;
|
||||
char hour[3] = "";
|
||||
char minute[3] = "";
|
||||
char second[3] = "";
|
||||
// there can be any amount of fraction seconds
|
||||
char fraction_seconds[80] = "";
|
||||
char timeZoneSign[2] = "";
|
||||
char timezoneHour[3] = "";
|
||||
char timezoneMinute[3] = "";
|
||||
|
||||
PRTime dateTime;
|
||||
|
||||
char fulldate[100] = "";
|
||||
|
||||
// overflow check
|
||||
if (strlen(strValue) >= sizeof(fulldate))
|
||||
return PR_FALSE;
|
||||
|
||||
/*
|
||||
http://www.w3.org/TR/xmlschema-2/#time
|
||||
(-)CCYY-MM-DDT
|
||||
*/
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("\n Validating Time part");
|
||||
#endif
|
||||
|
||||
while ( (run <= length) && (!doneParsing) ) {
|
||||
switch (parseState) {
|
||||
|
||||
case 0: {
|
||||
// hour
|
||||
if (strValue[run] == ':') {
|
||||
// finished
|
||||
parseState++;
|
||||
|
||||
if ( (strlen(hour) != 2) || (strcmp(hour, "24") == 1))
|
||||
doneParsing = PR_TRUE;
|
||||
|
||||
bufferRun = 0;
|
||||
} else {
|
||||
if (bufferRun > 1)
|
||||
doneParsing = PR_TRUE;
|
||||
else {
|
||||
hour[bufferRun] = strValue[run];
|
||||
bufferRun++;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 1: {
|
||||
// minutes
|
||||
if (strValue[run] == ':') {
|
||||
// finished
|
||||
parseState++;
|
||||
|
||||
if ((strlen(minute) != 2) || (strcmp(minute, "59") == 1))
|
||||
doneParsing = PR_TRUE;
|
||||
|
||||
bufferRun = 0;
|
||||
} else {
|
||||
if ((bufferRun > 1) || (strValue[run] > '9') || (strValue[run] < '0'))
|
||||
doneParsing = PR_TRUE;
|
||||
else {
|
||||
minute[bufferRun] = strValue[run];
|
||||
bufferRun++;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 2: {
|
||||
// seconds
|
||||
if ((strValue[run] == 'Z') || (strValue[run] == '-') || (strValue[run] == '+')) {
|
||||
// finished
|
||||
parseState = 4;
|
||||
|
||||
if (strlen(second) != 2)
|
||||
doneParsing = PR_TRUE;
|
||||
else if (strValue[run] == 'Z') {
|
||||
if (strValue[run+1] == '\0')
|
||||
isValid = PR_TRUE;
|
||||
doneParsing = PR_TRUE;
|
||||
}
|
||||
|
||||
timeZoneSign[0] = strValue[run];
|
||||
|
||||
bufferRun = 0;
|
||||
} else if (strValue[run] == '.') {
|
||||
// fractional seconds
|
||||
parseState = 3;
|
||||
|
||||
if (strlen(second) != 2)
|
||||
doneParsing = PR_TRUE;
|
||||
|
||||
bufferRun = 0;
|
||||
|
||||
} else {
|
||||
if (bufferRun > 1)
|
||||
doneParsing = PR_TRUE;
|
||||
else {
|
||||
second[bufferRun] = strValue[run];
|
||||
bufferRun++;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 3: {
|
||||
// fraction seconds
|
||||
if ((strValue[run] == 'Z') || (strValue[run] == '-') || (strValue[run] == '+')) {
|
||||
// finished
|
||||
parseState = 4;
|
||||
|
||||
if (!IsStringANumber(fraction_seconds)) {
|
||||
doneParsing = PR_TRUE;
|
||||
} else if (strValue[run] == 'Z') {
|
||||
if (strValue[run+1] == '\0')
|
||||
isValid = PR_TRUE;
|
||||
|
||||
doneParsing = PR_TRUE;
|
||||
}
|
||||
|
||||
timeZoneSign[0] = strValue[run];
|
||||
|
||||
bufferRun = 0;
|
||||
} else {
|
||||
if (bufferRun >= sizeof(fraction_seconds)) {
|
||||
// more fraction seconds than the variable can store
|
||||
// so stop parseing
|
||||
doneParsing = PR_TRUE;
|
||||
} else {
|
||||
fraction_seconds[bufferRun] = strValue[run];
|
||||
bufferRun++;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 4: {
|
||||
// validate timezone
|
||||
char timezone[6] = "";
|
||||
int tzLength = strlen(strValue) - run;
|
||||
|
||||
// timezone is hh:mm
|
||||
if (tzLength == 5) {
|
||||
strncat(timezone, &strValue[run], tzLength);
|
||||
timezone[sizeof(timezone)-1] = '\0';
|
||||
isValid = ParseSchemaTimeZone(timezone, timezoneHour, timezoneMinute);
|
||||
}
|
||||
doneParsing = PR_TRUE;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
run++;
|
||||
}
|
||||
|
||||
if (isValid) {
|
||||
// 10:59:12.82
|
||||
// use a dummy year to make nspr do the work for us
|
||||
|
||||
sprintf(fulldate, "1-1-90 %s:%s:%s%s",
|
||||
hour,
|
||||
minute,
|
||||
second,
|
||||
timeZoneSign);
|
||||
|
||||
if (timeZoneSign[0] != 'Z') {
|
||||
strcat(fulldate, timezoneHour);
|
||||
strcat(fulldate, ":");
|
||||
strcat(fulldate, timezoneMinute);
|
||||
}
|
||||
fulldate[sizeof(fulldate)-1] = '\0';
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("\n new time is %s", fulldate);
|
||||
#endif
|
||||
|
||||
PRStatus foo = PR_ParseTimeString(fulldate,
|
||||
PR_TRUE, &dateTime);
|
||||
if (foo == -1) {
|
||||
isValid = PR_FALSE;
|
||||
} else {
|
||||
|
||||
PRExplodedTime explodedDateTime;
|
||||
PR_ExplodeTime(dateTime, PR_GMTParameters, &explodedDateTime);
|
||||
|
||||
sprintf(rv_hour, "%d", explodedDateTime.tm_hour);
|
||||
sprintf(rv_minute, "%d", explodedDateTime.tm_min);
|
||||
strcpy(rv_second, second);
|
||||
strcpy(rv_fraction_second, fraction_seconds);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("\n Time is %s \n", ((isValid) ? "Valid" : "Not Valid"));
|
||||
#endif
|
||||
|
||||
return isValid;
|
||||
}
|
||||
|
||||
PRBool nsSchemaValidatorUtils::ParseSchemaTimeZone(const char * strValue,
|
||||
char *rv_tzhour, char *rv_tzminute)
|
||||
{
|
||||
PRBool isValid = PR_FALSE;
|
||||
|
||||
int run = 0;
|
||||
int bufferRun = 0;
|
||||
int length = strlen(strValue);
|
||||
|
||||
PRBool doneParsing = PR_FALSE;
|
||||
|
||||
int parseState = 0;
|
||||
char timezoneHour[3] = "";
|
||||
char timezoneMinute[3] = "";
|
||||
|
||||
char fulldate[100] = "";
|
||||
|
||||
// overflow check
|
||||
if (strlen(fulldate) >= strlen(strValue))
|
||||
return PR_FALSE;
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("\n Validating TimeZone");
|
||||
#endif
|
||||
|
||||
while ( (run <= length) && (!doneParsing) ) {
|
||||
switch (parseState) {
|
||||
|
||||
case 0: {
|
||||
// timezone hh
|
||||
if (strValue[run] == ':') {
|
||||
parseState = 1;
|
||||
|
||||
if ((strlen(timezoneHour) != 2) || (strcmp(timezoneHour, "24") == 1))
|
||||
doneParsing = PR_TRUE;
|
||||
|
||||
bufferRun = 0;
|
||||
} else {
|
||||
if ((bufferRun > 1) || (strValue[run] > '9') || (strValue[run] < '0')){
|
||||
doneParsing = PR_TRUE;
|
||||
} else {
|
||||
timezoneHour[bufferRun] = strValue[run];
|
||||
bufferRun++;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 1: {
|
||||
// timezone mm
|
||||
if (strValue[run] == '\0') {
|
||||
if ((strlen(timezoneMinute) == 2) || (strcmp(timezoneMinute, "59") == 1))
|
||||
isValid = PR_TRUE;
|
||||
} else {
|
||||
if ((bufferRun > 1) || (strValue[run] > '9') || (strValue[run] < '0'))
|
||||
doneParsing = PR_TRUE;
|
||||
else {
|
||||
timezoneMinute[bufferRun] = strValue[run];
|
||||
bufferRun++;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
run++;
|
||||
}
|
||||
|
||||
if (isValid) {
|
||||
timezoneHour[2] = '\0';
|
||||
timezoneMinute[2] = '\0';
|
||||
strncpy(rv_tzhour, timezoneHour, 3);
|
||||
strncpy(rv_tzminute, timezoneMinute, 3);
|
||||
}
|
||||
|
||||
return isValid;
|
||||
}
|
||||
|
||||
/*
|
||||
-1 - aDateTime1 < aDateTime2
|
||||
0 - equal
|
||||
1 - aDateTime1 > aDateTime2
|
||||
*/
|
||||
int nsSchemaValidatorUtils::CompareExplodedDateTime(PRExplodedTime aDateTime1,
|
||||
PRBool aDateTime1IsNegative, PRExplodedTime aDateTime2, PRBool aDateTime2IsNegative)
|
||||
{
|
||||
int result;
|
||||
|
||||
if (!aDateTime1IsNegative && aDateTime2IsNegative) {
|
||||
// positive year is always bigger than negative year
|
||||
result = 1;
|
||||
} else if (aDateTime1IsNegative && !aDateTime2IsNegative) {
|
||||
result = -1;
|
||||
} else {
|
||||
result = CompareExplodedDate(aDateTime1, aDateTime2);
|
||||
|
||||
if (result == 0)
|
||||
result = CompareExplodedTime(aDateTime1, aDateTime2);
|
||||
|
||||
if (aDateTime1IsNegative && aDateTime2IsNegative) {
|
||||
// -20 is smaller than -21
|
||||
if (result == -1)
|
||||
result = 1;
|
||||
else if (result == 1)
|
||||
result = -1;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
-1 - aDateTime1 < aDateTime2
|
||||
0 - equal
|
||||
1 - aDateTime1 > aDateTime2
|
||||
*/
|
||||
int nsSchemaValidatorUtils::CompareExplodedDate(PRExplodedTime aDateTime1,
|
||||
PRExplodedTime aDateTime2)
|
||||
{
|
||||
int result;
|
||||
if (aDateTime1.tm_year < aDateTime2.tm_year) {
|
||||
result = -1;
|
||||
} else if (aDateTime1.tm_year > aDateTime2.tm_year) {
|
||||
result = 1;
|
||||
} else {
|
||||
if (aDateTime1.tm_month < aDateTime2.tm_month) {
|
||||
result = -1;
|
||||
} else if (aDateTime1.tm_month > aDateTime2.tm_month) {
|
||||
result = 1;
|
||||
} else {
|
||||
if (aDateTime1.tm_mday < aDateTime2.tm_mday) {
|
||||
result = -1;
|
||||
} else if (aDateTime1.tm_mday > aDateTime2.tm_mday) {
|
||||
result = 1;
|
||||
} else {
|
||||
result = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
-1 - aDateTime1 < aDateTime2
|
||||
0 - equal
|
||||
1 - aDateTime1 > aDateTime2
|
||||
*/
|
||||
int nsSchemaValidatorUtils::CompareExplodedTime(PRExplodedTime aDateTime1,
|
||||
PRExplodedTime aDateTime2)
|
||||
{
|
||||
int result;
|
||||
|
||||
if (aDateTime1.tm_hour < aDateTime2.tm_hour) {
|
||||
result = -1;
|
||||
} else if (aDateTime1.tm_hour > aDateTime2.tm_hour) {
|
||||
result = 1;
|
||||
} else {
|
||||
if (aDateTime1.tm_min < aDateTime2.tm_min) {
|
||||
result = -1;
|
||||
} else if (aDateTime1.tm_min > aDateTime2.tm_min) {
|
||||
result = 1;
|
||||
} else {
|
||||
if (aDateTime1.tm_sec < aDateTime2.tm_sec) {
|
||||
result = -1;
|
||||
} else if (aDateTime1.tm_sec > aDateTime2.tm_sec) {
|
||||
result = 1;
|
||||
} else {
|
||||
if (aDateTime1.tm_usec < aDateTime2.tm_usec) {
|
||||
result = -1;
|
||||
} else if (aDateTime1.tm_usec > aDateTime2.tm_usec) {
|
||||
result = 1;
|
||||
} else {
|
||||
result = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void nsSchemaValidatorUtils::GetMonthShorthand(char* aMonth, nsACString & aReturn)
|
||||
{
|
||||
if (strcmp(aMonth, "01") == 0)
|
||||
aReturn.AssignLiteral("Jan");
|
||||
else if (strcmp(aMonth, "02") == 0)
|
||||
aReturn.AssignLiteral("Feb");
|
||||
else if (strcmp(aMonth, "03") == 0)
|
||||
aReturn.AssignLiteral("Mar");
|
||||
else if (strcmp(aMonth, "04") == 0)
|
||||
aReturn.AssignLiteral("Apr");
|
||||
else if (strcmp(aMonth, "05") == 0)
|
||||
aReturn.AssignLiteral("May");
|
||||
else if (strcmp(aMonth, "06") == 0)
|
||||
aReturn.AssignLiteral("Jun");
|
||||
else if (strcmp(aMonth, "07") == 0)
|
||||
aReturn.AssignLiteral("Jul");
|
||||
else if (strcmp(aMonth, "08") == 0)
|
||||
aReturn.AssignLiteral("Aug");
|
||||
else if (strcmp(aMonth, "09") == 0)
|
||||
aReturn.AssignLiteral("Sep");
|
||||
else if (strcmp(aMonth, "10") == 0)
|
||||
aReturn.AssignLiteral("Oct");
|
||||
else if (strcmp(aMonth, "11") == 0)
|
||||
aReturn.AssignLiteral("Nov");
|
||||
else if (strcmp(aMonth, "12") == 0)
|
||||
aReturn.AssignLiteral("Dec");
|
||||
}
|
||||
|
||||
PRBool nsSchemaValidatorUtils::IsStringANumber(char* aChar)
|
||||
{
|
||||
char * pEnd;
|
||||
long intValue = strtol(aChar, &pEnd, 10);
|
||||
|
||||
return (*pEnd == '\0');
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
-1 - aYearMonth1 < aYearMonth2
|
||||
0 - equal
|
||||
1 - aYearMonth1 > aYearMonth2
|
||||
*/
|
||||
int nsSchemaValidatorUtils::CompareGYearMonth(Schema_GYearMonth aYearMonth1,
|
||||
Schema_GYearMonth aYearMonth2)
|
||||
{
|
||||
int rv;
|
||||
|
||||
if (aYearMonth1.gYear.year > aYearMonth2.gYear.year) {
|
||||
rv = 1;
|
||||
} else if (aYearMonth1.gYear.year < aYearMonth2.gYear.year) {
|
||||
rv = -1;
|
||||
} else {
|
||||
// both have the same year
|
||||
if (aYearMonth1.gMonth.month > aYearMonth2.gMonth.month)
|
||||
rv = 1;
|
||||
else if (aYearMonth1.gMonth.month < aYearMonth2.gMonth.month)
|
||||
rv = -1;
|
||||
else
|
||||
rv = 0;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
/*
|
||||
-1 - aMonthDay1 < aMonthDay2
|
||||
0 - equal
|
||||
1 - aMonthDay1 > aMonthDay2
|
||||
*/
|
||||
int nsSchemaValidatorUtils::CompareGMonthDay(Schema_GMonthDay aMonthDay1,
|
||||
Schema_GMonthDay aMonthDay2)
|
||||
{
|
||||
int rv;
|
||||
|
||||
if (aMonthDay1.gMonth.month > aMonthDay2.gMonth.month) {
|
||||
rv = 1;
|
||||
} else if (aMonthDay1.gMonth.month < aMonthDay2.gMonth.month) {
|
||||
rv = -1;
|
||||
} else {
|
||||
// both have the same year
|
||||
if (aMonthDay1.gDay.day > aMonthDay2.gDay.day)
|
||||
rv = 1;
|
||||
else if (aMonthDay1.gDay.day < aMonthDay2.gDay.day)
|
||||
rv = -1;
|
||||
else
|
||||
rv = 0;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
void nsSchemaValidatorUtils::RemoveLeadingZeros(nsAString & aString)
|
||||
{
|
||||
nsAString::const_iterator start, end;
|
||||
aString.BeginReading(start);
|
||||
aString.EndReading(end);
|
||||
|
||||
PRBool done = PR_FALSE;
|
||||
PRUint32 count = 0;
|
||||
|
||||
while ((start != end) && !done)
|
||||
{
|
||||
if (*start++ == '0') {
|
||||
++count;
|
||||
} else {
|
||||
done = PR_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
// finally, remove the leading zeros
|
||||
aString.Cut(0, count);
|
||||
}
|
||||
|
|
@ -0,0 +1,75 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Schema Validation.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* IBM Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2004
|
||||
* IBM Corporation. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Doron Rosenberg <doronr@us.ibm.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsSchemaValidator.h"
|
||||
|
||||
class nsSchemaValidatorUtils
|
||||
{
|
||||
public:
|
||||
static PRBool IsValidSchemaInteger(const nsAString & aNodeValue, long *aResult);
|
||||
static PRBool IsValidSchemaInteger(char* aString, long *aResult);
|
||||
|
||||
static PRBool ParseSchemaDate(const char * strValue,
|
||||
char *rv_year, char *rv_month, char *rv_day);
|
||||
static PRBool ParseSchemaTime(const char * strValue,
|
||||
char *rv_hour, char *rv_minute, char *rv_second, char *rv_fraction_second);
|
||||
static PRBool ParseSchemaTimeZone(const char * strValue,
|
||||
char *rv_tzhour, char *rv_tzminute);
|
||||
|
||||
static void GetMonthShorthand(char* aMonth, nsACString & aReturn);
|
||||
|
||||
static int CompareExplodedDateTime(PRExplodedTime aDateTime1, PRBool aDateTime1IsNegative,
|
||||
PRExplodedTime aDateTime2, PRBool aDateTime2IsNegative);
|
||||
static int CompareExplodedDate(PRExplodedTime aDateTime1, PRExplodedTime aDateTime2);
|
||||
static int CompareExplodedTime(PRExplodedTime aDateTime1, PRExplodedTime aDateTime2);
|
||||
|
||||
static PRBool IsStringANumber(char* aString);
|
||||
|
||||
static int CompareGYearMonth(Schema_GYearMonth aYearMonth1, Schema_GYearMonth aYearMonth2);
|
||||
static int CompareGMonthDay(Schema_GMonthDay aMonthDay1, Schema_GMonthDay aMonthDay2);
|
||||
|
||||
static void RemoveLeadingZeros(nsAString & aString);
|
||||
|
||||
private:
|
||||
nsSchemaValidatorUtils();
|
||||
~nsSchemaValidatorUtils();
|
||||
|
||||
protected:
|
||||
|
||||
};
|
||||
|
|
@ -0,0 +1,476 @@
|
|||
<!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, aIsValid) {
|
||||
var rv = false;
|
||||
|
||||
var x = dp.parseFromString('<test xmlns="http://www.mozilla.org/schema/test" xmlns:xsi="http://www.w3.org/1999/XMLSchema" xsi:type="' + 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 validate(aNodeValue, aType, aIsValid){
|
||||
validateString(aNodeValue, aType, aIsValid);
|
||||
}
|
||||
|
||||
function validateComplexType(aNodeValue, aType, aIsValid){
|
||||
var rv = false;
|
||||
|
||||
var x = dp.parseFromString(aNodeValue, "text/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"].getService(Components.interfaces.nsISchemaValidator);
|
||||
|
||||
}catch(e){ alert(e) }
|
||||
|
||||
var schemaLoader = Components.classes["@mozilla.org/xmlextras/schemas/schemaloader;1"]
|
||||
.getService(Components.interfaces.nsISchemaLoader);
|
||||
try {
|
||||
schema = schemaLoader.load("file:///home/doron/mozbuilds/trunk/mozilla/extensions/schema-validation/tests/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();
|
||||
|
||||
/* validateComplexType('<balance xsi:type="balance" xmlns="http://www.mozilla.org/schema/test" xmlns:xsi="http://www.w3.org/1999/XMLSchema"><transaction><date/><desc/><withdraw/><amount/></transaction></balance>', "balance", true);
|
||||
validateComplexType('<balance xsi:type="balance" xmlns="http://www.mozilla.org/schema/test" xmlns:xsi="http://www.w3.org/1999/XMLSchema"><transaction><date/><desc2/><withdraw/><amount/></transaction></balance>', "balance", false);
|
||||
validateComplexType('<balance xsi:type="balance" xmlns="http://www.mozilla.org/schema/test" xmlns:xsi="http://www.w3.org/1999/XMLSchema"><transaction><date/><desc/></transaction></balance>', "balance", false);
|
||||
validateComplexType('<balance xsi:type="balance" xmlns="http://www.mozilla.org/schema/test" xmlns:xsi="http://www.w3.org/1999/XMLSchema"><transaction><date/><desc/><withdraw/><amount/><date/></transaction></balance>', "balance", false);
|
||||
*/
|
||||
|
||||
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("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("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("220.343434", "decimal-test-1", true);
|
||||
validate("220.3434a34", "decimal-test-1", false);
|
||||
validate("220.343.34", "decimal-test-1", false);
|
||||
|
||||
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("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("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", true);
|
||||
|
||||
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("--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-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("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-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("2001-01-18", "date-test-1", true);
|
||||
validate("2001-0a-18", "date-test-1", false);
|
||||
validate("2001-01-36", "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("bar..com", "anyuri-test-1", false);
|
||||
|
||||
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("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("P200Y30M23DT21H456M3234S", "duration-test-1", true);
|
||||
validate("P200Y30MT21H32.3a4S", "duration-test-1", false);
|
||||
validate("P200Y-20M", "duration-test-1", false);*/
|
||||
}
|
||||
|
||||
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>
|
|
@ -0,0 +1,316 @@
|
|||
<?xml version="1.0" ?>
|
||||
<schema targetNamespace="http://www.mozilla.org/schema/test"
|
||||
xmlns="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
||||
<import namespace="http://schemas.xmlsoap.org/soap/encoding/" />
|
||||
|
||||
<element name="balance">
|
||||
<complexType>
|
||||
<sequence minOccurs="0" maxOccurs="unbounded">
|
||||
<element name="transaction">
|
||||
<complexType>
|
||||
<sequence>
|
||||
<element name="date" type="date"/>
|
||||
<element name="desc" type="string"/>
|
||||
<element name="withdraw" type="boolean"/>
|
||||
<element name="amount" type="decimal"/>
|
||||
</sequence>
|
||||
</complexType>
|
||||
</element>
|
||||
</sequence>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
<simpleType name="integer-test-1">
|
||||
<restriction base='integer'>
|
||||
<totalDigits value="3"/>
|
||||
<maxExclusive value="101"/>
|
||||
<minExclusive value="5"/>
|
||||
</restriction>
|
||||
</simpleType>
|
||||
|
||||
<simpleType name="integer-test-2">
|
||||
<restriction base='integer'>
|
||||
<totalDigits value="3"/>
|
||||
<maxInclusive value="2"/>
|
||||
<minInclusive value="-40"/>
|
||||
</restriction>
|
||||
</simpleType>
|
||||
|
||||
<simpleType name="test-nonPositiveInteger">
|
||||
<restriction base='nonPositiveInteger'>
|
||||
<totalDigits value="3"/>
|
||||
</restriction>
|
||||
</simpleType>
|
||||
|
||||
<simpleType name="byte-test-1">
|
||||
<restriction base='byte'>
|
||||
</restriction>
|
||||
</simpleType>
|
||||
|
||||
<simpleType name="byte-test-2">
|
||||
<restriction base='byte'>
|
||||
<totalDigits value="2"/>
|
||||
<maxExclusive value="40"/>
|
||||
<minExclusive value="-40"/>
|
||||
</restriction>
|
||||
</simpleType>
|
||||
|
||||
<simpleType name="byte-test-3">
|
||||
<restriction base='byte'>
|
||||
<maxInclusive value="40"/>
|
||||
<minInclusive value="-40"/>
|
||||
</restriction>
|
||||
</simpleType>
|
||||
|
||||
<simpleType name="float-test-1">
|
||||
<restriction base='float'>
|
||||
<maxExclusive value="3.34"/>
|
||||
<minExclusive value="0.98"/>
|
||||
</restriction>
|
||||
</simpleType>
|
||||
|
||||
<simpleType name="float-test-2">
|
||||
<restriction base='float'>
|
||||
<maxInclusive value="3.34"/>
|
||||
<minInclusive value="-1.98"/>
|
||||
</restriction>
|
||||
</simpleType>
|
||||
|
||||
<simpleType name="decimal-test-1">
|
||||
<restriction base='decimal'>
|
||||
</restriction>
|
||||
</simpleType>
|
||||
|
||||
<simpleType name="decimal-test-2">
|
||||
<restriction base='decimal'>
|
||||
<maxExclusive value="220.343435"/>
|
||||
<minExclusive value="100.34"/>
|
||||
</restriction>
|
||||
</simpleType>
|
||||
|
||||
|
||||
<simpleType name="decimal-test-3">
|
||||
<restriction base='decimal'>
|
||||
<maxInclusive value="220.343435"/>
|
||||
<minInclusive value="100.34"/>
|
||||
</restriction>
|
||||
</simpleType>
|
||||
|
||||
<simpleType name="string-test-1">
|
||||
<restriction base='string'>
|
||||
<length value="5"/>
|
||||
</restriction>
|
||||
</simpleType>
|
||||
|
||||
<simpleType name="string-test-2">
|
||||
<restriction base='string'>
|
||||
<minLength value="4"/>
|
||||
<maxLength value="17"/>
|
||||
</restriction>
|
||||
</simpleType>
|
||||
|
||||
<simpleType name="boolean-test-1">
|
||||
<restriction base='boolean'>
|
||||
</restriction>
|
||||
</simpleType>
|
||||
|
||||
<simpleType name="gday-test-1">
|
||||
<restriction base='gDay'>
|
||||
</restriction>
|
||||
</simpleType>
|
||||
|
||||
<simpleType name="gday-test-2">
|
||||
<restriction base='gDay'>
|
||||
<maxExclusive value="---21"/>
|
||||
<minExclusive value="---05"/>
|
||||
</restriction>
|
||||
</simpleType>
|
||||
|
||||
<simpleType name="gday-test-3">
|
||||
<restriction base='gDay'>
|
||||
<maxInclusive value="---21Z"/>
|
||||
<minInclusive value="---05"/>
|
||||
</restriction>
|
||||
</simpleType>
|
||||
|
||||
<simpleType name="gmonth-test-1">
|
||||
<restriction base='gMonth'>
|
||||
</restriction>
|
||||
</simpleType>
|
||||
|
||||
<simpleType name="gmonth-test-2">
|
||||
<restriction base='gMonth'>
|
||||
<maxExclusive value="--11--Z"/>
|
||||
<minExclusive value="--05--"/>
|
||||
</restriction>
|
||||
</simpleType>
|
||||
|
||||
<simpleType name="gmonth-test-3">
|
||||
<restriction base='gMonth'>
|
||||
<maxInclusive value="--11--"/>
|
||||
<minInclusive value="--05--"/>
|
||||
</restriction>
|
||||
</simpleType>
|
||||
|
||||
<simpleType name="gyear-test-1">
|
||||
<restriction base='gYear'>
|
||||
</restriction>
|
||||
</simpleType>
|
||||
|
||||
<simpleType name="gyear-test-2">
|
||||
<restriction base='gYear'>
|
||||
<maxInclusive value="10000"/>
|
||||
<minInclusive value="1900"/>
|
||||
</restriction>
|
||||
</simpleType>
|
||||
|
||||
<simpleType name="gyear-test-3">
|
||||
<restriction base='gYear'>
|
||||
<maxExclusive value="10000"/>
|
||||
<minExclusive value="1900"/>
|
||||
</restriction>
|
||||
</simpleType>
|
||||
|
||||
<simpleType name="gyearmonth-test-1">
|
||||
<restriction base='gYearMonth'>
|
||||
</restriction>
|
||||
</simpleType>
|
||||
|
||||
<simpleType name="gyearmonth-test-2">
|
||||
<restriction base='gYearMonth'>
|
||||
<maxExclusive value="10000-11Z"/>
|
||||
<minExclusive value="1990-01Z"/>
|
||||
</restriction>
|
||||
</simpleType>
|
||||
|
||||
<simpleType name="gyearmonth-test-3">
|
||||
<restriction base='gYearMonth'>
|
||||
<maxInclusive value="10000-11Z"/>
|
||||
<minInclusive value="1990-02Z"/>
|
||||
</restriction>
|
||||
</simpleType>
|
||||
|
||||
<simpleType name="gmonthday-test-1">
|
||||
<restriction base='gMonthDay'>
|
||||
</restriction>
|
||||
</simpleType>
|
||||
|
||||
<simpleType name="gmonthday-test-2">
|
||||
<restriction base='gMonthDay'>
|
||||
<maxExclusive value="--08-03Z"/>
|
||||
<minExclusive value="--02-21Z"/>
|
||||
</restriction>
|
||||
</simpleType>
|
||||
|
||||
<simpleType name="gmonthday-test-3">
|
||||
<restriction base='gMonthDay'>
|
||||
<maxInclusive value="--08-03Z"/>
|
||||
<minInclusive value="--02-21Z"/>
|
||||
</restriction>
|
||||
</simpleType>
|
||||
|
||||
<simpleType name="datetime-test-1">
|
||||
<restriction base='dateTime'>
|
||||
</restriction>
|
||||
</simpleType>
|
||||
|
||||
<simpleType name="datetime-test-2">
|
||||
<restriction base='dateTime'>
|
||||
<maxExclusive value="2004-02-18T12:21:03Z"/>
|
||||
<minExclusive value="2001-02-18T12:21:03Z"/>
|
||||
</restriction>
|
||||
</simpleType>
|
||||
|
||||
<simpleType name="datetime-test-3">
|
||||
<restriction base='dateTime'>
|
||||
<maxInclusive value="2004-02-18T12:21:03Z"/>
|
||||
<minInclusive value="2001-02-18T12:21:03Z"/>
|
||||
</restriction>
|
||||
</simpleType>
|
||||
|
||||
<simpleType name="date-test-1">
|
||||
<restriction base='date'>
|
||||
</restriction>
|
||||
</simpleType>
|
||||
|
||||
<simpleType name="date-test-2">
|
||||
<restriction base='date'>
|
||||
<maxExclusive value="2004-02-18"/>
|
||||
<minExclusive value="2001-02-18"/>
|
||||
</restriction>
|
||||
</simpleType>
|
||||
|
||||
<simpleType name="date-test-3">
|
||||
<restriction base='date'>
|
||||
<maxInclusive value="2004-02-18"/>
|
||||
<minInclusive value="2001-02-18"/>
|
||||
</restriction>
|
||||
</simpleType>
|
||||
|
||||
<simpleType name="time-test-1">
|
||||
<restriction base='time'>
|
||||
</restriction>
|
||||
</simpleType>
|
||||
|
||||
<simpleType name="time-test-2">
|
||||
<restriction base='time'>
|
||||
<minExclusive value="12:30:45"/>
|
||||
<maxExclusive value="22:30:45"/>
|
||||
</restriction>
|
||||
</simpleType>
|
||||
|
||||
<simpleType name="time-test-3">
|
||||
<restriction base='time'>
|
||||
<minInclusive value="12:30:45"/>
|
||||
<maxInclusive value="22:30:45"/>
|
||||
</restriction>
|
||||
</simpleType>
|
||||
|
||||
<simpleType name="duration-test-1">
|
||||
<restriction base='duration'>
|
||||
</restriction>
|
||||
</simpleType>
|
||||
|
||||
<simpleType name="anyuri-test-1">
|
||||
<restriction base='anyURI'>
|
||||
</restriction>
|
||||
</simpleType>
|
||||
|
||||
<simpleType name="anyuri-test-2">
|
||||
<restriction base='anyURI'>
|
||||
<maxLength value="50"/>
|
||||
<minLength value="17"/>
|
||||
</restriction>
|
||||
</simpleType>
|
||||
|
||||
<simpleType name="anyuri-test-3">
|
||||
<restriction base='anyURI'>
|
||||
<length value="17"/>
|
||||
</restriction>
|
||||
</simpleType>
|
||||
|
||||
<simpleType name="base64-test-1">
|
||||
<restriction base='base64Binary'>
|
||||
</restriction>
|
||||
</simpleType>
|
||||
|
||||
<simpleType name="base64-test-2">
|
||||
<restriction base='base64Binary'>
|
||||
<length value="14"/>
|
||||
</restriction>
|
||||
</simpleType>
|
||||
|
||||
<simpleType name="base64-test-3">
|
||||
<restriction base='base64Binary'>
|
||||
<maxLength value="14"/>
|
||||
<minLength value="3"/>
|
||||
</restriction>
|
||||
</simpleType>
|
||||
|
||||
<simpleType name='better-us-zipcode'>
|
||||
<restriction base='string'>
|
||||
<pattern value='[0-9]{5}(-[0-9]{4})?'/>
|
||||
</restriction>
|
||||
</simpleType>
|
||||
</schema>
|
|
@ -95,6 +95,7 @@
|
|||
#define NS_ERROR_MODULE_IPC 28
|
||||
#define NS_ERROR_MODULE_SVG 29
|
||||
#define NS_ERROR_MODULE_STORAGE 30
|
||||
#define NS_ERROR_MODULE_SCHEMA 31
|
||||
|
||||
/* NS_ERROR_MODULE_GENERAL should be used by modules that do not
|
||||
* care if return code values overlap. Callers of methods that
|
||||
|
|
Загрузка…
Ссылка в новой задаче