diff --git a/Projects/OS2/VACPP40/xerces_util.icc b/Projects/OS2/VACPP40/xerces_util.icc index f3a71f85b9bab6abf5a9d169bc536e6b4244d42c..cd655bef6aa81a098a54924d3b22b6b73e653309 100644 --- a/Projects/OS2/VACPP40/xerces_util.icc +++ b/Projects/OS2/VACPP40/xerces_util.icc @@ -22,6 +22,7 @@ group xerces_util = BASE_DIR "\\src\\util\\XMLBigInteger.cpp", BASE_DIR "\\src\\util\\XMLChTranscoder.cpp", BASE_DIR "\\src\\util\\XMLDouble.cpp", + BASE_DIR "\\src\\util\\XMLDateTime.cpp", BASE_DIR "\\src\\util\\XMLEBCDICTranscoder.cpp", BASE_DIR "\\src\\util\\XMLException.cpp", BASE_DIR "\\src\\util\\XMLFloat.cpp", diff --git a/Projects/OS2/VACPP40/xerces_validators.icc b/Projects/OS2/VACPP40/xerces_validators.icc index d0470731450b9d9f7636fe65a0d2a924c11f9f06..a9f19a01844922343628a06d1cd602d39de56621 100644 --- a/Projects/OS2/VACPP40/xerces_validators.icc +++ b/Projects/OS2/VACPP40/xerces_validators.icc @@ -32,6 +32,16 @@ group xerces_validators = BASE_DIR "\\src\\validators\\datatype\\NCNameDatatypeValidator.cpp", BASE_DIR "\\src\\validators\\datatype\\StringDatatypeValidator.cpp", BASE_DIR "\\src\\validators\\datatype\\UnionDatatypeValidator.cpp", + BASE_DIR "\\src\\validators\\datatype\\DateTimeValidator.cpp", + BASE_DIR "\\src\\validators\\datatype\\DateTimeDatatypeValidator.cpp", + BASE_DIR "\\src\\validators\\datatype\\DateDatatypeValidator.cpp", + BASE_DIR "\\src\\validators\\datatype\\TimeDatatypeValidator.cpp", + BASE_DIR "\\src\\validators\\datatype\\DayDatatypeValidator.cpp", + BASE_DIR "\\src\\validators\\datatype\\MonthDatatypeValidator.cpp", + BASE_DIR "\\src\\validators\\datatype\\MonthDayDatatypeValidator.cpp", + BASE_DIR "\\src\\validators\\datatype\\YearDatatypeValidator.cpp", + BASE_DIR "\\src\\validators\\datatype\\YearMonthDatatypeValidator.cpp", + BASE_DIR "\\src\\validators\\datatype\\DurationDatatypeValidator.cpp", BASE_DIR "\\src\\validators\\DTD\\DTDAttDef.cpp", BASE_DIR "\\src\\validators\\DTD\\DTDAttDefList.cpp", BASE_DIR "\\src\\validators\\DTD\\DTDElementDecl.cpp", diff --git a/Projects/Win32/BCB5/Xerces-all/XercesLib/XercesLib.bpr b/Projects/Win32/BCB5/Xerces-all/XercesLib/XercesLib.bpr index b60eed0763b83a0dd42fd95702480f0826b14abd..40e9779d9f23e2195b7963118de7cc5a9776feca 100644 --- a/Projects/Win32/BCB5/Xerces-all/XercesLib/XercesLib.bpr +++ b/Projects/Win32/BCB5/Xerces-all/XercesLib/XercesLib.bpr @@ -146,6 +146,7 @@ ..\..\..\..\..\Build\Win32\BCB5\obj\XMLBigInteger.obj ..\..\..\..\..\Build\Win32\BCB5\obj\XMLChTranscoder.obj ..\..\..\..\..\Build\Win32\BCB5\obj\XMLDouble.obj + ..\..\..\..\..\Build\Win32\BCB5\obj\XMLDateTime.obj ..\..\..\..\..\Build\Win32\BCB5\obj\XMLEBCDICTranscoder.obj ..\..\..\..\..\Build\Win32\BCB5\obj\XMLException.obj ..\..\..\..\..\Build\Win32\BCB5\obj\XMLFloat.obj @@ -192,6 +193,16 @@ ..\..\..\..\..\Build\Win32\BCB5\obj\NCNameDatatypeValidator.obj ..\..\..\..\..\Build\Win32\BCB5\obj\StringDatatypeValidator.obj ..\..\..\..\..\Build\Win32\BCB5\obj\UnionDatatypeValidator.obj + ..\..\..\..\..\Build\Win32\BCB5\obj\DateTimeValidator.obj + ..\..\..\..\..\Build\Win32\BCB5\obj\DateTimeDatatypeValidator.obj + ..\..\..\..\..\Build\Win32\BCB5\obj\DateDatatypeValidator.obj + ..\..\..\..\..\Build\Win32\BCB5\obj\TimeDatatypeValidator.obj + ..\..\..\..\..\Build\Win32\BCB5\obj\DayDatatypeValidator.obj + ..\..\..\..\..\Build\Win32\BCB5\obj\MonthDatatypeValidator.obj + ..\..\..\..\..\Build\Win32\BCB5\obj\MonthDayDatatypeValidator.obj + ..\..\..\..\..\Build\Win32\BCB5\obj\YearDatatypeValidator.obj + ..\..\..\..\..\Build\Win32\BCB5\obj\YearMonthDatatypeValidator.obj + ..\..\..\..\..\Build\Win32\BCB5\obj\DurationDatatypeValidator.obj ..\..\..\..\..\Build\Win32\BCB5\obj\DTDAttDef.obj ..\..\..\..\..\Build\Win32\BCB5\obj\DTDAttDefList.obj ..\..\..\..\..\Build\Win32\BCB5\obj\DTDElementDecl.obj diff --git a/Projects/Win32/BCB5/Xerces-all/XercesLib/XercesLib.cpp b/Projects/Win32/BCB5/Xerces-all/XercesLib/XercesLib.cpp index 9e12254dfba719cc532fd1bb034ba7de488b53cf..356d70a2094cfee8ca1363c142d429395c100f3c 100644 --- a/Projects/Win32/BCB5/Xerces-all/XercesLib/XercesLib.cpp +++ b/Projects/Win32/BCB5/Xerces-all/XercesLib/XercesLib.cpp @@ -163,6 +163,7 @@ USEUNIT("..\..\..\..\..\src\util\XMLBigDecimal.cpp"); USEUNIT("..\..\..\..\..\src\util\XMLBigInteger.cpp"); USEUNIT("..\..\..\..\..\src\util\XMLChTranscoder.cpp"); USEUNIT("..\..\..\..\..\src\util\XMLDouble.cpp"); +USEUNIT("..\..\..\..\..\src\util\XMLDateTime.cpp"); USEUNIT("..\..\..\..\..\src\util\XMLEBCDICTranscoder.cpp"); USEUNIT("..\..\..\..\..\src\util\XMLException.cpp"); USEUNIT("..\..\..\..\..\src\util\XMLFloat.cpp"); @@ -209,6 +210,16 @@ USEUNIT("..\..\..\..\..\src\validators\datatype\NameDatatypeValidator.cpp"); USEUNIT("..\..\..\..\..\src\validators\datatype\NCNameDatatypeValidator.cpp"); USEUNIT("..\..\..\..\..\src\validators\datatype\StringDatatypeValidator.cpp"); USEUNIT("..\..\..\..\..\src\validators\datatype\UnionDatatypeValidator.cpp"); +USEUNIT("..\..\..\..\..\src\validators\datatype\DateTimeValidator.cpp"); +USEUNIT("..\..\..\..\..\src\validators\datatype\DateTimeDatatypeValidator.cpp"); +USEUNIT("..\..\..\..\..\src\validators\datatype\DateDatatypeValidator.cpp"); +USEUNIT("..\..\..\..\..\src\validators\datatype\TimeDatatypeValidator.cpp"); +USEUNIT("..\..\..\..\..\src\validators\datatype\DayDatatypeValidator.cpp"); +USEUNIT("..\..\..\..\..\src\validators\datatype\MonthDatatypeValidator.cpp"); +USEUNIT("..\..\..\..\..\src\validators\datatype\MonthDayDatatypeValidator.cpp"); +USEUNIT("..\..\..\..\..\src\validators\datatype\YearDatatypeValidator.cpp"); +USEUNIT("..\..\..\..\..\src\validators\datatype\YearMonthDatatypeValidator.cpp"); +USEUNIT("..\..\..\..\..\src\validators\datatype\DurationDatatypeValidator.cpp"); USEUNIT("..\..\..\..\..\src\validators\DTD\DTDAttDef.cpp"); USEUNIT("..\..\..\..\..\src\validators\DTD\DTDAttDefList.cpp"); USEUNIT("..\..\..\..\..\src\validators\DTD\DTDElementDecl.cpp"); diff --git a/Projects/Win32/BCB5/Xerces-all/XercesLib/XercesLib.mak b/Projects/Win32/BCB5/Xerces-all/XercesLib/XercesLib.mak index 0fb61342bdd228b9586e283d33753360dbb429ef..dd72a0b4bfddeca83199505ddaa615a8e90f6fc4 100644 --- a/Projects/Win32/BCB5/Xerces-all/XercesLib/XercesLib.mak +++ b/Projects/Win32/BCB5/Xerces-all/XercesLib/XercesLib.mak @@ -156,6 +156,7 @@ OBJFILES = ..\..\..\..\..\Build\Win32\BCB5\obj\XercesLib.obj \ ..\..\..\..\..\Build\Win32\BCB5\obj\XMLBigInteger.obj \ ..\..\..\..\..\Build\Win32\BCB5\obj\XMLChTranscoder.obj \ ..\..\..\..\..\Build\Win32\BCB5\obj\XMLDouble.obj \ + ..\..\..\..\..\Build\Win32\BCB5\obj\XMLDateTime.obj \ ..\..\..\..\..\Build\Win32\BCB5\obj\XMLEBCDICTranscoder.obj \ ..\..\..\..\..\Build\Win32\BCB5\obj\XMLException.obj \ ..\..\..\..\..\Build\Win32\BCB5\obj\XMLFloat.obj \ @@ -202,6 +203,16 @@ OBJFILES = ..\..\..\..\..\Build\Win32\BCB5\obj\XercesLib.obj \ ..\..\..\..\..\Build\Win32\BCB5\obj\NCNameDatatypeValidator.obj \ ..\..\..\..\..\Build\Win32\BCB5\obj\StringDatatypeValidator.obj \ ..\..\..\..\..\Build\Win32\BCB5\obj\UnionDatatypeValidator.obj \ + ..\..\..\..\..\Build\Win32\BCB5\obj\DateTimeValidator.obj \ + ..\..\..\..\..\Build\Win32\BCB5\obj\DateTimeDatatypeValidator.obj \ + ..\..\..\..\..\Build\Win32\BCB5\obj\DateDatatypeValidator.obj \ + ..\..\..\..\..\Build\Win32\BCB5\obj\TimeDatatypeValidator.obj \ + ..\..\..\..\..\Build\Win32\BCB5\obj\DayDatatypeValidator.obj \ + ..\..\..\..\..\Build\Win32\BCB5\obj\MonthDatatypeValidator.obj \ + ..\..\..\..\..\Build\Win32\BCB5\obj\MonthDayDatatypeValidator.obj \ + ..\..\..\..\..\Build\Win32\BCB5\obj\YearDatatypeValidator.obj \ + ..\..\..\..\..\Build\Win32\BCB5\obj\YearMonthDatatypeValidator.obj \ + ..\..\..\..\..\Build\Win32\BCB5\obj\DurationDatatypeValidator.obj \ ..\..\..\..\..\Build\Win32\BCB5\obj\DTDAttDef.obj \ ..\..\..\..\..\Build\Win32\BCB5\obj\DTDAttDefList.obj \ ..\..\..\..\..\Build\Win32\BCB5\obj\DTDElementDecl.obj \ diff --git a/Projects/Win32/VC6/xerces-all/XercesLib/XercesLib.dsp b/Projects/Win32/VC6/xerces-all/XercesLib/XercesLib.dsp index 52f31fac42cac55027687cdad557c3cf153eff6b..91f931fc9a7d792f91bc0088edd401d6c221542e 100644 --- a/Projects/Win32/VC6/xerces-all/XercesLib/XercesLib.dsp +++ b/Projects/Win32/VC6/xerces-all/XercesLib/XercesLib.dsp @@ -684,6 +684,14 @@ SOURCE=..\..\..\..\..\src\util\XMLChTranscoder.hpp # End Source File # Begin Source File +SOURCE=..\..\..\..\..\src\util\XMLDateTime.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\..\..\src\util\XMLDateTime.hpp +# End Source File +# Begin Source File + SOURCE=..\..\..\..\..\src\util\XMLDeleterFor.hpp # End Source File # Begin Source File @@ -1815,6 +1823,38 @@ SOURCE=..\..\..\..\..\src\validators\datatype\DatatypeValidatorFactory.hpp # End Source File # Begin Source File +SOURCE=..\..\..\..\..\src\validators\datatype\DateDatatypeValidator.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\..\..\src\validators\datatype\DateDatatypeValidator.hpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\..\..\src\validators\datatype\DateTimeDatatypeValidator.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\..\..\src\validators\datatype\DateTimeDatatypeValidator.hpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\..\..\src\validators\datatype\DateTimeValidator.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\..\..\src\validators\datatype\DateTimeValidator.hpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\..\..\src\validators\datatype\DayDatatypeValidator.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\..\..\src\validators\datatype\DayDatatypeValidator.hpp +# End Source File +# Begin Source File + SOURCE=..\..\..\..\..\src\validators\datatype\DecimalDatatypeValidator.cpp # End Source File # Begin Source File @@ -1831,6 +1871,14 @@ SOURCE=..\..\..\..\..\src\validators\datatype\DoubleDatatypeValidator.hpp # End Source File # Begin Source File +SOURCE=..\..\..\..\..\src\validators\datatype\DurationDatatypeValidator.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\..\..\src\validators\datatype\DurationDatatypeValidator.hpp +# End Source File +# Begin Source File + SOURCE=..\..\..\..\..\src\validators\datatype\ENTITYDatatypeValidator.cpp # End Source File # Begin Source File @@ -1887,6 +1935,22 @@ SOURCE=..\..\..\..\..\src\validators\datatype\ListDatatypeValidator.hpp # End Source File # Begin Source File +SOURCE=..\..\..\..\..\src\validators\datatype\MonthDatatypeValidator.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\..\..\src\validators\datatype\MonthDatatypeValidator.hpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\..\..\src\validators\datatype\MonthDayDatatypeValidator.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\..\..\src\validators\datatype\MonthDayDatatypeValidator.hpp +# End Source File +# Begin Source File + SOURCE=..\..\..\..\..\src\validators\datatype\NameDatatypeValidator.cpp # End Source File # Begin Source File @@ -1927,12 +1991,36 @@ SOURCE=..\..\..\..\..\src\validators\datatype\StringDatatypeValidator.hpp # End Source File # Begin Source File +SOURCE=..\..\..\..\..\src\validators\datatype\TimeDatatypeValidator.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\..\..\src\validators\datatype\TimeDatatypeValidator.hpp +# End Source File +# Begin Source File + SOURCE=..\..\..\..\..\src\validators\datatype\UnionDatatypeValidator.cpp # End Source File # Begin Source File SOURCE=..\..\..\..\..\src\validators\datatype\UnionDatatypeValidator.hpp # End Source File +# Begin Source File + +SOURCE=..\..\..\..\..\src\validators\datatype\YearDatatypeValidator.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\..\..\src\validators\datatype\YearDatatypeValidator.hpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\..\..\src\validators\datatype\YearMonthDatatypeValidator.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\..\..\src\validators\datatype\YearMonthDatatypeValidator.hpp +# End Source File # End Group # Begin Group "DTD" diff --git a/src/util/Makefile.in b/src/util/Makefile.in index 41b1a7d02fc4b23507d71c036e0ddf2d9bc71118..ac3e2840cd4396b7e4729aa892e0c717b4dba281 100644 --- a/src/util/Makefile.in +++ b/src/util/Makefile.in @@ -55,6 +55,9 @@ # # # $Log$ +# Revision 1.49 2001/11/07 19:16:03 peiyongz +# DateTime Port +# # Revision 1.48 2001/10/23 23:09:32 peiyongz # [Bug#880] patch to PlatformUtils:init()/term() and related. from Mark Weaver # @@ -363,6 +366,7 @@ UTIL_CPP_PUBHEADERS = \ XMLBigDecimal.hpp \ XMLBigInteger.hpp \ XMLDouble.hpp \ + XMLDateTime.hpp \ XMLChTranscoder.hpp \ XMLInteger.hpp \ XMLIBM1140Transcoder.hpp \ @@ -431,6 +435,7 @@ UTIL_CPP_OBJECTS = \ XMLBigDecimal.$(TO) \ XMLBigInteger.$(TO) \ XMLDouble.$(TO) \ + XMLDateTime.$(TO) \ XMLChTranscoder.$(TO) \ XMLIBM1140Transcoder.$(TO) \ XMLEBCDICTranscoder.$(TO) \ diff --git a/src/util/XMLDateTime.cpp b/src/util/XMLDateTime.cpp new file mode 100644 index 0000000000000000000000000000000000000000..1c360bffc894caff9e6356295b91df9c3dc141d3 --- /dev/null +++ b/src/util/XMLDateTime.cpp @@ -0,0 +1,1260 @@ +/* + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2001 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. + * + * 4. The names "Xerces" and "Apache Software Foundation" must + * not be used to endorse or promote products derived from this + * software without prior written permission. For written + * permission, please contact apache\@apache.org. + * + * 5. Products derived from this software may not be called "Apache", + * nor may "Apache" appear in their name, without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation, and was + * originally based on software copyright (c) 2001, International + * Business Machines, Inc., http://www.ibm.com . For more information + * on the Apache Software Foundation, please see + * <http://www.apache.org/>. + */ + +/* + * $Id$ + * $Log$ + * Revision 1.1 2001/11/07 19:16:03 peiyongz + * DateTime Port + * + * + */ + +// --------------------------------------------------------------------------- +// Includes +// --------------------------------------------------------------------------- +#include <stdlib.h> +#include <util/XMLDateTime.hpp> +#include <util/XMLString.hpp> +#include <util/XMLUni.hpp> +#include <util/Janitor.hpp> + +// +// constants used to process raw data (fBuffer) +// +// [-]{CCYY-MM-DD}'T'{HH:MM:SS.MS}['Z'] +// [{+|-}hh:mm'] +// + +static const XMLCh DURATION_STARTER = chLatin_P; // 'P' +static const XMLCh DURATION_Y = chLatin_Y; // 'Y' +static const XMLCh DURATION_M = chLatin_M; // 'M' +static const XMLCh DURATION_D = chLatin_D; // 'D' +static const XMLCh DURATION_H = chLatin_H; // 'H' +static const XMLCh DURATION_S = chLatin_S; // 'S' + +static const XMLCh DATE_SEPARATOR = chDash; // '-' +static const XMLCh TIME_SEPARATOR = chColon; // ':' +static const XMLCh TIMEZONE_SEPARATOR = chColon; // ':' +static const XMLCh DATETIME_SEPARATOR = chLatin_T; // 'T' +static const XMLCh MILISECOND_SEPARATOR = chPeriod; // '.' + +static const XMLCh UTC_STD_CHAR = chLatin_Z; // 'Z' +static const XMLCh UTC_POS_CHAR = chPlus; // '+' +static const XMLCh UTC_NEG_CHAR = chDash; // '-' + +static const XMLCh UTC_SET[] = {UTC_STD_CHAR //"Z+-" + , UTC_POS_CHAR + , UTC_NEG_CHAR + , chNull}; + +static const int YMD_MIN_SIZE = 10; // CCYY-MM-DD +static const int YMONTH_MIN_SIZE = 7; // CCYY_MM +static const int TIME_MIN_SIZE = 8; // hh:mm:ss +static const int TIMEZONE_SIZE = 5; // hh:mm +static const int DAY_SIZE = 5; // ---DD +static const int MONTH_SIZE = 6; // --MM-- +static const int MONTHDAY_SIZE = 7; // --MM-DD +static const int NOT_FOUND = -1; + +//define constants to be used in assigning default values for +//all date/time excluding duration +static const int YEAR_DEFAULT = 2000; +static const int MONTH_DEFAULT = 01; +static const int DAY_DEFAULT = 15; + +// order-relation on duration is a partial order. The dates below are used to +// for comparison of 2 durations, based on the fact that +// duration x and y is x<=y iff s+x<=s+y +// see 3.2.6 duration W3C schema datatype specs +// +// the dates are in format: {CCYY,MM,DD, H, S, M, MS, timezone} +const int XMLDateTime::DATETIMES[4][TOTAL_SIZE] = +{ + {1696, 9, 1, 0, 0, 0, 0, UTC_STD}, + {1697, 2, 1, 0, 0, 0, 0, UTC_STD}, + {1903, 3, 1, 0, 0, 0, 0, UTC_STD}, + {1903, 7, 1, 0, 0, 0, 0, UTC_STD} +}; + +// --------------------------------------------------------------------------- +// local methods +// --------------------------------------------------------------------------- +static inline int fQuotient(int a, int b) +{ + div_t div_result = div(a, b); + return div_result.quot; +} + +static inline int fQuotient(int temp, int low, int high) +{ + return fQuotient(temp - low, high - low); +} + +static inline int mod(int a, int b, int quotient) +{ + return (a - quotient*b) ; +} + +static inline int modulo (int temp, int low, int high) +{ + //modulo(a - low, high - low) + low + int a = temp - low; + int b = high - low; + return (mod (a, b, fQuotient(a, b)) + low) ; +} + +static inline bool isLeapYear(int year) +{ + return((year%4 == 0) && ((year%100 != 0) || (year%400 == 0))); +} + +static int maxDayInMonthFor(int year, int month) +{ + + if ( month == 4 || month == 6 || month == 9 || month == 11 ) + { + return 30; + } + else if ( month==2 ) + { + if ( isLeapYear(year) ) + return 29; + else + return 28; + } + else + { + return 31; + } + +} + +// --------------------------------------------------------------------------- +// static methods : for duration +// --------------------------------------------------------------------------- +/** + * Compares 2 given durations. (refer to W3C Schema Datatypes "3.2.6 duration") + * + * 3.2.6.2 Order relation on duration + * + * In general, the order-relation on duration is a partial order since there is no + * determinate relationship between certain durations such as one month (P1M) and 30 days (P30D). + * The order-relation of two duration values x and y is x < y iff s+x < s+y for each qualified + * dateTime s in the list below. + * + * These values for s cause the greatest deviations in the addition of dateTimes and durations + * + **/ +int XMLDateTime::compare(const XMLDateTime* const pDate1 + , const XMLDateTime* const pDate2 + , bool strict) +{ + //REVISIT: this is unoptimazed vs of comparing 2 durations + // Algorithm is described in 3.2.6.2 W3C Schema Datatype specs + // + + int resultA, resultB = INDETERMINATE; + + //try and see if the objects are equal + if ( (resultA = compareOrder(pDate1, pDate2)) == EQUAL) + return EQUAL; + + //long comparison algorithm is required + XMLDateTime tempA, *pTempA = &tempA; + XMLDateTime tempB, *pTempB = &tempB; + + addDuration(pTempA, pDate1, 0); + addDuration(pTempB, pDate2, 0); + resultA = compareOrder(pTempA, pTempB); + if ( resultA == INDETERMINATE ) + return INDETERMINATE; + + addDuration(pTempA, pDate1, 1); + addDuration(pTempB, pDate2, 1); + resultB = compareOrder(pTempA, pTempB); + resultA = compareResult(resultA, resultB, strict); + if ( resultA == INDETERMINATE ) + return INDETERMINATE; + + addDuration(pTempA, pDate1, 2); + addDuration(pTempB, pDate2, 2); + resultB = compareOrder(pTempA, pTempB); + resultA = compareResult(resultA, resultB, strict); + if ( resultA == INDETERMINATE ) + return INDETERMINATE; + + addDuration(pTempA, pDate1, 3); + addDuration(pTempB, pDate2, 3); + resultB = compareOrder(pTempA, pTempB); + resultA = compareResult(resultA, resultB, strict); + + return resultA; + +} + +// +// Form a new XMLDateTime with duration and baseDate array +// Note: C++ Java +// fNewDate duration +// fDuration date +// + +void XMLDateTime::addDuration(XMLDateTime* fNewDate + , const XMLDateTime* const fDuration + , int index) + +{ + + //REVISIT: some code could be shared between normalize() and this method, + // however is it worth moving it? The structures are different... + // + + fNewDate->reset(); + //add months (may be modified additionaly below) + int temp = DATETIMES[index][Month] + fDuration->fValue[Month]; + fNewDate->fValue[Month] = modulo(temp, 1, 13); + int carry = fQuotient(temp, 1, 13); + + //add years (may be modified additionaly below) + fNewDate->fValue[CentYear] = DATETIMES[index][CentYear] + fDuration->fValue[CentYear] + carry; + + //add seconds + temp = DATETIMES[index][Second] + fDuration->fValue[Second]; + carry = fQuotient (temp, 60); + fNewDate->fValue[Second] = mod(temp, 60, carry); + + //add minutes + temp = DATETIMES[index][Minute] + fDuration->fValue[Minute] + carry; + carry = fQuotient(temp, 60); + fNewDate->fValue[Minute] = mod(temp, 60, carry); + + //add hours + temp = DATETIMES[index][Hour] + fDuration->fValue[Hour] + carry; + carry = fQuotient(temp, 24); + fNewDate->fValue[Hour] = mod(temp, 24, carry); + + fNewDate->fValue[Day] = DATETIMES[index][Day] + fDuration->fValue[Day] + carry; + + while ( true ) + { + temp = maxDayInMonthFor(fNewDate->fValue[CentYear], fNewDate->fValue[Month]); + if ( fNewDate->fValue[Day] < 1 ) + { //original fNewDate was negative + fNewDate->fValue[Day] += maxDayInMonthFor(fNewDate->fValue[CentYear], fNewDate->fValue[Month]-1); + carry = -1; + } + else if ( fNewDate->fValue[Day] > temp ) + { + fNewDate->fValue[Day] -= temp; + carry = 1; + } + else + { + break; + } + + temp = fNewDate->fValue[Month] + carry; + fNewDate->fValue[Month] = modulo(temp, 1, 13); + fNewDate->fValue[CentYear] += fQuotient(temp, 1, 13); + } + + //fNewDate->fValue[utc] = UTC_STD_CHAR; + fNewDate->fValue[utc] = UTC_STD; +} + +int XMLDateTime::compareResult(short resultA + , short resultB + , bool strict) +{ + + if ( resultB == INDETERMINATE ) + { + return INDETERMINATE; + } + else if ( (resultA != resultB) && + strict ) + { + return INDETERMINATE; + } + else if ( (resultA != resultB) && + !strict ) + { + if ( (resultA != EQUAL) && + (resultB != EQUAL) ) + { + return INDETERMINATE; + } + else + { + return (resultA != EQUAL)? resultA : resultB; + } + } + + return resultA; + +} + +// --------------------------------------------------------------------------- +// static methods : for others +// --------------------------------------------------------------------------- +int XMLDateTime::compare(const XMLDateTime* const pDate1 + , const XMLDateTime* const pDate2) +{ + + if (pDate1->fValue[utc] == pDate2->fValue[utc]) + { + return XMLDateTime::compareOrder(pDate1, pDate2); + } + + short c1, c2; + + if ( pDate1->isNormalized()) + { + c1 = compareResult(pDate1, pDate2, false, UTC_POS); + c2 = compareResult(pDate1, pDate2, false, UTC_NEG); + return getRetVal(c1, c2); + } + else if ( pDate2->isNormalized()) + { + c1 = compareResult(pDate1, pDate2, true, UTC_POS); + c2 = compareResult(pDate1, pDate2, true, UTC_NEG); + return getRetVal(c1, c2); + } + + return INDETERMINATE; +} + +int XMLDateTime::compareResult(const XMLDateTime* const pDate1 + , const XMLDateTime* const pDate2 + , bool set2Left + , int utc_type) +{ + XMLDateTime tmpDate = (set2Left ? *pDate1 : *pDate2); + + tmpDate.fTimeZone[hh] = 14; + tmpDate.fTimeZone[mm] = 0; + tmpDate.fValue[utc] = utc_type; + tmpDate.normalize(); + + return (set2Left? XMLDateTime::compareOrder(&tmpDate, pDate2) : + XMLDateTime::compareOrder(pDate1, &tmpDate)); +} + +int XMLDateTime::compareOrder(const XMLDateTime* const lValue + , const XMLDateTime* const rValue) +{ + // + // If any of the them is not normalized() yet, + // we need to do something here. + // + XMLDateTime lTemp = *lValue; + XMLDateTime rTemp = *rValue; + + lTemp.normalize(); + rTemp.normalize(); + + for ( int i = 0 ; i < TOTAL_SIZE; i++ ) + { + if ( lTemp.fValue[i] < rTemp.fValue[i] ) + { + return LESS_THAN; + } + else if ( lTemp.fValue[i] > rTemp.fValue[i] ) + { + return GREATER_THAN; + } + } + + return EQUAL; +} + +// --------------------------------------------------------------------------- +// ctor and dtor +// --------------------------------------------------------------------------- +XMLDateTime::~XMLDateTime() +{ + if (fBuffer) + delete[] fBuffer; +} + +XMLDateTime::XMLDateTime() +:fBuffer(0) +{ + reset(); +} + +XMLDateTime::XMLDateTime(const XMLCh* const aString) +:fBuffer(0) +{ + setBuffer(aString); +} + +// ----------------------------------------------------------------------- +// Copy ctor and Assignment operators +// ----------------------------------------------------------------------- + +XMLDateTime::XMLDateTime(const XMLDateTime &toCopy) +:fBuffer(0) +{ + copy(toCopy); +} + +XMLDateTime& XMLDateTime::operator=(const XMLDateTime& rhs) +{ + if (this == &rhs) + return *this; + + copy(rhs); + return *this; +} + +// ----------------------------------------------------------------------- +// Implementation of Abstract Interface +// ----------------------------------------------------------------------- + +// +// We may simply return the handle to fBuffer, but +// for the sake of consistency, we return a duplicated copy +// and the caller is responsible for the release of the buffer +// just like any other things in the XMLNumber family. +// +XMLCh* XMLDateTime::toString() const +{ + assertBuffer(); + + XMLCh* retBuf = XMLString::replicate(fBuffer); + return retBuf; +} + +int XMLDateTime::getSign() const +{ + return 0; +} + +// --------------------------------------------------------------------------- +// Parsers +// --------------------------------------------------------------------------- + +// +// [-]{CCYY-MM-DD}'T'{HH:MM:SS.MS}[TimeZone] +// +void XMLDateTime::parseDateTime() +{ + initParser(); + getDate(); + + //fStart is supposed to point to 'T' + if (fBuffer[fStart++] != DATETIME_SEPARATOR) + ThrowXML(RuntimeException, XMLExcepts::SubGrpComparator_NGR); + //("CCYY-MM must be followed by '-' sign"); + + getTime(); + validateDateTime(); + normalize(); +} + +// +// [-]{CCYY-MM-DD}[TimeZone] +// +void XMLDateTime::parseDate() +{ + initParser(); + getDate(); + parseTimeZone(); + validateDateTime(); + normalize(); +} + +void XMLDateTime::parseTime() +{ + initParser(); + + // time initialize to default values + fValue[CentYear]= YEAR_DEFAULT; + fValue[Month] = MONTH_DEFAULT; + fValue[Day] = DAY_DEFAULT; + + getTime(); + + validateDateTime(); + normalize(); +} + +// +// {---DD}[TimeZone] +// 01234 +// +void XMLDateTime::parseDay() +{ + initParser(); + + if (fBuffer[0] != DATE_SEPARATOR || + fBuffer[1] != DATE_SEPARATOR || + fBuffer[2] != DATE_SEPARATOR ) + { + ThrowXML(RuntimeException, XMLExcepts::SubGrpComparator_NGR); + //"Error in day parsing"); + } + + //initialize values + fValue[CentYear] = YEAR_DEFAULT; + fValue[Month] = MONTH_DEFAULT; + fValue[Day] = parseInt(fStart+3, fStart+5); + + if ( DAY_SIZE < fEnd ) + { + int sign = findUTCSign(DAY_SIZE); + if ( sign < 0 ) + { + ThrowXML(RuntimeException, XMLExcepts::SubGrpComparator_NGR); + //"Error in day parsing"); + } + else + { + getTimeZone(sign); + } + } + + validateDateTime(); + normalize(); +} + +// +// {--MM--}[TimeZone] +// 012345 +// +void XMLDateTime::parseMonth() +{ + initParser(); + + if (fBuffer[0] != DATE_SEPARATOR || + fBuffer[1] != DATE_SEPARATOR || + fBuffer[4] != DATE_SEPARATOR || + fBuffer[5] != DATE_SEPARATOR ) + { + ThrowXML(RuntimeException, XMLExcepts::SubGrpComparator_NGR); + //("Invalid format for gMonth: "+str); + } + + //set constants + fValue[CentYear] = YEAR_DEFAULT; + fValue[Day] = DAY_DEFAULT; + fValue[Month] = parseInt(2, 4); + + if ( MONTH_SIZE < fEnd ) + { + int sign = findUTCSign(MONTH_SIZE); + if ( sign < 0 ) + { + ThrowXML(RuntimeException, XMLExcepts::SubGrpComparator_NGR); + //"Error in month parsing: "+str); + } + else + { + getTimeZone(sign); + } + } + + validateDateTime(); + normalize(); +} + +// +//[-]{CCYY}[TimeZone] +// 0 1234 +// +void XMLDateTime::parseYear() +{ + initParser(); + + // skip the first '-' and search for timezone + // + int sign = findUTCSign((fBuffer[0] == chDash) ? 1 : 0); + + if (sign == -1) + { + fValue[CentYear] = parseIntYear(fEnd); + } + else + { + fValue[CentYear] = parseIntYear(sign); + getTimeZone (sign); + } + + //initialize values + fValue[Month] = MONTH_DEFAULT; + fValue[Day] = DAY_DEFAULT; //java is 1 + + validateDateTime(); + normalize(); +} + +// +//{--MM-DD}[TimeZone] +// 0123456 +// +void XMLDateTime::parseMonthDay() +{ + initParser(); + + if (fBuffer[0] != DATE_SEPARATOR || + fBuffer[1] != DATE_SEPARATOR || + fBuffer[4] != DATE_SEPARATOR ) + { + ThrowXML(RuntimeException, XMLExcepts::SubGrpComparator_NGR); + //("Invalid format for gMonthDay: "+str); + } + + + //initialize + fValue[CentYear] = YEAR_DEFAULT; + fValue[Month] = parseInt(2, 4); + fValue[Day] = parseInt(5, 7); + + if ( MONTHDAY_SIZE < fEnd ) + { + int sign = findUTCSign(MONTHDAY_SIZE); + if ( sign<0 ) + { + ThrowXML(RuntimeException, XMLExcepts::SubGrpComparator_NGR); + //"Error in month parsing: "+str); + } + else + { + getTimeZone(sign); + } + } + + validateDateTime(); + normalize(); +} + +void XMLDateTime::parseYearMonth() +{ + initParser(); + + // get date + getYearMonth(); + parseTimeZone(); + + validateDateTime(); + normalize(); +} + +// +//PnYn MnDTnH nMnS: -P1Y2M3DT10H30M +// +// [-]{'P'{[n'Y'][n'M'][n'D']['T'][n'H'][n'M'][n'S']}} +// +// Note: the n above shall be >= 0 +// if no time element found, 'T' shall be absent +// +void XMLDateTime::parseDuration() +{ + initParser(); + + // must start with '-' or 'P' + // + XMLCh c = fBuffer[fStart++]; + if ( (c != DURATION_STARTER) && + (c != chDash) ) + { + ThrowXML(RuntimeException, XMLExcepts::SubGrpComparator_NGR); + //"Error in month parsing: "+str); + //SchemaDateTimeException(); + } + + // 'P' must ALWAYS be present in either case + if ( (c == chDash) && + (fBuffer[fStart++]!= DURATION_STARTER )) + { + ThrowXML(RuntimeException, XMLExcepts::SubGrpComparator_NGR); + //SchemaDateTimeException(); + } + + // java code + //date[utc]=(c=='-')?'-':0; + //fValue[utc] = UTC_STD; + fValue[utc] = (fBuffer[0] == chDash? UTC_NEG : UTC_STD); + + int negate = ( fBuffer[0] == chDash ? -1 : 1); + + // + // No negative value is allowed after 'P' + // + // eg P-1234, invalid + // + if (indexOf(fStart, fEnd, chDash) != NOT_FOUND) + { + ThrowXML(RuntimeException, XMLExcepts::SubGrpComparator_NGR); + //SchemaDateTimeException(); + } + + //at least one number and designator must be seen after P + bool designator = false; + + int endDate = indexOf(fStart, fEnd, DATETIME_SEPARATOR); + if ( endDate == NOT_FOUND ) + { + endDate = fEnd; // 'T' absent + } + + //find 'Y' + int end = indexOf(fStart, endDate, DURATION_Y); + if ( end != NOT_FOUND ) + { + //scan year + fValue[CentYear] = negate * parseInt(fStart, end); + fStart = end+1; + designator = true; + } + + end = indexOf(fStart, endDate, DURATION_M); + if ( end != NOT_FOUND ) + { + //scan month + fValue[Month] = negate * parseInt(fStart, end); + fStart = end+1; + designator = true; + } + + end = indexOf(fStart, endDate, DURATION_D); + if ( end != NOT_FOUND ) + { + //scan day + fValue[Day] = negate * parseInt(fStart,end); + fStart = end+1; + designator = true; + } + + if ( (fEnd == endDate) && // 'T' absent + (fStart != fEnd) ) // something after Day + { + ThrowXML(RuntimeException, XMLExcepts::SubGrpComparator_NGR); + //SchemaDateTimeException(); + } + + if ( fEnd != endDate ) // 'T' present + { + //scan hours, minutes, seconds + // + + // skip 'T' first + end = indexOf(++fStart, fEnd, DURATION_H); + if ( end != NOT_FOUND ) + { + //scan hours + fValue[Hour] = negate * parseInt(fStart, end); + fStart = end+1; + designator = true; + } + + end = indexOf(fStart, fEnd, DURATION_M); + if ( end != NOT_FOUND ) + { + //scan min + fValue[Minute] = negate * parseInt(fStart, end); + fStart = end+1; + designator = true; + } + + end = indexOf(fStart, fEnd, DURATION_S); + if ( end != NOT_FOUND ) + { + //scan seconds + int mlsec = indexOf (fStart, end, MILISECOND_SEPARATOR); + if ( mlsec != NOT_FOUND ) + { + fValue[Second] = negate * parseInt(fStart, mlsec); + fValue[MiliSecond] = negate * parseInt(mlsec+1, end); + } + else + { + fValue[Second] = negate * parseInt(fStart,end); + } + + fStart = end+1; + designator = true; + } + + // no additional data shouls appear after last item + // P1Y1M1DT is illigal value as well + if ( (fStart != fEnd) || + fBuffer[--fStart] == DATETIME_SEPARATOR ) + { + ThrowXML(RuntimeException, XMLExcepts::SubGrpComparator_NGR); + //SchemaDateTimeException(); + } + } + + if ( !designator ) + { + ThrowXML(RuntimeException, XMLExcepts::SubGrpComparator_NGR); + //SchemaDateTimeException(); + } + +} + +// --------------------------------------------------------------------------- +// Scanners +// --------------------------------------------------------------------------- + +// +// [-]{CCYY-MM-DD} +// +// Note: CCYY could be more than 4 digits +// Assuming fStart point to the beginning of the Date Section +// fStart updated to point to the position right AFTER the second 'D' +// Since the lenght of CCYY might be variable, we can't check format upfront +// +void XMLDateTime::getDate() +{ + + // Ensure enough chars in buffer + if ( (fStart+YMD_MIN_SIZE) > fEnd) + ThrowXML(RuntimeException, XMLExcepts::SubGrpComparator_NGR); + //"Imcomplete Date Format"; + + getYearMonth(); // Scan YearMonth and + // fStart point to the next '-' + + if (fBuffer[fStart++] != DATE_SEPARATOR) + { + ThrowXML(RuntimeException, XMLExcepts::SubGrpComparator_NGR); + //("CCYY-MM must be followed by '-' sign"); + } + + fValue[Day] = parseInt(fStart, fStart+2); + fStart += 2 ; //fStart points right after the Day + + return; +} + +// +// hh:mm:ss[.msssss]['Z'] +// hh:mm:ss[.msssss][['+'|'-']hh:mm] +// 012345678 +// +// Note: Assuming fStart point to the beginning of the Time Section +// fStart updated to point to the position right AFTER the second 's' +// or ms if any +// +void XMLDateTime::getTime() +{ + + // Ensure enough chars in buffer + if ( (fStart+TIME_MIN_SIZE) > fEnd) + ThrowXML(RuntimeException, XMLExcepts::SubGrpComparator_NGR); + //"Imcomplete Time Format" + + // check (fixed) format first + if ((fBuffer[fStart + 2] != TIME_SEPARATOR) || + (fBuffer[fStart + 5] != TIME_SEPARATOR) ) + { + ThrowXML(RuntimeException, XMLExcepts::SubGrpComparator_NGR); + //("Error in parsing time" ); + } + + // + // get hours, minute and second + // + fValue[Hour] = parseInt(fStart + 0, fStart + 2); + fValue[Minute] = parseInt(fStart + 3, fStart + 5); + fValue[Second] = parseInt(fStart + 6, fStart + 8); + fStart += 8; + + // to see if any ms and/or utc part after that + if (fStart >= fEnd) + return; + + //find UTC sign if any + int sign = findUTCSign(fStart); + + //parse miliseconds + int milisec = (fBuffer[fStart] == MILISECOND_SEPARATOR)? fStart : NOT_FOUND; + if ( milisec != NOT_FOUND ) + { + fStart++; // skip the '.' + // make sure we have some thing between the '.' and fEnd + if (fStart >= fEnd) + { + ThrowXML(RuntimeException, XMLExcepts::SubGrpComparator_NGR); + //("ms shall be present once '.' is present" ); + } + + if ( sign == NOT_FOUND ) + { + fValue[MiliSecond] = parseInt(fStart, fEnd); //get ms between '.' and fEnd + fStart = fEnd; + } + else + { + fValue[MiliSecond] = parseInt(fStart, sign); //get ms between UTC sign and fEnd + } + } + + //parse UTC time zone (hh:mm) + if ( sign > 0 ) { + getTimeZone(sign); + } + +} + +// +// [-]{CCYY-MM} +// +// Note: CCYY could be more than 4 digits +// fStart updated to point AFTER the second 'M' (probably meet the fEnd) +// +void XMLDateTime::getYearMonth() +{ + + // Ensure enough chars in buffer + if ( (fStart+YMONTH_MIN_SIZE) > fEnd) + ThrowXML(RuntimeException, XMLExcepts::SubGrpComparator_NGR); + //"Imcomplete YearMonth Format"; + + // skip the first leading '-' + int start = ( fBuffer[0] == chDash ) ? fStart + 1 : fStart; + + // + // search for year separator '-' + // + int yearSeparator = indexOf(start, fEnd, DATE_SEPARATOR); + if ( yearSeparator == NOT_FOUND) + ThrowXML(RuntimeException, XMLExcepts::SubGrpComparator_NGR); + //("Year separator is missing or misplaced"); + + int length = yearSeparator - start; + if (length < 4) + { + ThrowXML(RuntimeException, XMLExcepts::SubGrpComparator_NGR); + //"Year must have 'CCYY' format"); + } + else if (length > 4 && + fBuffer[start] == chDigit_0) + { + ThrowXML(RuntimeException, XMLExcepts::SubGrpComparator_NGR); + //"Leading zeros are required if the year value would otherwise have fewer than four digits; + // otherwise they are forbidden"); + } + + fValue[CentYear] = parseIntYear(yearSeparator); + fStart = yearSeparator + 1; //skip the '-' and point to the first M + + // + //gonna check we have enough byte for month + // + if ((fStart + 2) > fEnd ) + ThrowXML(RuntimeException, XMLExcepts::SubGrpComparator_NGR); + //"no month in buffer" + + fValue[Month] = parseInt(fStart, yearSeparator + 3); + fStart += 2; //fStart points right after the MONTH + + return; +} + +void XMLDateTime::parseTimeZone() +{ + if ( fStart < fEnd ) + { + int sign = findUTCSign(fStart); + if ( sign < 0 ) + { + ThrowXML(RuntimeException, XMLExcepts::SubGrpComparator_NGR); + //("Error in month parsing"); + } + else + { + getTimeZone(sign); + } + } + + return; +} + +// +// 'Z' +// ['+'|'-']hh:mm +// +// Note: Assuming fStart points to the beginning of TimeZone section +// fStart updated to meet fEnd +// +void XMLDateTime::getTimeZone(const int sign) +{ + + if ( fBuffer[sign] == UTC_STD_CHAR ) + { + if ((sign + 1) != fEnd ) + { + ThrowXML(RuntimeException, XMLExcepts::SubGrpComparator_NGR); + //"Error in parsing time zone"); + } + + return; + } + + // + // otherwise, it has to be this format + // '[+|-]'hh:mm + // 1 23456 7 + // sign fEnd + // + if ( ( ( sign + TIMEZONE_SIZE + 1) != fEnd ) || + ( fBuffer[sign + 3] != TIMEZONE_SEPARATOR ) ) + { + ThrowXML(RuntimeException, XMLExcepts::SubGrpComparator_NGR); + //("Error in parsing time zone"); + } + + fTimeZone[hh] = parseInt(sign+1, sign+3); + fTimeZone[mm] = parseInt(sign+4, fEnd); + + return; +} + +// --------------------------------------------------------------------------- +// Validator and normalizer +// --------------------------------------------------------------------------- + +/** + * If timezone present - normalize dateTime [E Adding durations to dateTimes] + * + * @param date CCYY-MM-DDThh:mm:ss+03 + * @return CCYY-MM-DDThh:mm:ssZ + */ +void XMLDateTime::normalize() +{ + + if ((fValue[utc] == UTC_UNKNOWN) || + (fValue[utc] == UTC_STD) ) + return; + + int negate = (fValue[utc] == UTC_POS)? -1: 1; + + // add mins + int temp = fValue[Minute] + negate * fTimeZone[mm]; + int carry = fQuotient(temp, 60); + fValue[Minute] = mod(temp, 60, carry); + + //add hours + temp = fValue[Hour] + negate * fTimeZone[hh] + carry; + carry = fQuotient(temp, 24); + fValue[Hour] = mod(temp, 24, carry); + + fValue[Day] += carry; + + while (1) + { + temp = maxDayInMonthFor(fValue[CentYear], fValue[Month]); + if (fValue[Day] < 1) + { + fValue[Day] += maxDayInMonthFor(fValue[CentYear], fValue[Month] - 1); + carry = -1; + } + else if ( fValue[Day] > temp ) + { + fValue[Day] -= temp; + carry = 1; + } + else + { + break; + } + + temp = fValue[Month] + carry; + fValue[Month] = modulo(temp, 1, 13); + fValue[CentYear] += fQuotient(temp, 1, 13); + } + + // set to normalized + fValue[utc] = UTC_STD; + + return; +} + +void XMLDateTime::validateDateTime() const +{ + + //REVISIT: should we throw an exception for not valid dates + // or reporting an error message should be sufficient? + if ( fValue[CentYear] == 0 ) + { + ThrowXML(RuntimeException, XMLExcepts::SubGrpComparator_NGR); + //"The year \"0000\" is an illegal year value"); + } + + if ( fValue[Month] < 1 || + fValue[Month] > 12 ) + { + ThrowXML(RuntimeException, XMLExcepts::SubGrpComparator_NGR); + //"The month must have values 1 to 12"); + } + + //validate days + if ( fValue[Day] > maxDayInMonthFor( fValue[CentYear], fValue[Month])) + { + ThrowXML(RuntimeException, XMLExcepts::SubGrpComparator_NGR); + //"The day must have values 1 to 31"); + } + + //validate hours + if ( fValue[Hour] < 0 || + fValue[Hour] > 23 ) + { + ThrowXML(RuntimeException, XMLExcepts::SubGrpComparator_NGR); + //("Hour must have values 0-23"); + } + + //validate + if ( fValue[Minute] < 0 || + fValue[Minute] > 59 ) + { + ThrowXML(RuntimeException, XMLExcepts::SubGrpComparator_NGR); + //"Minute must have values 0-59"); + } + + //validate + if ( fValue[Second] < 0 || + fValue[Second] > 60 ) + { + ThrowXML(RuntimeException, XMLExcepts::SubGrpComparator_NGR); + //"Second must have values 0-60"); + } + + //validate + if ( fTimeZone[hh] < -14 || + fTimeZone[hh] > 14 ) + { + ThrowXML(RuntimeException, XMLExcepts::SubGrpComparator_NGR); + //"Time zone should have range -14..+14"); + } + + //validate + if ( fTimeZone[mm] < -59 || + fTimeZone[mm] > 59 ) + { + ThrowXML(RuntimeException, XMLExcepts::SubGrpComparator_NGR); + //("Minute must have values 0-59"); + } + + return; +} + +// ----------------------------------------------------------------------- +// locator and converter +// ----------------------------------------------------------------------- +int XMLDateTime::indexOf(const int start, const int end, const XMLCh ch) const +{ + for ( int i = start; i < end; i++ ) + if ( fBuffer[i] == ch ) + return i; + + return NOT_FOUND; +} + +int XMLDateTime::findUTCSign (const int start) +{ + int pos; + for ( int index = start; index < fEnd; index++ ) + { + pos = XMLString::indexOf(UTC_SET, fBuffer[index]); + if ( pos != NOT_FOUND) + { + fValue[utc] = pos+1; // refer to utcType, there is 1 diff + return index; + } + } + + return NOT_FOUND; +} + +// +// Note: +// start: starting point in fBuffer +// end: ending point in fBuffer (exclusive) +// fStart NOT updated +// +int XMLDateTime::parseInt(const int start, const int end) const +{ + + XMLCh* strToScan = new XMLCh[end - start + 1]; + ArrayJanitor<XMLCh> jname(strToScan); + XMLString::subString(strToScan, fBuffer, start, end); + + unsigned int retVal; + XMLString::textToBin(strToScan, retVal); + + return (int) retVal; +} + +// +// [-]CCYY +// +// Note: start from fStart +// end (exclusive) +// fStart NOT updated +// +int XMLDateTime::parseIntYear(const int end) const +{ + bool negative = (fBuffer[0] == chDash); + int yearVal = parseInt((negative ? 1 : 0), end); + return ( negative ? (-1) * yearVal : yearVal ); +} + + diff --git a/src/util/XMLDateTime.hpp b/src/util/XMLDateTime.hpp new file mode 100644 index 0000000000000000000000000000000000000000..0defa0cb3d52949b5da9247244413e03c0792113 --- /dev/null +++ b/src/util/XMLDateTime.hpp @@ -0,0 +1,368 @@ +/* + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2001 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. + * + * 4. The names "Xerces" and "Apache Software Foundation" must + * not be used to endorse or promote products derived from this + * software without prior written permission. For written + * permission, please contact apache\@apache.org. + * + * 5. Products derived from this software may not be called "Apache", + * nor may "Apache" appear in their name, without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation, and was + * originally based on software copyright (c) 2001, International + * Business Machines, Inc., http://www.ibm.com . For more information + * on the Apache Software Foundation, please see + * <http://www.apache.org/>. + */ + +/* + * $Id$ + * $Log$ + * Revision 1.1 2001/11/07 19:16:03 peiyongz + * DateTime Port + * + */ + +#ifndef XML_DATETIME_HPP +#define XML_DATETIME_HPP + +#include <util/XercesDefs.hpp> +#include <util/XMLNumber.hpp> +#include <util/XMLString.hpp> +#include <util/XMLUniDefs.hpp> +#include <util/RuntimeException.hpp> + +class XMLUTIL_EXPORT XMLDateTime : public XMLNumber +{ +public: + + // to be moved to XMLNumber + enum + { + LESS_THAN = -1, + EQUAL = 0, + GREATER_THAN = 1, + INDETERMINATE = 2 + }; + + // ----------------------------------------------------------------------- + // ctors and dtor + // ----------------------------------------------------------------------- + + XMLDateTime(); + + XMLDateTime(const XMLCh* const); + + ~XMLDateTime(); + + inline void setBuffer(const XMLCh* const); + + // ----------------------------------------------------------------------- + // Copy ctor and Assignment operators + // ----------------------------------------------------------------------- + + XMLDateTime(const XMLDateTime&); + + XMLDateTime& operator=(const XMLDateTime&); + + // ----------------------------------------------------------------------- + // Implementation of Abstract Interface + // ----------------------------------------------------------------------- + + virtual XMLCh* toString() const; + + virtual int getSign() const; + + // ----------------------------------------------------------------------- + // parsers + // ----------------------------------------------------------------------- + + void parseDateTime(); //DateTime + + void parseDate(); //Date + + void parseTime(); //Time + + void parseDay(); //gDay + + void parseMonth(); //gMonth + + void parseYear(); //gYear + + void parseMonthDay(); //gMonthDay + + void parseYearMonth(); //gYearMonth + + void parseDuration(); //duration + + // ----------------------------------------------------------------------- + // Comparison + // ----------------------------------------------------------------------- + static int compare(const XMLDateTime* const + , const XMLDateTime* const); + + static int compare(const XMLDateTime* const + , const XMLDateTime* const + , bool ); + + static int compareOrder(const XMLDateTime* const + , const XMLDateTime* const); + +private: + + // ----------------------------------------------------------------------- + // Constant data + // ----------------------------------------------------------------------- + // + enum valueIndex + { + CentYear = 0, + Month = 1, + Day = 2, + Hour = 3, + Minute = 4, + Second = 5, + MiliSecond = 6, + utc = 7, + TOTAL_SIZE = 8 + }; + + enum timezoneIndex + { + hh = 0, + mm = 1, + TIMEZONE_ARRAYSIZE = 2 + }; + + enum utcType + { + UTC_UNKNOWN = 0, + UTC_STD = 1, // set in parse() or normalize() + UTC_POS = 2, // set in parse() + UTC_NEG = 3 // set in parse() + }; + + static const int DATETIMES[4][TOTAL_SIZE]; + + // ----------------------------------------------------------------------- + // Comparison + // ----------------------------------------------------------------------- + static int compareResult(short + , short + , bool); + + static void addDuration(XMLDateTime* pDuration + , const XMLDateTime* const pBaseDate + , int index); + + + static int compareResult(const XMLDateTime* const + , const XMLDateTime* const + , bool + , int); + + static inline int getRetVal(int, int); + + // ----------------------------------------------------------------------- + // helper + // ----------------------------------------------------------------------- + + inline void reset(); + + inline void assertBuffer() const; + + inline void copy(const XMLDateTime&); + + // allow multiple parsing + inline void initParser(); + + inline bool isNormalized() const; + + // ----------------------------------------------------------------------- + // scaners + // ----------------------------------------------------------------------- + + void getDate(); + + void getTime(); + + void getYearMonth(); + + void getTimeZone(const int); + + void parseTimeZone(); + + // ----------------------------------------------------------------------- + // locator and converter + // ----------------------------------------------------------------------- + + int findUTCSign(int start); + + int indexOf(const int start + , const int end + , const XMLCh ch) const; + + int parseInt(const int start + , const int end) const; + + int parseIntYear(const int end) const; + + // ----------------------------------------------------------------------- + // validator and normalizer + // ----------------------------------------------------------------------- + + void validateDateTime() const; + + void normalize(); + + // ----------------------------------------------------------------------- + // Unimplemented operator == + // ----------------------------------------------------------------------- + bool operator==(const XMLDateTime& toCompare) const; + + + // ----------------------------------------------------------------------- + // Private data members + // + // fValue[] + // object representation of date time. + // + // fTimeZone[] + // temporary storage for normalization + // + // fStart, fEnd + // pointers to the portion of fBuffer being parsed + // + // fBuffer + // raw data to be parsed, own it. + // + // ----------------------------------------------------------------------- + + int fValue[TOTAL_SIZE]; + int fTimeZone[TIMEZONE_ARRAYSIZE]; + int fStart; + int fEnd; + + XMLCh* fBuffer; + +}; + +void XMLDateTime::setBuffer(const XMLCh* const aString) +{ + reset(); + fBuffer = XMLString::replicate(aString); + fEnd = XMLString::stringLen(fBuffer); + +} + +void XMLDateTime::reset() +{ + for ( int i=0; i < TOTAL_SIZE; i++ ) + fValue[i] = 0; + + fTimeZone[hh] = fTimeZone[mm] = 0; + fStart = fEnd = 0; + + if (fBuffer) + { + delete[] fBuffer; + fBuffer = 0; + } + +} + +void XMLDateTime::copy(const XMLDateTime& rhs) +{ + for ( int i = 0; i < TOTAL_SIZE; i++ ) + fValue[i] = rhs.fValue[i]; + + fTimeZone[hh] = rhs.fTimeZone[hh]; + fTimeZone[mm] = rhs.fTimeZone[mm]; + fStart = rhs.fStart; + fEnd = rhs.fEnd; + + if (fBuffer) + { + delete[] fBuffer; + fBuffer = 0; + } + + if (rhs.fBuffer) + fBuffer = XMLString::replicate(rhs.fBuffer); + +} + +void XMLDateTime::assertBuffer() const +{ + if ( ( !fBuffer ) || + ( fBuffer[0] == chNull ) ) + { + ThrowXML(RuntimeException, XMLExcepts::SubGrpComparator_NGR); + //" buffer not set properly" + } + +} + +void XMLDateTime::initParser() +{ + assertBuffer(); + fStart = 0; // to ensure scan from the very first beginning + // in case the pointer is updated accidentally by someone else. +} + +bool XMLDateTime::isNormalized() const +{ + return ( fValue[utc] == UTC_STD ? true : false ); +} + +int XMLDateTime::getRetVal(int c1, int c2) +{ + if ((c1 == LESS_THAN && c2 == GREATER_THAN) || + (c1 == GREATER_THAN && c2 == LESS_THAN) ) + { + return INDETERMINATE; + } + + return ( c1 != INDETERMINATE ) ? c1 : c2; +} + +#endif diff --git a/src/validators/datatype/DatatypeValidatorFactory.cpp b/src/validators/datatype/DatatypeValidatorFactory.cpp index de4e21d5314de85d20ac683c511edbbb78beac8f..d0d453bb25df132093377770eaf7fd62321083a7 100644 --- a/src/validators/datatype/DatatypeValidatorFactory.cpp +++ b/src/validators/datatype/DatatypeValidatorFactory.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.26 2001/11/07 19:18:52 peiyongz + * DateTime Port + * * Revision 1.25 2001/10/25 15:06:49 tng * Thread safe the static instance. * @@ -163,6 +166,15 @@ #include <validators/datatype/FloatDatatypeValidator.hpp> #include <validators/datatype/AnyURIDatatypeValidator.hpp> #include <validators/datatype/AnySimpleTypeDatatypeValidator.hpp> +#include <validators/datatype/DateTimeDatatypeValidator.hpp> +#include <validators/datatype/DateDatatypeValidator.hpp> +#include <validators/datatype/TimeDatatypeValidator.hpp> +#include <validators/datatype/DayDatatypeValidator.hpp> +#include <validators/datatype/MonthDatatypeValidator.hpp> +#include <validators/datatype/MonthDayDatatypeValidator.hpp> +#include <validators/datatype/YearDatatypeValidator.hpp> +#include <validators/datatype/YearMonthDatatypeValidator.hpp> +#include <validators/datatype/DurationDatatypeValidator.hpp> #include <util/PlatformUtils.hpp> #include <util/XMLRegisterCleanup.hpp> @@ -450,14 +462,25 @@ void DatatypeValidatorFactory::expandRegistryToFullSchemaSet() new NameDatatypeValidator()); fBuiltInRegistry->put((void*) SchemaSymbols::fgDT_NCNAME, new NCNameDatatypeValidator()); - /* - fBuiltInRegistry->put((void*) SchemaSymbols::fgDT_DURATION, - new DurationDatatypeValidator()); - fBuiltInRegistry->put((void*) SchemaSymbols::fgDT_DAY, - new DayDatatypeValidator()); + + fBuiltInRegistry->put((void*) SchemaSymbols::fgDT_DATETIME, + new DateTimeDatatypeValidator()); + fBuiltInRegistry->put((void*) SchemaSymbols::fgDT_DATE, + new DateDatatypeValidator()); fBuiltInRegistry->put((void*) SchemaSymbols::fgDT_TIME, new TimeDatatypeValidator()); - */ + fBuiltInRegistry->put((void*) SchemaSymbols::fgDT_DAY, + new DayDatatypeValidator()); + fBuiltInRegistry->put((void*) SchemaSymbols::fgDT_MONTH, + new MonthDatatypeValidator()); + fBuiltInRegistry->put((void*) SchemaSymbols::fgDT_MONTHDAY, + new MonthDayDatatypeValidator()); + fBuiltInRegistry->put((void*) SchemaSymbols::fgDT_YEAR, + new YearDatatypeValidator()); + fBuiltInRegistry->put((void*) SchemaSymbols::fgDT_YEARMONTH, + new YearMonthDatatypeValidator()); + fBuiltInRegistry->put((void*) SchemaSymbols::fgDT_DURATION, + new DurationDatatypeValidator()); // REVISIT // We are creating a lot of Hashtables for the facets of the different diff --git a/src/validators/datatype/DateDatatypeValidator.cpp b/src/validators/datatype/DateDatatypeValidator.cpp new file mode 100644 index 0000000000000000000000000000000000000000..eafe0fe08eacea31b38444bbb64f8d8924f45806 --- /dev/null +++ b/src/validators/datatype/DateDatatypeValidator.cpp @@ -0,0 +1,121 @@ +/* + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2001 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. + * + * 4. The names "Xerces" and "Apache Software Foundation" must + * not be used to endorse or promote products derived from this + * software without prior written permission. For written + * permission, please contact apache\@apache.org. + * + * 5. Products derived from this software may not be called "Apache", + * nor may "Apache" appear in their name, without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation, and was + * originally based on software copyright (c) 2001, International + * Business Machines, Inc., http://www.ibm.com . For more information + * on the Apache Software Foundation, please see + * <http://www.apache.org/>. + */ + +/* + * $Id$ + * $Log$ + * Revision 1.1 2001/11/07 19:18:52 peiyongz + * DateTime Port + * + */ + +// --------------------------------------------------------------------------- +// Includes +// --------------------------------------------------------------------------- +#include <validators/datatype/DateDatatypeValidator.hpp> + +// --------------------------------------------------------------------------- +// Constructors and Destructor +// --------------------------------------------------------------------------- +DateDatatypeValidator::DateDatatypeValidator() +:DateTimeValidator(0, 0, 0, DatatypeValidator::Date) +{} + +DateDatatypeValidator::DateDatatypeValidator( + DatatypeValidator* const baseValidator + , RefHashTableOf<KVStringPair>* const facets + , RefVectorOf<XMLCh>* const enums + , const int finalSet) +:DateTimeValidator(baseValidator, facets, finalSet, DatatypeValidator::Date) +{ + init(enums); +} + +DateDatatypeValidator::~DateDatatypeValidator() +{} + +DatatypeValidator* DateDatatypeValidator::newInstance( + RefHashTableOf<KVStringPair>* const facets + , RefVectorOf<XMLCh>* const enums + , const int finalSet) +{ + return (DatatypeValidator*) new DateDatatypeValidator(this, facets, enums, finalSet); +} + +// +// caller need to release the date created here +// +XMLDateTime* DateDatatypeValidator::parse(const XMLCh* const content) +{ + XMLDateTime *pRetDate = new XMLDateTime(content); + + try + { + pRetDate->parseDate(); + } + catch (...) + { + delete pRetDate; + throw; + } + + return pRetDate; +} + +/** + * End of file DateDatatypeValidator::cpp + */ + diff --git a/src/validators/datatype/DateDatatypeValidator.hpp b/src/validators/datatype/DateDatatypeValidator.hpp new file mode 100644 index 0000000000000000000000000000000000000000..21cd96c0d3f44b6641310131e73d26f16832b7bd --- /dev/null +++ b/src/validators/datatype/DateDatatypeValidator.hpp @@ -0,0 +1,112 @@ +/* + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2001 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. + * + * 4. The names "Xerces" and "Apache Software Foundation" must + * not be used to endorse or promote products derived from this + * software without prior written permission. For written + * permission, please contact apache\@apache.org. + * + * 5. Products derived from this software may not be called "Apache", + * nor may "Apache" appear in their name, without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation, and was + * originally based on software copyright (c) 2001, International + * Business Machines, Inc., http://www.ibm.com . For more information + * on the Apache Software Foundation, please see + * <http://www.apache.org/>. + */ + +/* + * $Id$ + * $Log$ + * Revision 1.1 2001/11/07 19:18:52 peiyongz + * DateTime Port + * + */ + +#if !defined(DATE_DATATYPE_VALIDATOR_HPP) +#define DATE_DATATYPE_VALIDATOR_HPP + +#include <validators/datatype/DateTimeValidator.hpp> + +class VALIDATORS_EXPORT DateDatatypeValidator : public DateTimeValidator +{ +public: + + // ----------------------------------------------------------------------- + // Public ctor/dtor + // ----------------------------------------------------------------------- + /** @name Constructor. */ + //@{ + + DateDatatypeValidator(); + + DateDatatypeValidator(DatatypeValidator* const baseValidator + , RefHashTableOf<KVStringPair>* const facets + , RefVectorOf<XMLCh>* const enums + , const int finalSet); + + ~DateDatatypeValidator(); + + + //@} + + /** + * Returns an instance of the base datatype validator class + * Used by the DatatypeValidatorFactory. + */ + virtual DatatypeValidator* newInstance(RefHashTableOf<KVStringPair>* const facets + , RefVectorOf<XMLCh>* const enums + , const int finalSet); + +protected: + + // ----------------------------------------------------------------------- + // implementation of (DateTimeValidator's) virtual interface + // ----------------------------------------------------------------------- + virtual XMLDateTime* parse(const XMLCh* const); +}; + +/** + * End of file DateDatatypeValidator.hpp + */ +#endif + diff --git a/src/validators/datatype/DateTimeDatatypeValidator.cpp b/src/validators/datatype/DateTimeDatatypeValidator.cpp new file mode 100644 index 0000000000000000000000000000000000000000..75ff75f8c5c76833b7c292bd817ebfc31c61c0c4 --- /dev/null +++ b/src/validators/datatype/DateTimeDatatypeValidator.cpp @@ -0,0 +1,121 @@ +/* + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2001 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. + * + * 4. The names "Xerces" and "Apache Software Foundation" must + * not be used to endorse or promote products derived from this + * software without prior written permission. For written + * permission, please contact apache\@apache.org. + * + * 5. Products derived from this software may not be called "Apache", + * nor may "Apache" appear in their name, without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation, and was + * originally based on software copyright (c) 2001, International + * Business Machines, Inc., http://www.ibm.com . For more information + * on the Apache Software Foundation, please see + * <http://www.apache.org/>. + */ + +/* + * $Id$ + * $Log$ + * Revision 1.1 2001/11/07 19:18:52 peiyongz + * DateTime Port + * + */ + +// --------------------------------------------------------------------------- +// Includes +// --------------------------------------------------------------------------- +#include <validators/datatype/DateTimeDatatypeValidator.hpp> + +// --------------------------------------------------------------------------- +// Constructors and Destructor +// --------------------------------------------------------------------------- +DateTimeDatatypeValidator::DateTimeDatatypeValidator() +:DateTimeValidator(0, 0, 0, DatatypeValidator::DateTime) +{} + +DateTimeDatatypeValidator::DateTimeDatatypeValidator( + DatatypeValidator* const baseValidator + , RefHashTableOf<KVStringPair>* const facets + , RefVectorOf<XMLCh>* const enums + , const int finalSet) +:DateTimeValidator(baseValidator, facets, finalSet, DatatypeValidator::DateTime) +{ + init(enums); +} + +DateTimeDatatypeValidator::~DateTimeDatatypeValidator() +{} + +DatatypeValidator* DateTimeDatatypeValidator::newInstance( + RefHashTableOf<KVStringPair>* const facets + , RefVectorOf<XMLCh>* const enums + , const int finalSet) +{ + return (DatatypeValidator*) new DateTimeDatatypeValidator(this, facets, enums, finalSet); +} + +// +// caller need to release the date created here +// +XMLDateTime* DateTimeDatatypeValidator::parse(const XMLCh* const content) +{ + XMLDateTime *pRetDate = new XMLDateTime(content); + + try + { + pRetDate->parseDateTime(); + } + catch (...) + { + delete pRetDate; + throw; + } + + return pRetDate; +} + +/** + * End of file DateTimeDatatypeValidator::cpp + */ + diff --git a/src/validators/datatype/DateTimeDatatypeValidator.hpp b/src/validators/datatype/DateTimeDatatypeValidator.hpp new file mode 100644 index 0000000000000000000000000000000000000000..d8295ffd423f8783965ddbfd95bb1ffbbe0be49f --- /dev/null +++ b/src/validators/datatype/DateTimeDatatypeValidator.hpp @@ -0,0 +1,112 @@ +/* + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2001 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. + * + * 4. The names "Xerces" and "Apache Software Foundation" must + * not be used to endorse or promote products derived from this + * software without prior written permission. For written + * permission, please contact apache\@apache.org. + * + * 5. Products derived from this software may not be called "Apache", + * nor may "Apache" appear in their name, without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation, and was + * originally based on software copyright (c) 2001, International + * Business Machines, Inc., http://www.ibm.com . For more information + * on the Apache Software Foundation, please see + * <http://www.apache.org/>. + */ + +/* + * $Id$ + * $Log$ + * Revision 1.1 2001/11/07 19:18:52 peiyongz + * DateTime Port + * + */ + +#if !defined(DATETIME_DATATYPE_VALIDATOR_HPP) +#define DATETIME_DATATYPE_VALIDATOR_HPP + +#include <validators/datatype/DateTimeValidator.hpp> + +class VALIDATORS_EXPORT DateTimeDatatypeValidator : public DateTimeValidator +{ +public: + + // ----------------------------------------------------------------------- + // Public ctor/dtor + // ----------------------------------------------------------------------- + /** @name Constructor. */ + //@{ + + DateTimeDatatypeValidator(); + + DateTimeDatatypeValidator(DatatypeValidator* const baseValidator + , RefHashTableOf<KVStringPair>* const facets + , RefVectorOf<XMLCh>* const enums + , const int finalSet); + + ~DateTimeDatatypeValidator(); + + + //@} + + /** + * Returns an instance of the base datatype validator class + * Used by the DatatypeValidatorFactory. + */ + virtual DatatypeValidator* newInstance(RefHashTableOf<KVStringPair>* const facets + , RefVectorOf<XMLCh>* const enums + , const int finalSet); + +protected: + + // ----------------------------------------------------------------------- + // implementation of (DateTimeValidator's) virtual interface + // ----------------------------------------------------------------------- + virtual XMLDateTime* parse(const XMLCh* const); +}; + +/** + * End of file DateTimeDatatypeValidator.hpp + */ +#endif + diff --git a/src/validators/datatype/DateTimeValidator.cpp b/src/validators/datatype/DateTimeValidator.cpp new file mode 100644 index 0000000000000000000000000000000000000000..346791a4e791a76bed95b0d9d307e00d0f655c47 --- /dev/null +++ b/src/validators/datatype/DateTimeValidator.cpp @@ -0,0 +1,352 @@ +/* + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2001 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. + * + * 4. The names "Xerces" and "Apache Software Foundation" must + * not be used to endorse or promote products derived from this + * software without prior written permission. For written + * permission, please contact apache\@apache.org. + * + * 5. Products derived from this software may not be called "Apache", + * nor may "Apache" appear in their name, without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation, and was + * originally based on software copyright (c) 2001, International + * Business Machines, Inc., http://www.ibm.com . For more information + * on the Apache Software Foundation, please see + * <http://www.apache.org/>. + */ + +/* + * $Id$ + * $Log$ + * Revision 1.1 2001/11/07 19:18:52 peiyongz + * DateTime Port + * + */ + +// --------------------------------------------------------------------------- +// Includes +// --------------------------------------------------------------------------- +#include <validators/datatype/DateTimeValidator.hpp> +#include <validators/datatype/InvalidDatatypeFacetException.hpp> +#include <validators/datatype/InvalidDatatypeValueException.hpp> +#include <validators/schema/SchemaSymbols.hpp> + +static const int BUF_LEN = 64; +static XMLCh value1[BUF_LEN+1]; +static XMLCh value2[BUF_LEN+1]; + +// --------------------------------------------------------------------------- +// Macro +// --------------------------------------------------------------------------- +#define REPORT_VALUE_ERROR(val1, val2, except_code) \ + XMLCh* value1 = (val1)->toString(); \ + ArrayJanitor<XMLCh> jan1(value1); \ + XMLCh* value2 = (val2)->toString(); \ + ArrayJanitor<XMLCh> jan2(value2); \ + ThrowXML2(InvalidDatatypeValueException \ + , except_code \ + , value1 \ + , value2); + +// --------------------------------------------------------------------------- +// Constructors and Destructor +// --------------------------------------------------------------------------- +DateTimeValidator::~DateTimeValidator() +{} + +DateTimeValidator::DateTimeValidator( + DatatypeValidator* const baseValidator + , RefHashTableOf<KVStringPair>* const facets + , const int finalSet + , const ValidatorType type) +:AbstractNumericFacetValidator(baseValidator, facets, finalSet, type) +{ + //do not invoke init() here !!! +} + +void DateTimeValidator::validate(const XMLCh* const content) +{ + checkContent(content, false); +} + +int DateTimeValidator::compare(const XMLCh* const value1 + , const XMLCh* const value2) +{ + try + { + XMLDateTime *pDate1 = parse(value1); + Janitor<XMLDateTime> jName1(pDate1); + XMLDateTime *pDate2 = parse(value2); + Janitor<XMLDateTime> jName2(pDate2); + int result = compareDates(pDate1, pDate2, true); + return (result==INDETERMINATE)? -1 : result; + } + catch (...) // RuntimeException e + { + return -1; // revisit after implement compareDates() + } + +} + +void DateTimeValidator::initializeValues() +{ +} + +void DateTimeValidator::assignAdditionalFacet( const XMLCh* const key + , const XMLCh* const) +{ + ThrowXML1(InvalidDatatypeFacetException + , XMLExcepts::FACET_Invalid_Tag + , key); +} + +void DateTimeValidator::inheritAdditionalFacet() +{} + +void DateTimeValidator::checkAdditionalFacetConstraints() const +{} + +void DateTimeValidator::checkAdditionalFacetConstraintsBase() const +{} + +void DateTimeValidator::checkContent(const XMLCh* const content + , bool asBase) +{ + + //validate against base validator if any + DateTimeValidator *pBaseValidator = (DateTimeValidator*) this->getBaseValidator(); + if (pBaseValidator) + pBaseValidator->checkContent(content, true); + + int thisFacetsDefined = getFacetsDefined(); + + // we check pattern first + if ( (thisFacetsDefined & DatatypeValidator::FACET_PATTERN ) != 0 ) + { + // lazy construction + if (getRegex() ==0) { + try { + setRegex(new RegularExpression(getPattern(), SchemaSymbols::fgRegEx_XOption)); + } + catch (XMLException &e) + { + ThrowXML1(InvalidDatatypeValueException, XMLExcepts::RethrowError, e.getMessage()); + } + } + + if (getRegex()->matches(content) ==false) + { + ThrowXML2(InvalidDatatypeValueException + , XMLExcepts::VALUE_NotMatch_Pattern + , content + , getPattern()); + } + } + + // if this is a base validator, we only need to check pattern facet + // all other facet were inherited by the derived type + if (asBase) + return; + + try + { + // the derived classes' parse() method constructs an + // XMLDateTime object anc invokes appropriate XMLDateTime's + // parser to parse the content. + XMLDateTime *theDate = parse(content); + Janitor<XMLDateTime> jname(theDate); + + int result; + + // must be < MaxExclusive + if ( (thisFacetsDefined & DatatypeValidator::FACET_MAXEXCLUSIVE) != 0 ) + { + result = compareValues(theDate, getMaxExclusive()); + if ( result != XMLDateTime::LESS_THAN ) + { + REPORT_VALUE_ERROR(theDate + , getMaxExclusive() + , XMLExcepts::VALUE_exceed_maxExcl) + } + } + + // must be <= MaxInclusive + if ( (thisFacetsDefined & DatatypeValidator::FACET_MAXINCLUSIVE) != 0 ) + { + result = compareValues(theDate, getMaxInclusive()); + if ( result == XMLDateTime::GREATER_THAN || result == XMLDateTime::INDETERMINATE ) + { + REPORT_VALUE_ERROR(theDate + , getMaxInclusive() + , XMLExcepts::VALUE_exceed_maxIncl) + } + } + + // must be >= MinInclusive + if ( (thisFacetsDefined & DatatypeValidator::FACET_MININCLUSIVE) != 0 ) + { + result = compareValues(theDate, getMinInclusive()); + if (result == XMLDateTime::LESS_THAN || result == XMLDateTime::INDETERMINATE ) + { + REPORT_VALUE_ERROR(theDate + , getMinInclusive() + , XMLExcepts::VALUE_exceed_minIncl) + } + } + + // must be > MinExclusive + if ( (thisFacetsDefined & DatatypeValidator::FACET_MINEXCLUSIVE) != 0 ) + { + result = compareValues(theDate, getMinExclusive()); + if (result != XMLDateTime::GREATER_THAN) + { + REPORT_VALUE_ERROR(theDate + , getMinExclusive() + , XMLExcepts::VALUE_exceed_minExcl) + } + } + + if ((thisFacetsDefined & DatatypeValidator::FACET_ENUMERATION) != 0 && + (getEnumeration() != 0)) + { + int i=0; + int enumLength = getEnumeration()->size(); + for ( ; i < enumLength; i++) + { + if (compareValues(theDate, getEnumeration()->elementAt(i)) == XMLDateTime::EQUAL) + break; + } + + if (i == enumLength) + ThrowXML1(InvalidDatatypeValueException, XMLExcepts::VALUE_NotIn_Enumeration, content); + } + } + catch ( RuntimeException e ) + { + ThrowXML1(InvalidDatatypeValueException, XMLExcepts::VALUE_NotIn_Enumeration, content); + // new error message needed here + //("Value '"+content+ "' is not legal value for current datatype. " +e.getMessage() ); + } + +} + +// +// Comparision methods +// +int DateTimeValidator::compareValues(const XMLNumber* const lValue + , const XMLNumber* const rValue) +{ + return compareDates((XMLDateTime*) lValue, (XMLDateTime*) rValue, true); +} + +/** + * Compare algorithm described in dateDime (3.2.7). + * Duration datatype overwrites this method + * + * @param date1 normalized date representation of the first value + * @param date2 normalized date representation of the second value + * @param strict + * @return less, greater, less_equal, greater_equal, equal + */ +int DateTimeValidator::compareDates(const XMLDateTime* const date1 + , const XMLDateTime* const date2 + , bool strict) +{ + return XMLDateTime::compare(date1, date2); +} + +// +// In fact, the proper way of the following set*() shall be +// { +// if (fMaxInclusive) +// delete fMaxInclusive; +// +// fMaxInclusive = parse(value); +// +// } +// +// But we know this function is invoked once and only once +// since there is no duplicated facet passed in, therefore +// fMaxInclusive is alwasy zero before, so for the +// sake of performance, we do not do the checking/delete. +// + +void DateTimeValidator::setMaxInclusive(const XMLCh* const value) +{ + fMaxInclusive = parse(value); +} + +void DateTimeValidator::setMaxExclusive(const XMLCh* const value) +{ + fMaxExclusive = parse(value); +} + +void DateTimeValidator::setMinInclusive(const XMLCh* const value) +{ + fMinInclusive = parse(value); +} + +void DateTimeValidator::setMinExclusive(const XMLCh* const value) +{ + fMinExclusive = parse(value); +} + +void DateTimeValidator::setEnumeration() +{ +// to do: do we need to check against base value space??? + + if (!fStrEnumeration) + return; + + int enumLength = fStrEnumeration->size(); + fEnumeration = new RefVectorOf<XMLNumber>(enumLength, true); + fEnumerationInherited = false; + + for ( int i = 0; i < enumLength; i++) + fEnumeration->insertElementAt(parse(fStrEnumeration->elementAt(i)), i); + +} + +/** + * End of file DateTimeValidator::cpp + */ + diff --git a/src/validators/datatype/DateTimeValidator.hpp b/src/validators/datatype/DateTimeValidator.hpp new file mode 100644 index 0000000000000000000000000000000000000000..97e53e46ec1d82170fb3f76d968c763194cb8d6b --- /dev/null +++ b/src/validators/datatype/DateTimeValidator.hpp @@ -0,0 +1,151 @@ +/* + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2001 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. + * + * 4. The names "Xerces" and "Apache Software Foundation" must + * not be used to endorse or promote products derived from this + * software without prior written permission. For written + * permission, please contact apache\@apache.org. + * + * 5. Products derived from this software may not be called "Apache", + * nor may "Apache" appear in their name, without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation, and was + * originally based on software copyright (c) 2001, International + * Business Machines, Inc., http://www.ibm.com . For more information + * on the Apache Software Foundation, please see + * <http://www.apache.org/>. + */ + +/* + * $Id$ + * $Log$ + * Revision 1.1 2001/11/07 19:18:52 peiyongz + * DateTime Port + * + */ + +#if !defined(DATETIME_VALIDATOR_HPP) +#define DATETIME_VALIDATOR_HPP + +#include <validators/datatype/AbstractNumericFacetValidator.hpp> +#include <util/XMLDateTime.hpp> + +class VALIDATORS_EXPORT DateTimeValidator : public AbstractNumericFacetValidator +{ +public: + + // ----------------------------------------------------------------------- + // Public dtor + // ----------------------------------------------------------------------- + /** @name Constructor. */ + //@{ + + virtual ~DateTimeValidator(); + + //@} + + virtual void validate(const XMLCh* const content); + + virtual int compare(const XMLCh* const value1 + , const XMLCh* const value2); + +protected: + + // ----------------------------------------------------------------------- + // ctor used by derived class + // ----------------------------------------------------------------------- + DateTimeValidator(DatatypeValidator* const baseValidator + , RefHashTableOf<KVStringPair>* const facets + , const int finalSet + , const ValidatorType type); + + // + // Abstract interface + // + + virtual void initializeValues(); + + virtual void assignAdditionalFacet(const XMLCh* const key + , const XMLCh* const value); + + virtual void inheritAdditionalFacet(); + + virtual void checkAdditionalFacetConstraints() const; + + virtual void checkAdditionalFacetConstraintsBase() const; + + virtual int compareValues(const XMLNumber* const lValue + , const XMLNumber* const rValue); + + virtual void checkContent(const XMLCh* const content + , bool asBase); + + + virtual void setMaxInclusive(const XMLCh* const); + + virtual void setMaxExclusive(const XMLCh* const); + + virtual void setMinInclusive(const XMLCh* const); + + virtual void setMinExclusive(const XMLCh* const); + + virtual void setEnumeration(); + +protected: + + // ----------------------------------------------------------------------- + // helper interface: to be implemented/overwritten by derived class + // ----------------------------------------------------------------------- + virtual XMLDateTime* parse(const XMLCh* const) = 0; + + // to be overwritten by duration + virtual int compareDates(const XMLDateTime* const lValue + , const XMLDateTime* const rValue + , bool strict); + +}; + +/** + * End of file DateTimeValidator.hpp + */ + +#endif + diff --git a/src/validators/datatype/DayDatatypeValidator.cpp b/src/validators/datatype/DayDatatypeValidator.cpp new file mode 100644 index 0000000000000000000000000000000000000000..604cb3d8e6d63ff846758cc0562477d45414de11 --- /dev/null +++ b/src/validators/datatype/DayDatatypeValidator.cpp @@ -0,0 +1,121 @@ +/* + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2001 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. + * + * 4. The names "Xerces" and "Apache Software Foundation" must + * not be used to endorse or promote products derived from this + * software without prior written permission. For written + * permission, please contact apache\@apache.org. + * + * 5. Products derived from this software may not be called "Apache", + * nor may "Apache" appear in their name, without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation, and was + * originally based on software copyright (c) 2001, International + * Business Machines, Inc., http://www.ibm.com . For more information + * on the Apache Software Foundation, please see + * <http://www.apache.org/>. + */ + +/* + * $Id$ + * $Log$ + * Revision 1.1 2001/11/07 19:18:52 peiyongz + * DateTime Port + * + */ + +// --------------------------------------------------------------------------- +// Includes +// --------------------------------------------------------------------------- +#include <validators/datatype/DayDatatypeValidator.hpp> + +// --------------------------------------------------------------------------- +// Constructors and Destructor +// --------------------------------------------------------------------------- +DayDatatypeValidator::DayDatatypeValidator() +:DateTimeValidator(0, 0, 0, DatatypeValidator::Day) +{} + +DayDatatypeValidator::DayDatatypeValidator( + DatatypeValidator* const baseValidator + , RefHashTableOf<KVStringPair>* const facets + , RefVectorOf<XMLCh>* const enums + , const int finalSet) +:DateTimeValidator(baseValidator, facets, finalSet, DatatypeValidator::Day) +{ + init(enums); +} + +DayDatatypeValidator::~DayDatatypeValidator() +{} + +DatatypeValidator* DayDatatypeValidator::newInstance( + RefHashTableOf<KVStringPair>* const facets + , RefVectorOf<XMLCh>* const enums + , const int finalSet) +{ + return (DatatypeValidator*) new DayDatatypeValidator(this, facets, enums, finalSet); +} + +// +// caller need to release the date created here +// +XMLDateTime* DayDatatypeValidator::parse(const XMLCh* const content) +{ + XMLDateTime *pRetDate = new XMLDateTime(content); + + try + { + pRetDate->parseDay(); + } + catch (...) + { + delete pRetDate; + throw; + } + + return pRetDate; +} + +/** + * End of file DayDatatypeValidator::cpp + */ + diff --git a/src/validators/datatype/DayDatatypeValidator.hpp b/src/validators/datatype/DayDatatypeValidator.hpp new file mode 100644 index 0000000000000000000000000000000000000000..6c67dc4cb7d31d8e9b9b7342e765ae5a06b65f41 --- /dev/null +++ b/src/validators/datatype/DayDatatypeValidator.hpp @@ -0,0 +1,111 @@ +/* + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2001 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. + * + * 4. The names "Xerces" and "Apache Software Foundation" must + * not be used to endorse or promote products derived from this + * software without prior written permission. For written + * permission, please contact apache\@apache.org. + * + * 5. Products derived from this software may not be called "Apache", + * nor may "Apache" appear in their name, without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation, and was + * originally based on software copyright (c) 2001, International + * Business Machines, Inc., http://www.ibm.com . For more information + * on the Apache Software Foundation, please see + * <http://www.apache.org/>. + */ + +/* + * $Id$ + * $Log$ + * Revision 1.1 2001/11/07 19:18:52 peiyongz + * DateTime Port + * + */ + +#if !defined(DAY_DATATYPE_VALIDATOR_HPP) +#define DAY_DATATYPE_VALIDATOR_HPP + +#include <validators/datatype/DateTimeValidator.hpp> + +class VALIDATORS_EXPORT DayDatatypeValidator : public DateTimeValidator +{ +public: + + // ----------------------------------------------------------------------- + // Public ctor/dtor + // ----------------------------------------------------------------------- + /** @name Constructor. */ + //@{ + + DayDatatypeValidator(); + + DayDatatypeValidator(DatatypeValidator* const baseValidator + , RefHashTableOf<KVStringPair>* const facets + , RefVectorOf<XMLCh>* const enums + , const int finalSet); + + ~DayDatatypeValidator(); + + //@} + + /** + * Returns an instance of the base datatype validator class + * Used by the DatatypeValidatorFactory. + */ + virtual DatatypeValidator* newInstance(RefHashTableOf<KVStringPair>* const facets + , RefVectorOf<XMLCh>* const enums + , const int finalSet); + +protected: + + // ----------------------------------------------------------------------- + // implementation of (DateTimeValidator's) virtual interface + // ----------------------------------------------------------------------- + virtual XMLDateTime* parse(const XMLCh* const); +}; + +/** + * End of file DayDatatypeValidator.hpp + */ +#endif + diff --git a/src/validators/datatype/DurationDatatypeValidator.cpp b/src/validators/datatype/DurationDatatypeValidator.cpp new file mode 100644 index 0000000000000000000000000000000000000000..fa3ab0f87f3bcf2d0fd167fb1b9dfec7ea91eaf0 --- /dev/null +++ b/src/validators/datatype/DurationDatatypeValidator.cpp @@ -0,0 +1,128 @@ +/* + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2001 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. + * + * 4. The names "Xerces" and "Apache Software Foundation" must + * not be used to endorse or promote products derived from this + * software without prior written permission. For written + * permission, please contact apache\@apache.org. + * + * 5. Products derived from this software may not be called "Apache", + * nor may "Apache" appear in their name, without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation, and was + * originally based on software copyright (c) 2001, International + * Business Machines, Inc., http://www.ibm.com . For more information + * on the Apache Software Foundation, please see + * <http://www.apache.org/>. + */ + +/* + * $Id$ + * $Log$ + * Revision 1.1 2001/11/07 19:18:52 peiyongz + * DateTime Port + * + */ + +// --------------------------------------------------------------------------- +// Includes +// --------------------------------------------------------------------------- +#include <validators/datatype/DurationDatatypeValidator.hpp> + +// --------------------------------------------------------------------------- +// Constructors and Destructor +// --------------------------------------------------------------------------- +DurationDatatypeValidator::DurationDatatypeValidator() +:DateTimeValidator(0, 0, 0, DatatypeValidator::Duration) +{} + +DurationDatatypeValidator::DurationDatatypeValidator( + DatatypeValidator* const baseValidator + , RefHashTableOf<KVStringPair>* const facets + , RefVectorOf<XMLCh>* const enums + , const int finalSet) +:DateTimeValidator(baseValidator, facets, finalSet, DatatypeValidator::Duration) +{ + init(enums); +} + +DurationDatatypeValidator::~DurationDatatypeValidator() +{} + +DatatypeValidator* DurationDatatypeValidator::newInstance( + RefHashTableOf<KVStringPair>* const facets + , RefVectorOf<XMLCh>* const enums + , const int finalSet) +{ + return (DatatypeValidator*) new DurationDatatypeValidator(this, facets, enums, finalSet); +} + +// +// caller need to release the date created here +// +XMLDateTime* DurationDatatypeValidator::parse(const XMLCh* const content) +{ + XMLDateTime *pRetDate = new XMLDateTime(content); + + try + { + pRetDate->parseDuration(); + } + catch (...) + { + delete pRetDate; + throw; + } + + return pRetDate; +} + +int DurationDatatypeValidator::compareDates(const XMLDateTime* const date1 + , const XMLDateTime* const date2 + , bool strict) +{ + return XMLDateTime::compare(date1, date2, strict); +} + +/** + * End of file DurationDatatypeValidator::cpp + */ + diff --git a/src/validators/datatype/DurationDatatypeValidator.hpp b/src/validators/datatype/DurationDatatypeValidator.hpp new file mode 100644 index 0000000000000000000000000000000000000000..9f6d716918cf84c75ae86ac0f111b17c81e16d74 --- /dev/null +++ b/src/validators/datatype/DurationDatatypeValidator.hpp @@ -0,0 +1,117 @@ +/* + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2001 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. + * + * 4. The names "Xerces" and "Apache Software Foundation" must + * not be used to endorse or promote products derived from this + * software without prior written permission. For written + * permission, please contact apache\@apache.org. + * + * 5. Products derived from this software may not be called "Apache", + * nor may "Apache" appear in their name, without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation, and was + * originally based on software copyright (c) 2001, International + * Business Machines, Inc., http://www.ibm.com . For more information + * on the Apache Software Foundation, please see + * <http://www.apache.org/>. + */ + +/* + * $Id$ + * $Log$ + * Revision 1.1 2001/11/07 19:18:52 peiyongz + * DateTime Port + * + */ + +#if !defined(DURATION_DATATYPE_VALIDATOR_HPP) +#define DURATION_DATATYPE_VALIDATOR_HPP + +#include <validators/datatype/DateTimeValidator.hpp> + +class VALIDATORS_EXPORT DurationDatatypeValidator : public DateTimeValidator +{ +public: + + // ----------------------------------------------------------------------- + // Public ctor/dtor + // ----------------------------------------------------------------------- + /** @name Constructor. */ + //@{ + + DurationDatatypeValidator(); + + DurationDatatypeValidator(DatatypeValidator* const baseValidator + , RefHashTableOf<KVStringPair>* const facets + , RefVectorOf<XMLCh>* const enums + , const int finalSet); + + ~DurationDatatypeValidator(); + + + //@} + + /** + * Returns an instance of the base datatype validator class + * Used by the DatatypeValidatorFactory. + */ + virtual DatatypeValidator* newInstance(RefHashTableOf<KVStringPair>* const facets + , RefVectorOf<XMLCh>* const enums + , const int finalSet); + +protected: + + // ----------------------------------------------------------------------- + // implementation of (DateTimeValidator's) virtual interface + // ----------------------------------------------------------------------- + virtual XMLDateTime* parse(const XMLCh* const); + + virtual int compareDates(const XMLDateTime* const + , const XMLDateTime* const + , bool ); + +}; + +/** + * End of file DurationDatatypeValidator.hpp + */ +#endif + diff --git a/src/validators/datatype/Makefile.in b/src/validators/datatype/Makefile.in index 11c91f9221805ed7cf0f12804df38f680cfa3c76..99e9ecae755e5558473b5a5cff7030863dc46751 100644 --- a/src/validators/datatype/Makefile.in +++ b/src/validators/datatype/Makefile.in @@ -55,6 +55,9 @@ # # # $Log$ +# Revision 1.22 2001/11/07 19:18:52 peiyongz +# DateTime Port +# # Revision 1.21 2001/10/01 16:14:22 peiyongz # DTV Reorganization:new classes: AbstractNumericFactValidator/ AbstractNumericValidator # @@ -168,7 +171,17 @@ VALIDATORS_DATATYPE_CPP_PUBHEADERS = \ AnySimpleTypeDatatypeValidator.hpp \ AbstractNumericFacetValidator.hpp \ AbstractNumericValidator.hpp \ - AbstractStringValidator.hpp + AbstractStringValidator.hpp \ + DateTimeValidator.hpp \ + DateTimeDatatypeValidator.hpp \ + DateDatatypeValidator.hpp \ + TimeDatatypeValidator.hpp \ + DayDatatypeValidator.hpp \ + MonthDatatypeValidator.hpp \ + MonthDayDatatypeValidator.hpp \ + YearDatatypeValidator.hpp \ + YearMonthDatatypeValidator.hpp \ + DurationDatatypeValidator.hpp VALIDATORS_DATATYPE_CPP_PRIVHEADERS = @@ -197,7 +210,17 @@ VALIDATORS_DATATYPE_CPP_OBJECTS = \ AnySimpleTypeDatatypeValidator.$(TO) \ AbstractNumericFacetValidator.$(TO) \ AbstractNumericValidator.$(TO) \ - AbstractStringValidator.$(TO) + AbstractStringValidator.$(TO) \ + DateTimeValidator.$(TO) \ + DateTimeDatatypeValidator.$(TO) \ + DateDatatypeValidator.$(TO) \ + TimeDatatypeValidator.$(TO) \ + DayDatatypeValidator.$(TO) \ + MonthDatatypeValidator.$(TO) \ + MonthDayDatatypeValidator.$(TO) \ + YearDatatypeValidator.$(TO) \ + YearMonthDatatypeValidator.$(TO) \ + DurationDatatypeValidator.$(TO) all:: includes $(VALIDATORS_DATATYPE_CPP_OBJECTS) diff --git a/src/validators/datatype/MonthDatatypeValidator.cpp b/src/validators/datatype/MonthDatatypeValidator.cpp new file mode 100644 index 0000000000000000000000000000000000000000..3cedf106242c2b35ced52e87e8c4cd412ff76785 --- /dev/null +++ b/src/validators/datatype/MonthDatatypeValidator.cpp @@ -0,0 +1,121 @@ +/* + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2001 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. + * + * 4. The names "Xerces" and "Apache Software Foundation" must + * not be used to endorse or promote products derived from this + * software without prior written permission. For written + * permission, please contact apache\@apache.org. + * + * 5. Products derived from this software may not be called "Apache", + * nor may "Apache" appear in their name, without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation, and was + * originally based on software copyright (c) 2001, International + * Business Machines, Inc., http://www.ibm.com . For more information + * on the Apache Software Foundation, please see + * <http://www.apache.org/>. + */ + +/* + * $Id$ + * $Log$ + * Revision 1.1 2001/11/07 19:18:52 peiyongz + * DateTime Port + * + */ + +// --------------------------------------------------------------------------- +// Includes +// --------------------------------------------------------------------------- +#include <validators/datatype/MonthDatatypeValidator.hpp> + +// --------------------------------------------------------------------------- +// Constructors and Destructor +// --------------------------------------------------------------------------- +MonthDatatypeValidator::MonthDatatypeValidator() +:DateTimeValidator(0, 0, 0, DatatypeValidator::Month) +{} + +MonthDatatypeValidator::MonthDatatypeValidator( + DatatypeValidator* const baseValidator + , RefHashTableOf<KVStringPair>* const facets + , RefVectorOf<XMLCh>* const enums + , const int finalSet) +:DateTimeValidator(baseValidator, facets, finalSet, DatatypeValidator::Month) +{ + init(enums); +} + +MonthDatatypeValidator::~MonthDatatypeValidator() +{} + +DatatypeValidator* MonthDatatypeValidator::newInstance( + RefHashTableOf<KVStringPair>* const facets + , RefVectorOf<XMLCh>* const enums + , const int finalSet) +{ + return (DatatypeValidator*) new MonthDatatypeValidator(this, facets, enums, finalSet); +} + +// +// caller need to release the date created here +// +XMLDateTime* MonthDatatypeValidator::parse(const XMLCh* const content) +{ + XMLDateTime *pRetDate = new XMLDateTime(content); + + try + { + pRetDate->parseMonth(); + } + catch (...) + { + delete pRetDate; + throw; + } + + return pRetDate; +} + +/** + * End of file MonthDatatypeValidator::cpp + */ + diff --git a/src/validators/datatype/MonthDatatypeValidator.hpp b/src/validators/datatype/MonthDatatypeValidator.hpp new file mode 100644 index 0000000000000000000000000000000000000000..b635e6f15eb23d8ca1be4523bddaa222e851f530 --- /dev/null +++ b/src/validators/datatype/MonthDatatypeValidator.hpp @@ -0,0 +1,112 @@ +/* + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2001 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. + * + * 4. The names "Xerces" and "Apache Software Foundation" must + * not be used to endorse or promote products derived from this + * software without prior written permission. For written + * permission, please contact apache\@apache.org. + * + * 5. Products derived from this software may not be called "Apache", + * nor may "Apache" appear in their name, without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation, and was + * originally based on software copyright (c) 2001, International + * Business Machines, Inc., http://www.ibm.com . For more information + * on the Apache Software Foundation, please see + * <http://www.apache.org/>. + */ + +/* + * $Id$ + * $Log$ + * Revision 1.1 2001/11/07 19:18:52 peiyongz + * DateTime Port + * + */ + +#if !defined(MONTH_DATATYPE_VALIDATOR_HPP) +#define MONTH_DATATYPE_VALIDATOR_HPP + +#include <validators/datatype/DateTimeValidator.hpp> + +class VALIDATORS_EXPORT MonthDatatypeValidator : public DateTimeValidator +{ +public: + + // ----------------------------------------------------------------------- + // Public ctor/dtor + // ----------------------------------------------------------------------- + /** @name Constructor. */ + //@{ + + MonthDatatypeValidator(); + + MonthDatatypeValidator(DatatypeValidator* const baseValidator + , RefHashTableOf<KVStringPair>* const facets + , RefVectorOf<XMLCh>* const enums + , const int finalSet); + + ~MonthDatatypeValidator(); + + + //@} + + /** + * Returns an instance of the base datatype validator class + * Used by the DatatypeValidatorFactory. + */ + virtual DatatypeValidator* newInstance(RefHashTableOf<KVStringPair>* const facets + , RefVectorOf<XMLCh>* const enums + , const int finalSet); + +protected: + + // ----------------------------------------------------------------------- + // implementation of (DateTimeValidator's) virtual interface + // ----------------------------------------------------------------------- + virtual XMLDateTime* parse(const XMLCh* const); +}; + +/** + * End of file MonthDatatypeValidator.hpp + */ +#endif + diff --git a/src/validators/datatype/MonthDayDatatypeValidator.cpp b/src/validators/datatype/MonthDayDatatypeValidator.cpp new file mode 100644 index 0000000000000000000000000000000000000000..025953b7ecbe01ffda1bb0b21d66110c6eb3663e --- /dev/null +++ b/src/validators/datatype/MonthDayDatatypeValidator.cpp @@ -0,0 +1,121 @@ +/* + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2001 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. + * + * 4. The names "Xerces" and "Apache Software Foundation" must + * not be used to endorse or promote products derived from this + * software without prior written permission. For written + * permission, please contact apache\@apache.org. + * + * 5. Products derived from this software may not be called "Apache", + * nor may "Apache" appear in their name, without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation, and was + * originally based on software copyright (c) 2001, International + * Business Machines, Inc., http://www.ibm.com . For more information + * on the Apache Software Foundation, please see + * <http://www.apache.org/>. + */ + +/* + * $Id$ + * $Log$ + * Revision 1.1 2001/11/07 19:18:52 peiyongz + * DateTime Port + * + */ + +// --------------------------------------------------------------------------- +// Includes +// --------------------------------------------------------------------------- +#include <validators/datatype/MonthDayDatatypeValidator.hpp> + +// --------------------------------------------------------------------------- +// Constructors and Destructor +// --------------------------------------------------------------------------- +MonthDayDatatypeValidator::MonthDayDatatypeValidator() +:DateTimeValidator(0, 0, 0, DatatypeValidator::MonthDay) +{} + +MonthDayDatatypeValidator::MonthDayDatatypeValidator( + DatatypeValidator* const baseValidator + , RefHashTableOf<KVStringPair>* const facets + , RefVectorOf<XMLCh>* const enums + , const int finalSet) +:DateTimeValidator(baseValidator, facets, finalSet, DatatypeValidator::MonthDay) +{ + init(enums); +} + +MonthDayDatatypeValidator::~MonthDayDatatypeValidator() +{} + +DatatypeValidator* MonthDayDatatypeValidator::newInstance( + RefHashTableOf<KVStringPair>* const facets + , RefVectorOf<XMLCh>* const enums + , const int finalSet) +{ + return (DatatypeValidator*) new MonthDayDatatypeValidator(this, facets, enums, finalSet); +} + +// +// caller need to release the date created here +// +XMLDateTime* MonthDayDatatypeValidator::parse(const XMLCh* const content) +{ + XMLDateTime *pRetDate = new XMLDateTime(content); + + try + { + pRetDate->parseMonthDay(); + } + catch (...) + { + delete pRetDate; + throw; + } + + return pRetDate; +} + +/** + * End of file MonthDayDatatypeValidator::cpp + */ + diff --git a/src/validators/datatype/MonthDayDatatypeValidator.hpp b/src/validators/datatype/MonthDayDatatypeValidator.hpp new file mode 100644 index 0000000000000000000000000000000000000000..fc43428dca885d5b8f60b821a036af25dfdeba0f --- /dev/null +++ b/src/validators/datatype/MonthDayDatatypeValidator.hpp @@ -0,0 +1,112 @@ +/* + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2001 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. + * + * 4. The names "Xerces" and "Apache Software Foundation" must + * not be used to endorse or promote products derived from this + * software without prior written permission. For written + * permission, please contact apache\@apache.org. + * + * 5. Products derived from this software may not be called "Apache", + * nor may "Apache" appear in their name, without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation, and was + * originally based on software copyright (c) 2001, International + * Business Machines, Inc., http://www.ibm.com . For more information + * on the Apache Software Foundation, please see + * <http://www.apache.org/>. + */ + +/* + * $Id$ + * $Log$ + * Revision 1.1 2001/11/07 19:18:52 peiyongz + * DateTime Port + * + */ + +#if !defined(MONTHDAY_DATATYPE_VALIDATOR_HPP) +#define MONTHDAY_DATATYPE_VALIDATOR_HPP + +#include <validators/datatype/DateTimeValidator.hpp> + +class VALIDATORS_EXPORT MonthDayDatatypeValidator : public DateTimeValidator +{ +public: + + // ----------------------------------------------------------------------- + // Public ctor/dtor + // ----------------------------------------------------------------------- + /** @name Constructor. */ + //@{ + + MonthDayDatatypeValidator(); + + MonthDayDatatypeValidator(DatatypeValidator* const baseValidator + , RefHashTableOf<KVStringPair>* const facets + , RefVectorOf<XMLCh>* const enums + , const int finalSet); + + ~MonthDayDatatypeValidator(); + + + //@} + + /** + * Returns an instance of the base datatype validator class + * Used by the DatatypeValidatorFactory. + */ + virtual DatatypeValidator* newInstance(RefHashTableOf<KVStringPair>* const facets + , RefVectorOf<XMLCh>* const enums + , const int finalSet); + +protected: + + // ----------------------------------------------------------------------- + // implementation of (DateTimeValidator's) virtual interface + // ----------------------------------------------------------------------- + virtual XMLDateTime* parse(const XMLCh* const); +}; + +/** + * End of file MonthDayDatatypeValidator.hpp + */ +#endif + diff --git a/src/validators/datatype/TimeDatatypeValidator.cpp b/src/validators/datatype/TimeDatatypeValidator.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f906b8bfed65deebcc34123f499db7509be39c4e --- /dev/null +++ b/src/validators/datatype/TimeDatatypeValidator.cpp @@ -0,0 +1,121 @@ +/* + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2001 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. + * + * 4. The names "Xerces" and "Apache Software Foundation" must + * not be used to endorse or promote products derived from this + * software without prior written permission. For written + * permission, please contact apache\@apache.org. + * + * 5. Products derived from this software may not be called "Apache", + * nor may "Apache" appear in their name, without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation, and was + * originally based on software copyright (c) 2001, International + * Business Machines, Inc., http://www.ibm.com . For more information + * on the Apache Software Foundation, please see + * <http://www.apache.org/>. + */ + +/* + * $Id$ + * $Log$ + * Revision 1.1 2001/11/07 19:18:52 peiyongz + * DateTime Port + * + */ + +// --------------------------------------------------------------------------- +// Includes +// --------------------------------------------------------------------------- +#include <validators/datatype/TimeDatatypeValidator.hpp> + +// --------------------------------------------------------------------------- +// Constructors and Destructor +// --------------------------------------------------------------------------- +TimeDatatypeValidator::TimeDatatypeValidator() +:DateTimeValidator(0, 0, 0, DatatypeValidator::Time) +{} + +TimeDatatypeValidator::TimeDatatypeValidator( + DatatypeValidator* const baseValidator + , RefHashTableOf<KVStringPair>* const facets + , RefVectorOf<XMLCh>* const enums + , const int finalSet) +:DateTimeValidator(baseValidator, facets, finalSet, DatatypeValidator::Time) +{ + init(enums); +} + +TimeDatatypeValidator::~TimeDatatypeValidator() +{} + +DatatypeValidator* TimeDatatypeValidator::newInstance( + RefHashTableOf<KVStringPair>* const facets + , RefVectorOf<XMLCh>* const enums + , const int finalSet) +{ + return (DatatypeValidator*) new TimeDatatypeValidator(this, facets, enums, finalSet); +} + +// +// caller need to release the date created here +// +XMLDateTime* TimeDatatypeValidator::parse(const XMLCh* const content) +{ + XMLDateTime *pRetDate = new XMLDateTime(content); + + try + { + pRetDate->parseTime(); + } + catch (...) + { + delete pRetDate; + throw; + } + + return pRetDate; +} + +/** + * End of file TimeDatatypeValidator::cpp + */ + diff --git a/src/validators/datatype/TimeDatatypeValidator.hpp b/src/validators/datatype/TimeDatatypeValidator.hpp new file mode 100644 index 0000000000000000000000000000000000000000..8299ac59bbada940e2b22ed0301b6904de3037b0 --- /dev/null +++ b/src/validators/datatype/TimeDatatypeValidator.hpp @@ -0,0 +1,113 @@ +/* + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2001 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. + * + * 4. The names "Xerces" and "Apache Software Foundation" must + * not be used to endorse or promote products derived from this + * software without prior written permission. For written + * permission, please contact apache\@apache.org. + * + * 5. Products derived from this software may not be called "Apache", + * nor may "Apache" appear in their name, without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation, and was + * originally based on software copyright (c) 2001, International + * Business Machines, Inc., http://www.ibm.com . For more information + * on the Apache Software Foundation, please see + * <http://www.apache.org/>. + */ + +/* + * $Id$ + * $Log$ + * Revision 1.1 2001/11/07 19:18:52 peiyongz + * DateTime Port + * + */ + +#if !defined(TIME_DATATYPE_VALIDATOR_HPP) +#define TIME_DATATYPE_VALIDATOR_HPP + +#include <validators/datatype/DateTimeValidator.hpp> +#include <util/RefVectorOf.hpp> + +class VALIDATORS_EXPORT TimeDatatypeValidator : public DateTimeValidator +{ +public: + + // ----------------------------------------------------------------------- + // Public ctor/dtor + // ----------------------------------------------------------------------- + /** @name Constructor. */ + //@{ + + TimeDatatypeValidator(); + + TimeDatatypeValidator(DatatypeValidator* const baseValidator + , RefHashTableOf<KVStringPair>* const facets + , RefVectorOf<XMLCh>* const enums + , const int finalSet); + + ~TimeDatatypeValidator(); + + + //@} + + /** + * Returns an instance of the base datatype validator class + * Used by the DatatypeValidatorFactory. + */ + virtual DatatypeValidator* newInstance(RefHashTableOf<KVStringPair>* const facets + , RefVectorOf<XMLCh>* const enums + , const int finalSet); + +protected: + + // ----------------------------------------------------------------------- + // implementation of (DateTimeValidator's) virtual interface + // ----------------------------------------------------------------------- + virtual XMLDateTime* parse(const XMLCh* const); +}; + +/** + * End of file TimeDatatypeValidator.hpp + */ +#endif + diff --git a/src/validators/datatype/YearDatatypeValidator.cpp b/src/validators/datatype/YearDatatypeValidator.cpp new file mode 100644 index 0000000000000000000000000000000000000000..3a7b369800acf9dc45c1ef532e4a82a09577a855 --- /dev/null +++ b/src/validators/datatype/YearDatatypeValidator.cpp @@ -0,0 +1,121 @@ +/* + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2001 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. + * + * 4. The names "Xerces" and "Apache Software Foundation" must + * not be used to endorse or promote products derived from this + * software without prior written permission. For written + * permission, please contact apache\@apache.org. + * + * 5. Products derived from this software may not be called "Apache", + * nor may "Apache" appear in their name, without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation, and was + * originally based on software copyright (c) 2001, International + * Business Machines, Inc., http://www.ibm.com . For more information + * on the Apache Software Foundation, please see + * <http://www.apache.org/>. + */ + +/* + * $Id$ + * $Log$ + * Revision 1.1 2001/11/07 19:18:52 peiyongz + * DateTime Port + * + */ + +// --------------------------------------------------------------------------- +// Includes +// --------------------------------------------------------------------------- +#include <validators/datatype/YearDatatypeValidator.hpp> + +// --------------------------------------------------------------------------- +// Constructors and Destructor +// --------------------------------------------------------------------------- +YearDatatypeValidator::YearDatatypeValidator() +:DateTimeValidator(0, 0, 0, DatatypeValidator::Year) +{} + +YearDatatypeValidator::YearDatatypeValidator( + DatatypeValidator* const baseValidator + , RefHashTableOf<KVStringPair>* const facets + , RefVectorOf<XMLCh>* const enums + , const int finalSet) +:DateTimeValidator(baseValidator, facets, finalSet, DatatypeValidator::Year) +{ + init(enums); +} + +YearDatatypeValidator::~YearDatatypeValidator() +{} + +DatatypeValidator* YearDatatypeValidator::newInstance( + RefHashTableOf<KVStringPair>* const facets + , RefVectorOf<XMLCh>* const enums + , const int finalSet) +{ + return (DatatypeValidator*) new YearDatatypeValidator(this, facets, enums, finalSet); +} + +// +// caller need to release the date created here +// +XMLDateTime* YearDatatypeValidator::parse(const XMLCh* const content) +{ + XMLDateTime *pRetDate = new XMLDateTime(content); + + try + { + pRetDate->parseYear(); + } + catch (...) + { + delete pRetDate; + throw; + } + + return pRetDate; +} + +/** + * End of file YearDatatypeValidator::cpp + */ + diff --git a/src/validators/datatype/YearDatatypeValidator.hpp b/src/validators/datatype/YearDatatypeValidator.hpp new file mode 100644 index 0000000000000000000000000000000000000000..fef0f3caa5f551ba9f1e4b6f083e5b745ca068de --- /dev/null +++ b/src/validators/datatype/YearDatatypeValidator.hpp @@ -0,0 +1,112 @@ +/* + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2001 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. + * + * 4. The names "Xerces" and "Apache Software Foundation" must + * not be used to endorse or promote products derived from this + * software without prior written permission. For written + * permission, please contact apache\@apache.org. + * + * 5. Products derived from this software may not be called "Apache", + * nor may "Apache" appear in their name, without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation, and was + * originally based on software copyright (c) 2001, International + * Business Machines, Inc., http://www.ibm.com . For more information + * on the Apache Software Foundation, please see + * <http://www.apache.org/>. + */ + +/* + * $Id$ + * $Log$ + * Revision 1.1 2001/11/07 19:18:52 peiyongz + * DateTime Port + * + */ + +#if !defined(YEAR_DATATYPE_VALIDATOR_HPP) +#define YEAR_DATATYPE_VALIDATOR_HPP + +#include <validators/datatype/DateTimeValidator.hpp> + +class VALIDATORS_EXPORT YearDatatypeValidator : public DateTimeValidator +{ +public: + + // ----------------------------------------------------------------------- + // Public ctor/dtor + // ----------------------------------------------------------------------- + /** @name Constructor. */ + //@{ + + YearDatatypeValidator(); + + YearDatatypeValidator(DatatypeValidator* const baseValidator + , RefHashTableOf<KVStringPair>* const facets + , RefVectorOf<XMLCh>* const enums + , const int finalSet); + + ~YearDatatypeValidator(); + + + //@} + + /** + * Returns an instance of the base datatype validator class + * Used by the DatatypeValidatorFactory. + */ + virtual DatatypeValidator* newInstance(RefHashTableOf<KVStringPair>* const facets + , RefVectorOf<XMLCh>* const enums + , const int finalSet); + +protected: + + // ----------------------------------------------------------------------- + // implementation of (DateTimeValidator's) virtual interface + // ----------------------------------------------------------------------- + virtual XMLDateTime* parse(const XMLCh* const); +}; + +/** + * End of file YearDatatypeValidator.hpp + */ +#endif + diff --git a/src/validators/datatype/YearMonthDatatypeValidator.cpp b/src/validators/datatype/YearMonthDatatypeValidator.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8c4dd2ccf957fcfc6bdd9c72eec706711e84018e --- /dev/null +++ b/src/validators/datatype/YearMonthDatatypeValidator.cpp @@ -0,0 +1,121 @@ +/* + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2001 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. + * + * 4. The names "Xerces" and "Apache Software Foundation" must + * not be used to endorse or promote products derived from this + * software without prior written permission. For written + * permission, please contact apache\@apache.org. + * + * 5. Products derived from this software may not be called "Apache", + * nor may "Apache" appear in their name, without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation, and was + * originally based on software copyright (c) 2001, International + * Business Machines, Inc., http://www.ibm.com . For more information + * on the Apache Software Foundation, please see + * <http://www.apache.org/>. + */ + +/* + * $Id$ + * $Log$ + * Revision 1.1 2001/11/07 19:18:52 peiyongz + * DateTime Port + * + */ + +// --------------------------------------------------------------------------- +// Includes +// --------------------------------------------------------------------------- +#include <validators/datatype/YearMonthDatatypeValidator.hpp> + +// --------------------------------------------------------------------------- +// Constructors and Destructor +// --------------------------------------------------------------------------- +YearMonthDatatypeValidator::YearMonthDatatypeValidator() +:DateTimeValidator(0, 0, 0, DatatypeValidator::YearMonth) +{} + +YearMonthDatatypeValidator::YearMonthDatatypeValidator( + DatatypeValidator* const baseValidator + , RefHashTableOf<KVStringPair>* const facets + , RefVectorOf<XMLCh>* const enums + , const int finalSet) +:DateTimeValidator(baseValidator, facets, finalSet, DatatypeValidator::YearMonth) +{ + init(enums); +} + +YearMonthDatatypeValidator::~YearMonthDatatypeValidator() +{} + +DatatypeValidator* YearMonthDatatypeValidator::newInstance( + RefHashTableOf<KVStringPair>* const facets + , RefVectorOf<XMLCh>* const enums + , const int finalSet) +{ + return (DatatypeValidator*) new YearMonthDatatypeValidator(this, facets, enums, finalSet); +} + +// +// caller need to release the date created here +// +XMLDateTime* YearMonthDatatypeValidator::parse(const XMLCh* const content) +{ + XMLDateTime *pRetDate = new XMLDateTime(content); + + try + { + pRetDate->parseYearMonth(); + } + catch (...) + { + delete pRetDate; + throw; + } + + return pRetDate; +} + +/** + * End of file YearMonthDatatypeValidator::cpp + */ + diff --git a/src/validators/datatype/YearMonthDatatypeValidator.hpp b/src/validators/datatype/YearMonthDatatypeValidator.hpp new file mode 100644 index 0000000000000000000000000000000000000000..c6746857faf1dd035c7b7856a0d3245726cf2023 --- /dev/null +++ b/src/validators/datatype/YearMonthDatatypeValidator.hpp @@ -0,0 +1,112 @@ +/* + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2001 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. + * + * 4. The names "Xerces" and "Apache Software Foundation" must + * not be used to endorse or promote products derived from this + * software without prior written permission. For written + * permission, please contact apache\@apache.org. + * + * 5. Products derived from this software may not be called "Apache", + * nor may "Apache" appear in their name, without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation, and was + * originally based on software copyright (c) 2001, International + * Business Machines, Inc., http://www.ibm.com . For more information + * on the Apache Software Foundation, please see + * <http://www.apache.org/>. + */ + +/* + * $Id$ + * $Log$ + * Revision 1.1 2001/11/07 19:18:52 peiyongz + * DateTime Port + * + */ + +#if !defined(YEARMONTH_DATATYPE_VALIDATOR_HPP) +#define YEARMONTH_DATATYPE_VALIDATOR_HPP + +#include <validators/datatype/DateTimeValidator.hpp> + +class VALIDATORS_EXPORT YearMonthDatatypeValidator : public DateTimeValidator +{ +public: + + // ----------------------------------------------------------------------- + // Public ctor/dtor + // ----------------------------------------------------------------------- + /** @name Constructor. */ + //@{ + + YearMonthDatatypeValidator(); + + YearMonthDatatypeValidator(DatatypeValidator* const baseValidator + , RefHashTableOf<KVStringPair>* const facets + , RefVectorOf<XMLCh>* const enums + , const int finalSet); + + ~YearMonthDatatypeValidator(); + + + //@} + + /** + * Returns an instance of the base datatype validator class + * Used by the DatatypeValidatorFactory. + */ + virtual DatatypeValidator* newInstance(RefHashTableOf<KVStringPair>* const facets + , RefVectorOf<XMLCh>* const enums + , const int finalSet); + +protected: + + // ----------------------------------------------------------------------- + // implementation of (DateTimeValidator's) virtual interface + // ----------------------------------------------------------------------- + virtual XMLDateTime* parse(const XMLCh* const); +}; + +/** + * End of file YearMonthDatatypeValidator.hpp + */ +#endif + diff --git a/src/validators/schema/SchemaSymbols.cpp b/src/validators/schema/SchemaSymbols.cpp index a3c64f66ec402608341231d53e504feeb47dea1e..070e7ce722fcecded1129bb9bb2509cc51f8505f 100644 --- a/src/validators/schema/SchemaSymbols.cpp +++ b/src/validators/schema/SchemaSymbols.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.14 2001/11/07 19:20:01 peiyongz + * DateTime Port + * * Revision 1.13 2001/09/18 14:41:56 knoaman * Add support for <annotation>. * @@ -972,55 +975,53 @@ const XMLCh SchemaSymbols::fgDT_POSITIVEINTEGER[] = chLatin_g, chLatin_e, chLatin_r, chNull }; -const XMLCh SchemaSymbols::fgDT_RECURRINGDURATION[] = +const XMLCh SchemaSymbols::fgDT_DATETIME[] = { - chLatin_r, chLatin_e, chLatin_c, chLatin_u, chLatin_r, chLatin_r, - chLatin_i, chLatin_n, chLatin_g, chLatin_D, chLatin_u, chLatin_r, - chLatin_a, chLatin_t, chLatin_i, chLatin_o, chLatin_n, chNull + chLatin_d, chLatin_a, chLatin_t, chLatin_e, + chLatin_T, chLatin_i, chLatin_m, chLatin_e, chNull }; -const XMLCh SchemaSymbols::fgDT_TIMEINSTANT[] = +const XMLCh SchemaSymbols::fgDT_DATE[] = { - chLatin_t, chLatin_i, chLatin_m, chLatin_e, chLatin_I, chLatin_n, - chLatin_s, chLatin_t, chLatin_a, chLatin_n, chLatin_t, chNull + chLatin_d, chLatin_a, chLatin_t, chLatin_e, chNull }; -const XMLCh SchemaSymbols::fgDT_TIMEPERIOD[] = +const XMLCh SchemaSymbols::fgDT_TIME[] = { - chLatin_t, chLatin_i, chLatin_m, chLatin_e, chLatin_P, chLatin_e, - chLatin_r, chLatin_i, chLatin_o, chLatin_d, chNull + chLatin_t, chLatin_i, chLatin_m, chLatin_e, chNull }; -const XMLCh SchemaSymbols::fgDT_DATE[] = +const XMLCh SchemaSymbols::fgDT_DURATION[] = { - chLatin_d, chLatin_a, chLatin_t, chLatin_e, chNull + chLatin_d, chLatin_u, chLatin_r, chLatin_a, + chLatin_t, chLatin_i, chLatin_o, chLatin_n, chNull }; -const XMLCh SchemaSymbols::fgDT_MONTH[] = +const XMLCh SchemaSymbols::fgDT_DAY[] = { - chLatin_m, chLatin_o, chLatin_n, chLatin_t, chLatin_h, chNull + chLatin_g, chLatin_D, chLatin_a, chLatin_y, chNull }; -const XMLCh SchemaSymbols::fgDT_YEAR[] = +const XMLCh SchemaSymbols::fgDT_MONTH[] = { - chLatin_y, chLatin_e, chLatin_a, chLatin_r, chNull + chLatin_g, chLatin_M, chLatin_o, chLatin_n, chLatin_t, chLatin_h, chNull }; -const XMLCh SchemaSymbols::fgDT_CENTURY[] = +const XMLCh SchemaSymbols::fgDT_MONTHDAY[] = { - chLatin_c, chLatin_e, chLatin_n, chLatin_t, chLatin_u, chLatin_r, chLatin_y, chNull + chLatin_g, chLatin_M, chLatin_o, chLatin_n, chLatin_t, chLatin_h, + chLatin_D, chLatin_a, chLatin_y, chNull }; -const XMLCh SchemaSymbols::fgDT_RECURRINGDATE[] = +const XMLCh SchemaSymbols::fgDT_YEAR[] = { - chLatin_r, chLatin_e, chLatin_c, chLatin_u, chLatin_r, chLatin_r, chLatin_i, - chLatin_n, chLatin_g, chLatin_D, chLatin_a, chLatin_t, chLatin_e, chNull + chLatin_g, chLatin_Y, chLatin_e, chLatin_a, chLatin_r, chNull }; -const XMLCh SchemaSymbols::fgDT_TIMEDURATION[] = +const XMLCh SchemaSymbols::fgDT_YEARMONTH[] = { - chLatin_t, chLatin_i, chLatin_m, chLatin_e, chLatin_D, chLatin_u, - chLatin_r, chLatin_a, chLatin_t, chLatin_i, chLatin_o, chLatin_n, chNull + chLatin_g, chLatin_Y, chLatin_e, chLatin_a, chLatin_r, + chLatin_M, chLatin_o, chLatin_n, chLatin_t, chLatin_h, chNull }; const XMLCh SchemaSymbols::fgDT_BASE64BINARY[] = diff --git a/src/validators/schema/SchemaSymbols.hpp b/src/validators/schema/SchemaSymbols.hpp index a808b791bcd33f6871dc663ea16c18148eb8d982..ddac6ae6512a28795703201a1f20321250a4dc78 100644 --- a/src/validators/schema/SchemaSymbols.hpp +++ b/src/validators/schema/SchemaSymbols.hpp @@ -223,15 +223,17 @@ public : static const XMLCh fgDT_USHORT[]; static const XMLCh fgDT_UBYTE[]; static const XMLCh fgDT_POSITIVEINTEGER[]; - static const XMLCh fgDT_RECURRINGDURATION[]; - static const XMLCh fgDT_TIMEINSTANT[]; - static const XMLCh fgDT_TIMEPERIOD[]; +//datetime + static const XMLCh fgDT_DATETIME[]; static const XMLCh fgDT_DATE[]; + static const XMLCh fgDT_TIME[]; + static const XMLCh fgDT_DURATION[]; + static const XMLCh fgDT_DAY[]; static const XMLCh fgDT_MONTH[]; + static const XMLCh fgDT_MONTHDAY[]; static const XMLCh fgDT_YEAR[]; - static const XMLCh fgDT_CENTURY[]; - static const XMLCh fgDT_RECURRINGDATE[]; - static const XMLCh fgDT_TIMEDURATION[]; + static const XMLCh fgDT_YEARMONTH[]; + static const XMLCh fgDT_BASE64BINARY[]; static const XMLCh fgDT_HEXBINARY[]; static const XMLCh fgDT_FLOAT[];