зеркало из https://github.com/mozilla/pjs.git
Bug 223097 - check in latest version of XML Schema Validation. rs=peterv, a=mkaply
This commit is contained in:
Родитель
2e344f1b9f
Коммит
72c6bbf898
|
@ -44,8 +44,9 @@ include $(DEPTH)/config/autoconf.mk
|
|||
|
||||
MODULE = schemavalidation
|
||||
|
||||
XPIDLSRCS = \
|
||||
nsISchemaValidator.idl \
|
||||
XPIDLSRCS = \
|
||||
nsISchemaValidator.idl \
|
||||
nsISchemaDuration.idl \
|
||||
nsISchemaValidatorRegexp.idl \
|
||||
$(NULL)
|
||||
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
/* ***** 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) 2005
|
||||
* the Initial Developer. 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 ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
[scriptable, uuid(85dad673-28ce-414d-b46b-5c3cf4fd18a6)]
|
||||
interface nsISchemaDuration : nsISupports {
|
||||
readonly attribute boolean negative;
|
||||
|
||||
PRUint32 getYears();
|
||||
PRUint32 getMonths();
|
||||
PRUint32 getDays();
|
||||
PRUint32 getHours();
|
||||
PRUint32 getMinutes();
|
||||
PRUint32 getSeconds();
|
||||
PRUint32 getFractionSeconds();
|
||||
};
|
|
@ -1,5 +1,42 @@
|
|||
/* ***** 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) 2005
|
||||
* the Initial Developer. 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 ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
#include "nsISchema.idl"
|
||||
#include "nsISchemaDuration.idl"
|
||||
#include "nsIDOMNode.idl"
|
||||
|
||||
[scriptable, uuid(eced2af3-fde9-4575-b5a4-e1c830b24611)]
|
||||
|
@ -7,5 +44,14 @@ interface nsISchemaValidator : nsISupports {
|
|||
void loadSchema(in nsISchema aSchema);
|
||||
boolean validate(in nsIDOMNode aElement);
|
||||
boolean validateString(in AString aValue, in AString aType, in AString aNamespace);
|
||||
boolean validateAgainstType(in nsIDOMNode aElement, in nsISchemaType aType);
|
||||
|
||||
nsISchemaType getType(in AString aType, in AString aNamespace);
|
||||
|
||||
// methods to validate and parse schema builtin types
|
||||
nsISchemaDuration validateBuiltinTypeDuration(in AString aValue);
|
||||
PRTime validateBuiltinTypeTime(in AString aValue);
|
||||
PRTime validateBuiltinTypeDate(in AString aValue);
|
||||
PRTime validateBuiltinTypeDateTime(in AString aValue);
|
||||
};
|
||||
|
||||
|
|
|
@ -1,3 +1,39 @@
|
|||
/* ***** 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) 2005
|
||||
* the Initial Developer. 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 ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
[scriptable, uuid(26d69f7e-f7cf-423d-afb9-43d8a9ebf3ba)]
|
||||
|
|
|
@ -61,6 +61,7 @@ REQUIRES = xpcom \
|
|||
unicharutil \
|
||||
content \
|
||||
js \
|
||||
htmlparser \
|
||||
necko \
|
||||
xmlextras \
|
||||
websrvcs \
|
||||
|
@ -69,6 +70,7 @@ REQUIRES = xpcom \
|
|||
CPPSRCS = \
|
||||
nsSchemaValidatorModule.cpp \
|
||||
nsSchemaValidator.cpp \
|
||||
nsSchemaDuration.cpp \
|
||||
nsSchemaValidatorUtils.cpp \
|
||||
$(NULL)
|
||||
|
||||
|
|
|
@ -0,0 +1,139 @@
|
|||
/* -*- 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) 2005
|
||||
* 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 "nsSchemaDuration.h"
|
||||
|
||||
// string includes
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsString.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
|
||||
// XPCOM includes
|
||||
#include "nsMemory.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIComponentManager.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include "prprf.h"
|
||||
#include "prtime.h"
|
||||
#include "plbase64.h"
|
||||
|
||||
NS_IMPL_ISUPPORTS1_CI(nsSchemaDuration, nsISchemaDuration)
|
||||
|
||||
nsSchemaDuration::nsSchemaDuration(PRUint32 aYears, PRUint32 aMonths,
|
||||
PRUint32 aDays, PRUint32 aHours,
|
||||
PRUint32 aMinutes, PRUint32 aSeconds,
|
||||
PRUint32 aFractionalSeconds, PRBool aNegative)
|
||||
{
|
||||
years = aYears;
|
||||
months = aMonths;
|
||||
days = aDays;
|
||||
hours = aHours;
|
||||
minutes = aMinutes;
|
||||
seconds = aSeconds;
|
||||
fractional_seconds = aFractionalSeconds;
|
||||
negative = aNegative;
|
||||
}
|
||||
|
||||
nsSchemaDuration::~nsSchemaDuration()
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
//
|
||||
// nsSchemaDuration implementation
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSchemaDuration::GetYears(PRUint32 *aResult)
|
||||
{
|
||||
*aResult = years;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSchemaDuration::GetMonths(PRUint32 *aResult)
|
||||
{
|
||||
*aResult = months;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSchemaDuration::GetDays(PRUint32 *aResult)
|
||||
{
|
||||
*aResult = days;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSchemaDuration::GetHours(PRUint32 *aResult)
|
||||
{
|
||||
*aResult = hours;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSchemaDuration::GetMinutes(PRUint32 *aResult)
|
||||
{
|
||||
*aResult = minutes;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSchemaDuration::GetSeconds(PRUint32 *aResult)
|
||||
{
|
||||
*aResult = seconds;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSchemaDuration::GetFractionSeconds(PRUint32 *aResult)
|
||||
{
|
||||
*aResult = fractional_seconds;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSchemaDuration::GetNegative(PRBool *aResult)
|
||||
{
|
||||
*aResult = negative;
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
@ -0,0 +1,80 @@
|
|||
/* -*- 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) 2005
|
||||
* 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 __nsSchemaDuration_h__
|
||||
#define __nsSchemaDuration_h__
|
||||
|
||||
#include "nsSchemaValidatorUtils.h"
|
||||
#include "nsISchemaDuration.h"
|
||||
#include "nsISchema.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
/* 85dad673-28ce-414d-b46b-5c3cf4fd18a6 */
|
||||
#define NS_SCHEMADURATION_CID \
|
||||
{ 0x85dad673, 0x28ce, 0x414d, \
|
||||
{0xb4, 0x6b, 0x5c, 0x3c, 0xf4, 0xfd, 0x18, 0xa6}}
|
||||
|
||||
#define NS_SCHEMADURATION_CONTRACTID "@mozilla.org/schemavalidator/schemaduration;1"
|
||||
|
||||
|
||||
class nsSchemaDuration : public nsISchemaDuration
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSISCHEMADURATION
|
||||
|
||||
nsSchemaDuration(PRUint32 aYears, PRUint32 aMonths, PRUint32 aDays,
|
||||
PRUint32 aHours, PRUint32 aMinutes, PRUint32 aSeconds,
|
||||
PRUint32 aFractionalSeconds, PRBool aNegative);
|
||||
private:
|
||||
~nsSchemaDuration();
|
||||
PRUint32 years;
|
||||
PRUint32 months;
|
||||
PRUint32 days;
|
||||
PRUint32 hours;
|
||||
PRUint32 minutes;
|
||||
PRUint32 seconds;
|
||||
PRUint32 fractional_seconds;
|
||||
|
||||
PRBool negative;
|
||||
|
||||
protected:
|
||||
|
||||
};
|
||||
|
||||
#endif // __nsSchemaDuration_h__
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -39,61 +39,11 @@
|
|||
#ifndef __nsSchemaValidator_h__
|
||||
#define __nsSchemaValidator_h__
|
||||
|
||||
#include "nsSchemaValidatorUtils.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;
|
||||
}
|
||||
} ;
|
||||
#include "nsCOMArray.h"
|
||||
|
||||
/* eced2af3-fde9-4575-b5a4-e1c830b24611 */
|
||||
#define NS_SCHEMAVALIDATOR_CID \
|
||||
|
@ -103,7 +53,7 @@
|
|||
#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_DOM_NODE_SPECIFIED 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)
|
||||
|
||||
|
@ -119,104 +69,192 @@ private:
|
|||
~nsSchemaValidator();
|
||||
|
||||
// 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);
|
||||
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);
|
||||
|
||||
nsresult ValidateListSimpletype(const nsAString & aNodeValue,
|
||||
nsISchemaSimpleType *aSchemaSimpleType,
|
||||
PRBool *aResult);
|
||||
|
||||
nsresult ValidateUnionSimpletype(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);
|
||||
PRUint32 aLength, PRBool aLengthDefined,
|
||||
PRUint32 aMinLength, PRBool aMinLengthDefined,
|
||||
PRUint32 aMaxLength, PRBool aMaxLengthDefined,
|
||||
nsStringArray *aEnumerationList,
|
||||
PRBool *aResult);
|
||||
|
||||
nsresult ValidateBuiltinTypeBoolean(const nsAString & aNodeValue,
|
||||
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);
|
||||
const nsAString & aMaxExclusive,
|
||||
const nsAString & aMinExclusive,
|
||||
const nsAString & aMaxInclusive,
|
||||
const nsAString & aMinInclusive,
|
||||
PRBool *aResult);
|
||||
PRBool IsValidSchemaGDay(const nsAString & aNodeValue, nsSchemaGDay *aResult);
|
||||
|
||||
PRBool IsValidSchemaGType(const nsAString & aNodeValue,
|
||||
long aMinValue, long aMaxValue, int *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);
|
||||
const nsAString & aMaxExclusive,
|
||||
const nsAString & aMinExclusive,
|
||||
const nsAString & aMaxInclusive,
|
||||
const nsAString & aMinInclusive,
|
||||
PRBool *aResult);
|
||||
PRBool IsValidSchemaGMonth(const nsAString & aNodeValue, nsSchemaGMonth *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);
|
||||
const nsAString & aMaxExclusive,
|
||||
const nsAString & aMinExclusive,
|
||||
const nsAString & aMaxInclusive,
|
||||
const nsAString & aMinInclusive,
|
||||
PRBool *aResult);
|
||||
PRBool IsValidSchemaGYear(const nsAString & aNodeValue, nsSchemaGYear *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);
|
||||
const nsAString & aMaxExclusive,
|
||||
const nsAString & aMinExclusive,
|
||||
const nsAString & aMaxInclusive,
|
||||
const nsAString & aMinInclusive,
|
||||
PRBool *aResult);
|
||||
PRBool IsValidSchemaGYearMonth(const nsAString & aNodeValue, nsSchemaGYearMonth *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);
|
||||
const nsAString & aMaxExclusive,
|
||||
const nsAString & aMinExclusive,
|
||||
const nsAString & aMaxInclusive,
|
||||
const nsAString & aMinInclusive,
|
||||
PRBool *aResult);
|
||||
PRBool IsValidSchemaGMonthDay(const nsAString & aNodeValue, nsSchemaGMonthDay *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);
|
||||
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);
|
||||
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);
|
||||
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 ValidateBuiltinTypeDuration(const nsAString & aNodeValue,
|
||||
const nsAString & aMaxExclusive,
|
||||
const nsAString & aMinExclusive,
|
||||
const nsAString & aMaxInclusive,
|
||||
const nsAString & aMinInclusive,
|
||||
PRBool *aResult);
|
||||
PRBool IsValidSchemaDuration(const nsAString & aNodeValue,
|
||||
nsISchemaDuration **aResult);
|
||||
|
||||
nsresult ValidateBuiltinTypeFloat(const nsAString & aNodeValue, PRUint32 aTotalDigits, const nsAString & aMaxExclusive, const nsAString & aMinExclusive,
|
||||
const nsAString & aMaxInclusive, const nsAString & aMinInclusive, PRBool *aResult);
|
||||
nsresult ValidateBuiltinTypeInteger(const nsAString & aNodeValue,
|
||||
PRUint32 aTotalDigits,
|
||||
const nsAString & aMaxExclusive,
|
||||
const nsAString & aMaxInclusive,
|
||||
const nsAString & aMinInclusive,
|
||||
const nsAString & aMinExclusive,
|
||||
nsStringArray *aEnumerationList,
|
||||
PRBool *aResult);
|
||||
|
||||
nsresult ValidateBuiltinTypeFloat(const nsAString & aNodeValue,
|
||||
PRUint32 aTotalDigits,
|
||||
const nsAString & aMaxExclusive,
|
||||
const nsAString & aMinExclusive,
|
||||
const nsAString & aMaxInclusive,
|
||||
const nsAString & aMinInclusive,
|
||||
nsStringArray *aEnumerationList,
|
||||
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);
|
||||
nsresult ValidateBuiltinTypeByte(const nsAString & aNodeValue,
|
||||
PRUint32 aTotalDigits,
|
||||
const nsAString & aMaxExclusive,
|
||||
const nsAString & aMaxInclusive,
|
||||
const nsAString & aMinInclusive,
|
||||
const nsAString & aMinExclusive,
|
||||
nsStringArray *aEnumerationList,
|
||||
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);
|
||||
nsresult ValidateBuiltinTypeDecimal(const nsAString & aNodeValue,
|
||||
PRUint32 aTotalDigits,
|
||||
PRUint32 aTotalFractionDigits,
|
||||
PRBool aFractionDigitsSet,
|
||||
const nsAString & aMaxExclusive,
|
||||
const nsAString & aMinExclusive,
|
||||
const nsAString & aMaxInclusive,
|
||||
const nsAString & aMinInclusive,
|
||||
nsStringArray *aEnumerationList,
|
||||
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);
|
||||
nsresult ValidateBuiltinTypeAnyURI(const nsAString & aNodeValue,
|
||||
PRUint32 aLength, PRUint32 aMinLength,
|
||||
PRUint32 aMaxLength,
|
||||
nsStringArray *aEnumerationList,
|
||||
PRBool *aResult);
|
||||
PRBool IsValidSchemaAnyURI(const nsAString & aString);
|
||||
|
||||
nsresult ValidateBuiltinTypeBase64Binary(const nsAString & aNodeValue,
|
||||
PRUint32 aLength, PRUint32 aMinLength, PRUint32 aMaxLength,
|
||||
PRBool *aResult);
|
||||
nsresult ValidateBuiltinTypeBase64Binary(const nsAString & aNodeValue,
|
||||
PRUint32 aLength,
|
||||
PRBool aLengthDefined,
|
||||
PRUint32 aMinLength,
|
||||
PRBool aMinLengthDefined,
|
||||
PRUint32 aMaxLength,
|
||||
PRBool aMaxLengthDefined,
|
||||
nsStringArray *aEnumerationList,
|
||||
PRBool *aResult);
|
||||
PRBool IsValidSchemaBase64Binary(const nsAString & aString, char** aDecodedString);
|
||||
|
||||
nsresult ValidateBuiltinTypeQName(const nsAString & aNodeValue,
|
||||
PRUint32 aLength,
|
||||
PRBool aLengthDefined,
|
||||
PRUint32 aMinLength,
|
||||
PRBool aMinLengthDefined,
|
||||
PRUint32 aMaxLength,
|
||||
PRBool aMaxLengthDefined,
|
||||
nsStringArray *aEnumerationList,
|
||||
PRBool *aResult);
|
||||
PRBool IsValidSchemaQName(const nsAString & aString);
|
||||
|
||||
|
||||
// helper methods
|
||||
void DumpBaseType(nsISchemaBuiltinType *aBuiltInType);
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsISchema> mSchema;
|
||||
nsCOMPtr<nsISchemaCollection> mSchema;
|
||||
};
|
||||
|
||||
#endif // __nsSchemaValidator_h__
|
||||
|
|
|
@ -38,15 +38,23 @@
|
|||
|
||||
#include "nsIGenericFactory.h"
|
||||
#include "nsSchemaValidator.h"
|
||||
#include "nsSchemaDuration.h"
|
||||
|
||||
NS_DECL_CLASSINFO(nsSchemaValidator)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSchemaValidator)
|
||||
|
||||
NS_DECL_CLASSINFO(nsSchemaDuration)
|
||||
|
||||
static const nsModuleComponentInfo components[] = {
|
||||
{ "SchemaValidator",
|
||||
NS_SCHEMAVALIDATOR_CID,
|
||||
NS_SCHEMAVALIDATOR_CONTRACTID,
|
||||
nsSchemaValidatorConstructor }
|
||||
nsSchemaValidatorConstructor },
|
||||
|
||||
{ "SchemaDuration",
|
||||
NS_SCHEMADURATION_CID,
|
||||
NS_SCHEMADURATION_CONTRACTID,
|
||||
nsnull }
|
||||
};
|
||||
|
||||
PR_STATIC_CALLBACK(nsresult)
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -36,40 +36,117 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsSchemaValidator.h"
|
||||
#ifndef __nsSchemaValidatorUtils_h__
|
||||
#define __nsSchemaValidatorUtils_h__
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsISchemaDuration.h"
|
||||
#include "nsCOMArray.h"
|
||||
|
||||
struct nsSchemaGDay {
|
||||
PRUint32 day; // day represented (1-31)
|
||||
PRBool tz_negative; // is timezone negative
|
||||
PRUint32 tz_hour; // timezone - hour (0-23) - null if not specified
|
||||
PRUint32 tz_minute; // timezone - minute (0-59) - null if not specified
|
||||
} ;
|
||||
|
||||
struct nsSchemaGMonth {
|
||||
PRUint32 month; // month represented (1-12)
|
||||
PRBool tz_negative; // is timezone negative
|
||||
PRUint32 tz_hour; // timezone - hour (0-23) - null if not specified
|
||||
PRUint32 tz_minute; // timezone - minute (0-59) - null if not specified
|
||||
} ;
|
||||
|
||||
struct nsSchemaGYear {
|
||||
long year; // year
|
||||
PRBool tz_negative; // is timezone negative
|
||||
PRUint32 tz_hour; // timezone - hour (0-23) - null if not specified
|
||||
PRUint32 tz_minute; // timezone - minute (0-59) - null if not specified
|
||||
} ;
|
||||
|
||||
struct nsSchemaGYearMonth {
|
||||
nsSchemaGYear gYear;
|
||||
nsSchemaGMonth gMonth;
|
||||
} ;
|
||||
|
||||
struct nsSchemaGMonthDay {
|
||||
nsSchemaGMonth gMonth;
|
||||
nsSchemaGDay gDay;
|
||||
} ;
|
||||
|
||||
struct nsMonthShortHand {
|
||||
const char *number;
|
||||
const char *shortHand;
|
||||
};
|
||||
|
||||
const nsMonthShortHand monthShortHand[] = {
|
||||
{ "01", "Jan" },
|
||||
{ "02", "Feb" },
|
||||
{ "03", "Mar" },
|
||||
{ "04", "Apr" },
|
||||
{ "05", "May" },
|
||||
{ "06", "Jun" },
|
||||
{ "07", "Jul" },
|
||||
{ "08", "Aug" },
|
||||
{ "09", "Sep" },
|
||||
{ "10", "Oct" },
|
||||
{ "11", "Nov" },
|
||||
{ "12", "Dec" }
|
||||
};
|
||||
|
||||
class nsSchemaValidatorUtils
|
||||
{
|
||||
public:
|
||||
static PRBool IsValidSchemaInteger(const nsAString & aNodeValue, long *aResult);
|
||||
static PRBool IsValidSchemaInteger(char* aString, long *aResult);
|
||||
static PRBool IsValidSchemaInteger(const 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 PRBool ParseSchemaDate(const nsAString & aStrValue, char *rv_year,
|
||||
char *rv_month, char *rv_day);
|
||||
static PRBool ParseSchemaTime(const nsAString & aStrValue, char *rv_hour,
|
||||
char *rv_minute, char *rv_second,
|
||||
char *rv_fraction_second);
|
||||
|
||||
static PRBool ParseSchemaTimeZone(const nsAString & aStrValue,
|
||||
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 PRBool GetPRTimeFromDateTime(const nsAString & aNodeValue, PRTime *aResult);
|
||||
|
||||
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(nsSchemaGYearMonth aYearMonth1, nsSchemaGYearMonth aYearMonth2);
|
||||
static int CompareGMonthDay(nsSchemaGMonthDay aMonthDay1, nsSchemaGMonthDay aMonthDay2);
|
||||
|
||||
static int CompareGYearMonth(Schema_GYearMonth aYearMonth1, Schema_GYearMonth aYearMonth2);
|
||||
static int CompareGMonthDay(Schema_GMonthDay aMonthDay1, Schema_GMonthDay aMonthDay2);
|
||||
static PRBool ParseSchemaDuration(const char * aStrValue,
|
||||
nsISchemaDuration **aDuration);
|
||||
static PRBool ParseSchemaDuration(const nsAString & aStrValue,
|
||||
nsISchemaDuration **aDuration);
|
||||
|
||||
static int CompareStrings(const nsAString & aString1, const nsAString & aString2);
|
||||
|
||||
static int GetMaximumDayInMonthFor(int aYearValue, int aMonthValue);
|
||||
static int CompareDurations(nsISchemaDuration *aDuration1,
|
||||
nsISchemaDuration *aDuration2);
|
||||
static PRExplodedTime AddDurationToDatetime(PRExplodedTime aDatetime,
|
||||
nsISchemaDuration *aDuration);
|
||||
|
||||
static PRBool HandleEnumeration(const nsAString &aStrValue,
|
||||
const nsStringArray &aEnumerationList);
|
||||
|
||||
static void RemoveLeadingZeros(nsAString & aString);
|
||||
static void RemoveTrailingZeros(nsAString & aString);
|
||||
|
||||
private:
|
||||
nsSchemaValidatorUtils();
|
||||
~nsSchemaValidatorUtils();
|
||||
|
||||
protected:
|
||||
|
||||
};
|
||||
|
||||
#endif // __nsSchemaValidatorUtils_h__
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<!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>
|
||||
|
@ -26,10 +26,11 @@
|
|||
return myValidator;
|
||||
}
|
||||
|
||||
function validateDOMNode(aNodeValue, aType, aIsValid) {
|
||||
function validateDOMNode(aNodeValue, aType, aNSPrefix, 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>', "application/xml");
|
||||
var x = dp.parseFromString('<test xmlns:test="http://www.mozilla.org/schema/test" xmlns="http://www.mozilla.org/schema/test" xmlns:xsi="http://www.w3.org/1999/XMLSchema" xsi:type="' + aNSPrefix + ":" + aType + '">' + aNodeValue + '</test>', "text/xml");
|
||||
|
||||
rv = getValidator().validate(x.documentElement);
|
||||
|
||||
counter++;
|
||||
|
@ -43,6 +44,13 @@
|
|||
results[results.length] = {type: aType, nodevalue: aNodeValue, rv: rv, isvalid: aIsValid};
|
||||
}
|
||||
|
||||
function validateSimpleTypeString(aNodeValue, aType, aIsValid) {
|
||||
var rv = getValidator().validateString(aNodeValue, aType, "http://www.w3.org/1999/XMLSchema");
|
||||
|
||||
counter++;
|
||||
results[results.length] = {type: aType, nodevalue: aNodeValue, rv: rv, isvalid: aIsValid};
|
||||
}
|
||||
|
||||
function validate(aNodeValue, aType, aIsValid){
|
||||
validateString(aNodeValue, aType, aIsValid);
|
||||
}
|
||||
|
@ -130,17 +138,22 @@
|
|||
|
||||
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);
|
||||
*/
|
||||
/*
|
||||
validate("true false 0 1", "list-test-1", true);
|
||||
validate("true false e 1", "list-test-1", false);
|
||||
|
||||
if (1){
|
||||
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);
|
||||
validate("-220", "integer-test-1", false);
|
||||
|
||||
|
||||
validate("5", "integer-test-1", false);
|
||||
validate("101", "integer-test-1", false);
|
||||
validate("1013", "integer-test-1", false);
|
||||
|
@ -213,6 +226,10 @@
|
|||
validate("110.34", "decimal-test-3", true);
|
||||
validate("100.345", "decimal-test-3", true);
|
||||
|
||||
validate("100.32", "decimal-test-4", true);
|
||||
validate("1002.32", "decimal-test-4", false);
|
||||
validate("100.322", "decimal-test-4", false);
|
||||
|
||||
validate("bla", "string-test-1", false);
|
||||
validate("blaadadad", "string-test-1", false);
|
||||
validate("bla22", "string-test-1", true);
|
||||
|
@ -221,13 +238,17 @@
|
|||
validate("bladftrhhkeptjg,gjklg", "string-test-2", false);
|
||||
validate("testingtesting", "string-test-2", true);
|
||||
|
||||
validate("test", "string-test-3", true);
|
||||
validate("test2", "string-test-3", true);
|
||||
validate("test3", "string-test-3", false);
|
||||
|
||||
validate("bla", "boolean-test-1", false);
|
||||
validate("11", "boolean-test-1", false);
|
||||
validate("1", "boolean-test-1", true);
|
||||
validate("0", "boolean-test-1", true);
|
||||
validate("true", "boolean-test-1", true);
|
||||
validate("false", "boolean-test-1", true);
|
||||
validate("TRue", "boolean-test-1", true);
|
||||
validate("TRue", "boolean-test-1", false );
|
||||
|
||||
validate("---30+23:20", "gday-test-1", true);
|
||||
validate("---30+2a:20", "gday-test-1", false);
|
||||
|
@ -281,6 +302,7 @@
|
|||
validate("0000Z", "gyear-test-1", false);
|
||||
validate("12a4-13:43", "gyear-test-1", false);
|
||||
validate("1214-1a:43", "gyear-test-1", false);
|
||||
validate("0", "gyear-test-1", false);
|
||||
|
||||
validate("1456", "gyear-test-2", false);
|
||||
validate("1900", "gyear-test-2", true);
|
||||
|
@ -293,7 +315,7 @@
|
|||
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);
|
||||
|
@ -431,7 +453,7 @@
|
|||
validate("58758", "better-us-zipcode", true);
|
||||
validate("a758", "better-us-zipcode", false);
|
||||
|
||||
/*validate("P200Y30M", "duration-test-1", true);
|
||||
validate("P200Y30M", "duration-test-1", true);
|
||||
validate("200Y30M", "duration-test-1", false);
|
||||
validate("P200Y30Ma", "duration-test-1", false);
|
||||
validate("P200Y30MD", "duration-test-1", false);
|
||||
|
@ -443,7 +465,28 @@
|
|||
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);*/
|
||||
validate("P200Y-20M", "duration-test-1", false);
|
||||
validate("P2147483647Y", "duration-test-1", true);
|
||||
validate("P2147583647Y", "duration-test-1", false);
|
||||
validate("P21475836433337Y", "duration-test-1", false);
|
||||
|
||||
validate("P150D", "duration-test-2", false);
|
||||
validate("P149D", "duration-test-2", true);
|
||||
validate("P28D", "duration-test-2", false);
|
||||
validate("P32D", "duration-test-2", true);
|
||||
validate("P27D", "duration-test-2", false);
|
||||
|
||||
validate("P150D", "duration-test-3", false);
|
||||
validate("P149D", "duration-test-3", true);
|
||||
validate("P28D", "duration-test-3", false);
|
||||
validate("P32D", "duration-test-3", true);
|
||||
validate("P27D", "duration-test-3", false);
|
||||
|
||||
|
||||
validate("test:foo", "qname-test-1", true);
|
||||
validate(":fooasdad", "qname-test-1", false);
|
||||
validate("n:s", "qname-test-1", true);
|
||||
validate("test:123456789", "qname-test-1", false);
|
||||
}
|
||||
|
||||
end = new Date();
|
||||
|
|
|
@ -1,26 +1,10 @@
|
|||
<?xml version="1.0" ?>
|
||||
<schema targetNamespace="http://www.mozilla.org/schema/test"
|
||||
xmlns="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns:test="http://www.mozilla.org/schema/test"
|
||||
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"/>
|
||||
|
@ -97,6 +81,13 @@
|
|||
</restriction>
|
||||
</simpleType>
|
||||
|
||||
<simpleType name="decimal-test-4">
|
||||
<restriction base='decimal'>
|
||||
<totalDigits value="3"/>
|
||||
<fractionDigits value="2"/>
|
||||
</restriction>
|
||||
</simpleType>
|
||||
|
||||
<simpleType name="string-test-1">
|
||||
<restriction base='string'>
|
||||
<length value="5"/>
|
||||
|
@ -110,6 +101,13 @@
|
|||
</restriction>
|
||||
</simpleType>
|
||||
|
||||
<simpleType name="string-test-3">
|
||||
<restriction base='string'>
|
||||
<enumeration value="test"/>
|
||||
<enumeration value="test2"/>
|
||||
</restriction>
|
||||
</simpleType>
|
||||
|
||||
<simpleType name="boolean-test-1">
|
||||
<restriction base='boolean'>
|
||||
</restriction>
|
||||
|
@ -272,6 +270,21 @@
|
|||
</restriction>
|
||||
</simpleType>
|
||||
|
||||
<simpleType name="duration-test-2">
|
||||
<restriction base='duration'>
|
||||
<maxExclusive value="P5M"/>
|
||||
<minExclusive value="P1M"/>
|
||||
</restriction>
|
||||
</simpleType>
|
||||
|
||||
<simpleType name="duration-test-3">
|
||||
<restriction base='duration'>
|
||||
<maxInclusive value="P5M"/>
|
||||
<minInclusive value="P1M"/>
|
||||
</restriction>
|
||||
</simpleType>
|
||||
|
||||
|
||||
<simpleType name="anyuri-test-1">
|
||||
<restriction base='anyURI'>
|
||||
</restriction>
|
||||
|
@ -308,9 +321,398 @@
|
|||
</restriction>
|
||||
</simpleType>
|
||||
|
||||
<simpleType name="qname-test-1">
|
||||
<restriction base='QName'>
|
||||
<maxLength value="13"/>
|
||||
<minLength value="3"/>
|
||||
</restriction>
|
||||
</simpleType>
|
||||
|
||||
<simpleType name='better-us-zipcode'>
|
||||
<restriction base='string'>
|
||||
<pattern value='[0-9]{5}(-[0-9]{4})?'/>
|
||||
</restriction>
|
||||
</simpleType>
|
||||
|
||||
|
||||
<simpleType name="list-test-1">
|
||||
<list itemType="boolean"/>
|
||||
</simpleType>
|
||||
|
||||
<simpleType name="list-test-2">
|
||||
<list>
|
||||
<simpleType>
|
||||
<restriction base="integer">
|
||||
<enumeration value="100" />
|
||||
<enumeration value="4" />
|
||||
<enumeration value="33" />
|
||||
</restriction>
|
||||
</simpleType>
|
||||
</list>
|
||||
</simpleType>
|
||||
|
||||
<simpleType name="union-test-1">
|
||||
<union>
|
||||
<simpleType>
|
||||
<restriction base="integer"/>
|
||||
</simpleType>
|
||||
<simpleType>
|
||||
<restriction base="string">
|
||||
<enumeration value="N/A"/>
|
||||
</restriction>
|
||||
</simpleType>
|
||||
</union>
|
||||
</simpleType>
|
||||
|
||||
<!-- complex types -->
|
||||
|
||||
<element name="transaction">
|
||||
<complexType>
|
||||
<sequence minOccurs="0">
|
||||
<element name="date" type="date"/>
|
||||
<element name="desc" type="string"/>
|
||||
<element name="withdraw" type="boolean"/>
|
||||
<element name="amount" type="decimal"/>
|
||||
</sequence>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
<element name="balance">
|
||||
<complexType>
|
||||
<sequence>
|
||||
<element ref="transaction" />
|
||||
</sequence>
|
||||
<attribute name="id" type="string"/>
|
||||
<attribute name="xsi:type" type="string"/>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
<element name="balance2">
|
||||
<complexType>
|
||||
<sequence>
|
||||
<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" minOccurs="0"/>
|
||||
</sequence>
|
||||
</complexType>
|
||||
</element>
|
||||
</sequence>
|
||||
<attribute name="id" type="string"/>
|
||||
<attribute name="xsi:type" type="string"/>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
<element name="balance3">
|
||||
<complexType>
|
||||
<sequence>
|
||||
<element name="transaction">
|
||||
<complexType>
|
||||
<sequence>
|
||||
<element name="date" type="date"/>
|
||||
<element name="desc" type="string" minOccurs="0"/>
|
||||
<element name="withdraw" type="boolean"/>
|
||||
<element name="amount" type="decimal" minOccurs="0"/>
|
||||
</sequence>
|
||||
</complexType>
|
||||
</element>
|
||||
</sequence>
|
||||
<attribute name="id" type="string"/>
|
||||
<attribute name="xsi:type" type="string"/>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
<element name="balance4">
|
||||
<complexType>
|
||||
<sequence>
|
||||
<element name="transaction">
|
||||
<complexType>
|
||||
<sequence minOccurs="0" maxOccurs="unbounded">
|
||||
<element name="date" type="date"/>
|
||||
<element name="desc" type="string" minOccurs="0"/>
|
||||
<element name="withdraw" type="boolean"/>
|
||||
<element name="amount" type="decimal" minOccurs="0"/>
|
||||
</sequence>
|
||||
</complexType>
|
||||
</element>
|
||||
</sequence>
|
||||
<attribute name="id" type="string"/>
|
||||
<attribute name="xsi:type" type="string"/>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
<element name="balance5">
|
||||
<complexType>
|
||||
<sequence>
|
||||
<element name="transaction">
|
||||
<complexType>
|
||||
<sequence minOccurs="2" maxOccurs="4">
|
||||
<element name="date" type="date"/>
|
||||
<element name="desc" type="string" minOccurs="0"/>
|
||||
<element name="withdraw" type="boolean"/>
|
||||
<element name="amount" type="decimal" minOccurs="0"/>
|
||||
</sequence>
|
||||
</complexType>
|
||||
</element>
|
||||
</sequence>
|
||||
<attribute name="id" type="string"/>
|
||||
<attribute name="xsi:type" type="string"/>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
<element name="balance6">
|
||||
<complexType>
|
||||
<sequence>
|
||||
<element name="transaction">
|
||||
<complexType>
|
||||
<sequence>
|
||||
<element name="date" type="date"/>
|
||||
<element name="amount" type="decimal" minOccurs="0"/>
|
||||
<element name="desc" type="string" minOccurs="0" maxOccurs="3"/>
|
||||
<element name="withdraw" type="boolean"/>
|
||||
<element name="amount" type="decimal" minOccurs="0"/>
|
||||
</sequence>
|
||||
</complexType>
|
||||
</element>
|
||||
</sequence>
|
||||
<attribute name="id" type="string"/>
|
||||
<attribute name="xsi:type" type="string"/>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
<attribute name="testAttr3" type="boolean" fixed="true"/>
|
||||
<attribute name="testAttr4" type="boolean"/>
|
||||
|
||||
<element name="balance7">
|
||||
<complexType>
|
||||
<sequence>
|
||||
<element name="transaction">
|
||||
<complexType>
|
||||
<sequence>
|
||||
<element name="date" type="date"/>
|
||||
<element name="desc" type="string" minOccurs="0"/>
|
||||
<element name="withdraw" type="boolean"/>
|
||||
<element name="amount" type="decimal" minOccurs="0"/>
|
||||
</sequence>
|
||||
<attribute name="testAttr" type="boolean" use="required"/>
|
||||
<attribute name="testAttr2" type="boolean" use="optional" fixed="true"/>
|
||||
<attribute ref="testAttr3" use="optional"/>
|
||||
<attribute ref="testAttr4" use="required"/>
|
||||
</complexType>
|
||||
</element>
|
||||
</sequence>
|
||||
<attribute name="id" type="string"/>
|
||||
<attribute name="xsi:type" type="string"/>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
<element name="balance8">
|
||||
<complexType>
|
||||
<sequence>
|
||||
<element name="transaction">
|
||||
<complexType>
|
||||
<sequence>
|
||||
<element name="date" type="date"/>
|
||||
<element name="desc" type="string" minOccurs="0"/>
|
||||
<element name="withdraw" type="boolean"/>
|
||||
<element name="amount" type="decimal" minOccurs="0"/>
|
||||
</sequence>
|
||||
</complexType>
|
||||
</element>
|
||||
<sequence minOccurs="0" maxOccurs="unbounded">
|
||||
<element name="name" type="string"/>
|
||||
<element name="lastname" type="string" minOccurs="0"/>
|
||||
</sequence>
|
||||
</sequence>
|
||||
<attribute name="id" type="string"/>
|
||||
<attribute name="xsi:type" type="string"/>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
<element name="balance9">
|
||||
<complexType>
|
||||
<sequence>
|
||||
<element name="transaction">
|
||||
<complexType>
|
||||
<sequence>
|
||||
<element name="date" type="date"/>
|
||||
<element name="desc" type="string" minOccurs="0"/>
|
||||
<element name="withdraw" type="boolean"/>
|
||||
<element name="amount" type="decimal" minOccurs="0"/>
|
||||
</sequence>
|
||||
</complexType>
|
||||
</element>
|
||||
<sequence minOccurs="0" maxOccurs="unbounded">
|
||||
<element name="name" type="string"/>
|
||||
<element name="lastname" type="string" minOccurs="0"/>
|
||||
</sequence>
|
||||
<sequence>
|
||||
<element name="test" type="string"/>
|
||||
<element name="test2" type="string" />
|
||||
</sequence>
|
||||
</sequence>
|
||||
<attribute name="id" type="string"/>
|
||||
<attribute name="xsi:type" type="string"/>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
<element name="balance10">
|
||||
<complexType>
|
||||
<sequence>
|
||||
<element name="transaction">
|
||||
<complexType>
|
||||
<sequence>
|
||||
<element name="date" type="date"/>
|
||||
<element name="desc" type="string" minOccurs="0"/>
|
||||
<element name="withdraw" type="boolean"/>
|
||||
<element name="amount" type="decimal" minOccurs="0"/>
|
||||
</sequence>
|
||||
</complexType>
|
||||
</element>
|
||||
<sequence minOccurs="0" maxOccurs="unbounded">
|
||||
<element name="name" type="string"/>
|
||||
<element name="lastname" type="string" minOccurs="0"/>
|
||||
</sequence>
|
||||
</sequence>
|
||||
<attribute name="id" type="string"/>
|
||||
<attribute name="xsi:type" type="string"/>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
<element name="balance11">
|
||||
<complexType>
|
||||
<sequence>
|
||||
<element name="transaction">
|
||||
<complexType>
|
||||
<sequence>
|
||||
<element name="date" type="date"/>
|
||||
<element name="desc" type="string" minOccurs="0"/>
|
||||
<element name="withdraw" type="boolean"/>
|
||||
<element name="amount" type="decimal" minOccurs="0"/>
|
||||
<element name="foopy">
|
||||
<complexType>
|
||||
<sequence minOccurs="2" maxOccurs="4">
|
||||
<element ref="balance9"/>
|
||||
</sequence>
|
||||
</complexType>
|
||||
</element>
|
||||
</sequence>
|
||||
</complexType>
|
||||
</element>
|
||||
</sequence>
|
||||
<attribute name="id" type="string"/>
|
||||
<attribute name="xsi:type" type="string"/>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
<element name="balance12">
|
||||
<complexType>
|
||||
<sequence>
|
||||
<element name="transaction">
|
||||
<complexType>
|
||||
<choice minOccurs="1" maxOccurs="3">
|
||||
<element name="amount2" type="decimal"/>
|
||||
<sequence>
|
||||
<element name="date" type="date"/>
|
||||
<element name="desc" type="string" minOccurs="0"/>
|
||||
<element name="withdraw" type="boolean"/>
|
||||
<element name="amount" type="decimal" minOccurs="0"/>
|
||||
</sequence>
|
||||
<element name="date2" type="date"/>
|
||||
</choice>
|
||||
</complexType>
|
||||
</element>
|
||||
</sequence>
|
||||
<attribute name="id" type="string"/>
|
||||
<attribute name="xsi:type" type="string"/>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
<!-- Chilled -->
|
||||
|
||||
<simpleType name="chilledDecimal">
|
||||
<restriction base="decimal">
|
||||
<totalDigits value="5"/>
|
||||
<fractionDigits value="2"/>
|
||||
<minInclusive value="0"/>
|
||||
</restriction>
|
||||
</simpleType>
|
||||
|
||||
<simpleType name="milk">
|
||||
<restriction base="string">
|
||||
<enumeration value="full-cream"/>
|
||||
<enumeration value="semi-skimmed"/>
|
||||
<enumeration value="skimmed"/>
|
||||
</restriction>
|
||||
</simpleType>
|
||||
|
||||
<simpleType name="butter">
|
||||
<restriction base="string">
|
||||
<enumeration value="salted"/>
|
||||
<enumeration value="non-salted"/>
|
||||
</restriction>
|
||||
</simpleType>
|
||||
|
||||
<element name="volume">
|
||||
<complexType>
|
||||
<simpleContent>
|
||||
<extension base="test:chilledDecimal">
|
||||
<attribute name="uom" fixed="litres" type="string"/>
|
||||
</extension>
|
||||
</simpleContent>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
<element name="weight">
|
||||
<complexType>
|
||||
<simpleContent>
|
||||
<extension base="test:chilledDecimal">
|
||||
<attribute name="uom" fixed="kg" type="string"/>
|
||||
</extension>
|
||||
</simpleContent>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
<element name="fridge">
|
||||
<complexType>
|
||||
<sequence>
|
||||
<element name="contents">
|
||||
<complexType>
|
||||
<sequence>
|
||||
<element name="dairyProduce" type="test:dairy_Produce" minOccurs="0"/>
|
||||
</sequence>
|
||||
</complexType>
|
||||
</element>
|
||||
</sequence>
|
||||
<attribute name="id" type="string"/>
|
||||
<attribute name="xsi:type" type="string"/>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
<complexType name="dairy_Produce">
|
||||
<sequence>
|
||||
<element name="milk" minOccurs="1" maxOccurs="unbounded">
|
||||
<complexType>
|
||||
<sequence>
|
||||
<element ref="volume"/>
|
||||
</sequence>
|
||||
<attribute name="type" type="test:milk"/>
|
||||
</complexType>
|
||||
</element>
|
||||
<element name="butter" minOccurs="0" maxOccurs="unbounded">
|
||||
<complexType>
|
||||
<sequence>
|
||||
<element ref="weight"/>
|
||||
</sequence>
|
||||
<attribute name="type" type="test:butter"/>
|
||||
</complexType>
|
||||
</element>
|
||||
</sequence>
|
||||
<attribute name="id" type="string"/>
|
||||
<attribute name="xsi:type" type="string"/>
|
||||
</complexType>
|
||||
|
||||
</schema>
|
||||
|
|
Загрузка…
Ссылка в новой задаче