AbstractNumericFacetValidator.cpp
上传用户:zhuqijet
上传日期:2013-06-25
资源大小:10074k
文件大小:31k
源码类别:

词法分析

开发平台:

Visual C++

  1. /*
  2.  * The Apache Software License, Version 1.1
  3.  *
  4.  * Copyright (c) 2001 The Apache Software Foundation.  All rights
  5.  * reserved.
  6.  *
  7.  * Redistribution and use in source and binary forms, with or without
  8.  * modification, are permitted provided that the following conditions
  9.  * are met:
  10.  *
  11.  * 1. Redistributions of source code must retain the above copyright
  12.  *    notice, this list of conditions and the following disclaimer.
  13.  *
  14.  * 2. Redistributions in binary form must reproduce the above copyright
  15.  *    notice, this list of conditions and the following disclaimer in
  16.  *    the documentation and/or other materials provided with the
  17.  *    distribution.
  18.  *
  19.  * 3. The end-user documentation included with the redistribution,
  20.  *    if any, must include the following acknowledgment:
  21.  *       "This product includes software developed by the
  22.  *        Apache Software Foundation (http://www.apache.org/)."
  23.  *    Alternately, this acknowledgment may appear in the software itself,
  24.  *    if and wherever such third-party acknowledgments normally appear.
  25.  *
  26.  * 4. The names "Xerces" and "Apache Software Foundation" must
  27.  *    not be used to endorse or promote products derived from this
  28.  *    software without prior written permission. For written
  29.  *    permission, please contact apache@apache.org.
  30.  *
  31.  * 5. Products derived from this software may not be called "Apache",
  32.  *    nor may "Apache" appear in their name, without prior written
  33.  *    permission of the Apache Software Foundation.
  34.  *
  35.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  36.  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  37.  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  38.  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  39.  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  40.  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  41.  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  42.  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  43.  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  44.  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  45.  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  46.  * SUCH DAMAGE.
  47.  * ====================================================================
  48.  *
  49.  * This software consists of voluntary contributions made by many
  50.  * individuals on behalf of the Apache Software Foundation, and was
  51.  * originally based on software copyright (c) 2001, International
  52.  * Business Machines, Inc., http://www.ibm.com .  For more information
  53.  * on the Apache Software Foundation, please see
  54.  * <http://www.apache.org/>.
  55.  */
  56. /*
  57.  * $Id: AbstractNumericFacetValidator.cpp,v 1.12 2003/05/15 18:53:26 knoaman Exp $
  58.  * $Log: AbstractNumericFacetValidator.cpp,v $
  59.  * Revision 1.12  2003/05/15 18:53:26  knoaman
  60.  * Partial implementation of the configurable memory manager.
  61.  *
  62.  * Revision 1.11  2003/02/03 16:34:35  peiyongz
  63.  * fix to misplaced derived and base value in error message.
  64.  *
  65.  * Revision 1.10  2003/02/02 23:55:40  peiyongz
  66.  * getFormattedString() added to return original and converted value.
  67.  *
  68.  * Revision 1.9  2003/01/30 21:56:22  tng
  69.  * Performance: call getRawData instead of toString
  70.  *
  71.  * Revision 1.8  2003/01/25 16:33:25  peiyongz
  72.  * wrong error code.
  73.  *
  74.  * Revision 1.7  2002/12/18 14:17:55  gareth
  75.  * Fix to bug #13438. When you eant a vector that calls delete[] on its members you should use RefArrayVectorOf.
  76.  *
  77.  * Revision 1.6  2002/11/26 22:19:15  peiyongz
  78.  * Schema Errata E2-16 maxExclusive
  79.  *
  80.  * Revision 1.5  2002/11/04 14:53:27  tng
  81.  * C++ Namespace Support.
  82.  *
  83.  * Revision 1.4  2002/09/24 19:44:40  tng
  84.  * Performance: use XMLString::equals instead of XMLString::compareString
  85.  *
  86.  * Revision 1.3  2002/04/01 20:17:46  peiyongz
  87.  * Bug#7551: Exceptions are caught by value, rather than by reference
  88.  *
  89.  * Revision 1.2  2002/02/14 15:17:31  peiyongz
  90.  * getEnumString()
  91.  *
  92.  * Revision 1.1.1.1  2002/02/01 22:22:39  peiyongz
  93.  * sane_include
  94.  *
  95.  * Revision 1.6  2001/12/13 16:48:29  peiyongz
  96.  * Avoid dangling pointer
  97.  *
  98.  * Revision 1.5  2001/12/10 22:13:21  peiyongz
  99.  * swap checking to avoid "dangling pointer" reported by BoundsChecker
  100.  *
  101.  * Revision 1.4  2001/11/12 20:37:57  peiyongz
  102.  * SchemaDateTimeException defined
  103.  *
  104.  * Revision 1.3  2001/10/16 16:29:34  tng
  105.  * Schema: Fix Typo
  106.  *
  107.  * Revision 1.2  2001/10/09 21:17:41  peiyongz
  108.  * . macro to simplify code
  109.  * .save get***() to temp vars.
  110.  *
  111.  * Revision 1.1  2001/10/01 16:13:56  peiyongz
  112.  * DTV Reorganization:new classes: AbstractNumericFactValidator/ AbstractNumericValidator
  113.  *
  114.  */
  115. // ---------------------------------------------------------------------------
  116. //  Includes
  117. // ---------------------------------------------------------------------------
  118. #include <xercesc/validators/datatype/AbstractNumericFacetValidator.hpp>
  119. #include <xercesc/validators/datatype/InvalidDatatypeFacetException.hpp>
  120. #include <xercesc/util/NumberFormatException.hpp>
  121. XERCES_CPP_NAMESPACE_BEGIN
  122. const int AbstractNumericFacetValidator::INDETERMINATE = 2;
  123. #define  REPORT_FACET_ERROR(val1, val2, except_code)    
  124.   ThrowXML2(InvalidDatatypeFacetException               
  125.           , except_code                                 
  126.           , val1->getFormattedString()                  
  127.           , val2->getFormattedString());
  128. #define  FROM_BASE_VALUE_SPACE(val, facetFlag, except_code)   
  129.   if ((thisFacetsDefined & facetFlag) != 0)                   
  130. {                                                             
  131.     try                                                       
  132. {                                                             
  133.         numBase->checkContent(val->getRawData(), false);      
  134. }                                                             
  135.     catch ( XMLException& )                                   
  136. {                                                             
  137.         ThrowXML1(InvalidDatatypeFacetException               
  138.                 , except_code                                 
  139.                 , val->getRawData());                         
  140. }                                                             
  141. }
  142. // ---------------------------------------------------------------------------
  143. //  Constructors and Destructor
  144. // ---------------------------------------------------------------------------
  145. AbstractNumericFacetValidator::~AbstractNumericFacetValidator()
  146. {
  147.     if (!fMaxInclusiveInherited && fMaxInclusive)
  148.         delete fMaxInclusive;
  149.     if (!fMaxExclusiveInherited && fMaxExclusive)
  150.         delete fMaxExclusive;
  151.     if (!fMinInclusiveInherited && fMinInclusive)
  152.         delete fMinInclusive;
  153.     if (!fMinExclusiveInherited && fMinExclusive)
  154.         delete fMinExclusive;
  155.     //~RefVectorOf will delete all adopted elements
  156.     if (!fEnumerationInherited &&  fEnumeration)
  157.         delete fEnumeration;
  158.     if (!fEnumerationInherited &&  fStrEnumeration)
  159.         delete fStrEnumeration;
  160. }
  161. AbstractNumericFacetValidator::AbstractNumericFacetValidator(
  162.                           DatatypeValidator*            const baseValidator
  163.                         , RefHashTableOf<KVStringPair>* const facets
  164.                         , const int                           finalSet
  165.                         , const ValidatorType                 type
  166.                         , MemoryManager* const                manager)
  167. :DatatypeValidator(baseValidator, facets, finalSet, type, manager)
  168. , fMaxInclusiveInherited(false)
  169. , fMaxExclusiveInherited(false)
  170. , fMinInclusiveInherited(false)
  171. , fMinExclusiveInherited(false)
  172. , fEnumerationInherited(false)
  173. , fMaxInclusive(0)
  174. , fMaxExclusive(0)
  175. , fMinInclusive(0)
  176. , fMinExclusive(0)
  177. , fEnumeration(0)
  178. , fStrEnumeration(0)
  179. {
  180.     //do not invoke init() here !!!
  181. }
  182. //
  183. //  P1. Enumeration
  184. //
  185. void AbstractNumericFacetValidator::init(RefArrayVectorOf<XMLCh>* const enums)
  186. {
  187.     fStrEnumeration = enums; // save the literal value
  188.                          // which is needed for getEnumString()
  189.     if (enums)
  190.     {
  191.         setFacetsDefined(DatatypeValidator::FACET_ENUMERATION);
  192.     }
  193.     assignFacet();
  194.     inspectFacet();
  195.     inspectFacetBase();
  196.     inheritFacet();
  197. }
  198. //
  199. //   Assign facets
  200. //        assign common facets
  201. //        assign additional facet
  202. //
  203. void AbstractNumericFacetValidator::assignFacet()
  204. {
  205.     RefHashTableOf<KVStringPair>* facets = getFacets();
  206.     if (!facets)     // no facets defined
  207.         return;
  208.     XMLCh* key;
  209.     XMLCh* value;
  210.     RefHashTableOfEnumerator<KVStringPair> e(facets);
  211.     while (e.hasMoreElements())
  212.     {
  213.         KVStringPair pair = e.nextElement();
  214.         key = pair.getKey();
  215.         value = pair.getValue();
  216.         if (XMLString::equals(key, SchemaSymbols::fgELT_PATTERN))
  217.         {
  218.             setPattern(value);
  219.             if (getPattern())
  220.                 setFacetsDefined(DatatypeValidator::FACET_PATTERN);
  221.             // do not construct regex until needed
  222.         }
  223.         else if (XMLString::equals(key, SchemaSymbols::fgELT_MAXINCLUSIVE))
  224.         {
  225.             try
  226.             {
  227.                 setMaxInclusive(value);
  228.             }
  229.             catch (NumberFormatException&)
  230.             {
  231.                 ThrowXML1(InvalidDatatypeFacetException, XMLExcepts::FACET_Invalid_MaxIncl, value);
  232.             }
  233.             setFacetsDefined(DatatypeValidator::FACET_MAXINCLUSIVE);
  234.         }
  235.         else if (XMLString::equals(key, SchemaSymbols::fgELT_MAXEXCLUSIVE))
  236.         {
  237.             try
  238.             {
  239.                 setMaxExclusive(value);
  240.             }
  241.             catch (NumberFormatException&)
  242.             {
  243.                 ThrowXML1(InvalidDatatypeFacetException, XMLExcepts::FACET_Invalid_MaxExcl, value);
  244.             }
  245.             setFacetsDefined(DatatypeValidator::FACET_MAXEXCLUSIVE);
  246.         }
  247.         else if (XMLString::equals(key, SchemaSymbols::fgELT_MININCLUSIVE))
  248.         {
  249.             try
  250.             {
  251.                 setMinInclusive(value);
  252.             }
  253.             catch (NumberFormatException&)
  254.             {
  255.                 ThrowXML1(InvalidDatatypeFacetException, XMLExcepts::FACET_Invalid_MinIncl, value);
  256.             }
  257.             setFacetsDefined(DatatypeValidator::FACET_MININCLUSIVE);
  258.         }
  259.         else if (XMLString::equals(key, SchemaSymbols::fgELT_MINEXCLUSIVE))
  260.         {
  261.             try
  262.             {
  263.                 setMinExclusive(value);
  264.             }
  265.             catch (NumberFormatException&)
  266.             {
  267.                 ThrowXML1(InvalidDatatypeFacetException, XMLExcepts::FACET_Invalid_MinExcl, value);
  268.             }
  269.             setFacetsDefined(DatatypeValidator::FACET_MINEXCLUSIVE);
  270.         }
  271.         else if (XMLString::equals(key, SchemaSymbols::fgATT_FIXED))
  272.         {
  273.             unsigned int val;
  274.             bool         retStatus;
  275.             try
  276.             {
  277.                 retStatus = XMLString::textToBin(value, val);
  278.             }
  279.             catch (RuntimeException&)
  280.             {
  281.                 ThrowXML(InvalidDatatypeFacetException, XMLExcepts::FACET_internalError_fixed);
  282.             }
  283.             if (!retStatus)
  284.             {
  285.                 ThrowXML(InvalidDatatypeFacetException, XMLExcepts::FACET_internalError_fixed);
  286.             }
  287.             setFixed(val);
  288.             //no setFacetsDefined here
  289.         }
  290.         else
  291.         {
  292.             assignAdditionalFacet(key, value);
  293.         }
  294.     }//while
  295. }// end of assigneFacet()
  296. //
  297. // Check facet among self
  298. //         check common facets
  299. //         check Additional Facet Constraint
  300. //
  301. void AbstractNumericFacetValidator::inspectFacet()
  302. {
  303.     int thisFacetsDefined = getFacetsDefined();
  304.     XMLNumber *thisMaxInclusive = getMaxInclusive();
  305.     XMLNumber *thisMaxExclusive = getMaxExclusive();
  306.     XMLNumber *thisMinInclusive = getMinInclusive();
  307.     XMLNumber *thisMinExclusive = getMinExclusive();
  308.     if (!thisFacetsDefined)
  309.         return;
  310.     // non co-existence checking
  311.     // check 4.3.8.c1 error: maxInclusive + maxExclusive
  312.     if (((thisFacetsDefined & DatatypeValidator::FACET_MAXEXCLUSIVE) != 0) &&
  313.         ((thisFacetsDefined & DatatypeValidator::FACET_MAXINCLUSIVE) != 0) )
  314.         ThrowXML(InvalidDatatypeFacetException, XMLExcepts::FACET_max_Incl_Excl);
  315.     // non co-existence checking
  316.     // check 4.3.9.c1 error: minInclusive + minExclusive
  317.     if (((thisFacetsDefined & DatatypeValidator::FACET_MINEXCLUSIVE) != 0) &&
  318.         ((thisFacetsDefined & DatatypeValidator::FACET_MININCLUSIVE) != 0) )
  319.         ThrowXML(InvalidDatatypeFacetException, XMLExcepts::FACET_min_Incl_Excl);
  320.     //
  321.     // minExclusive < minInclusive <= maxInclusive < maxExclusive
  322.     //
  323.     // check 4.3.7.c1 must: minInclusive <= maxInclusive
  324.     if (((thisFacetsDefined & DatatypeValidator::FACET_MAXINCLUSIVE) != 0) &&
  325.         ((thisFacetsDefined & DatatypeValidator::FACET_MININCLUSIVE) != 0) )
  326.     {
  327.         int result = compareValues(thisMinInclusive, thisMaxInclusive);
  328.         if ( result == 1 || result == INDETERMINATE )
  329.         {
  330.             REPORT_FACET_ERROR(thisMinInclusive
  331.                              , thisMaxInclusive
  332.                              , XMLExcepts::FACET_maxIncl_minIncl)
  333.         }
  334.     }
  335.     // check 4.3.8.c2 must: minExclusive <= maxExclusive
  336.     if ( ((thisFacetsDefined & DatatypeValidator::FACET_MAXEXCLUSIVE) != 0) &&
  337.         ((thisFacetsDefined & DatatypeValidator::FACET_MINEXCLUSIVE) != 0) )
  338.     {
  339.         int result = compareValues(getMinExclusive(), getMaxExclusive());
  340.         if ( result == 1 || result == INDETERMINATE )
  341.         {
  342.             REPORT_FACET_ERROR(thisMinExclusive
  343.                              , thisMaxExclusive
  344.                              , XMLExcepts::FACET_maxExcl_minExcl)
  345.         }
  346.     }
  347.     // check 4.3.9.c2 must: minExclusive < maxInclusive
  348.     if ( ((thisFacetsDefined & DatatypeValidator::FACET_MAXINCLUSIVE) != 0) &&
  349.         ((thisFacetsDefined & DatatypeValidator::FACET_MINEXCLUSIVE) != 0) )
  350.     {
  351.         int result = compareValues(getMinExclusive(), getMaxInclusive());
  352.         if ( result != -1 )
  353.         {
  354.             REPORT_FACET_ERROR(thisMinExclusive
  355.                              , thisMaxInclusive
  356.                              , XMLExcepts::FACET_maxIncl_minExcl)
  357.         }
  358.     }
  359.     // check 4.3.10.c1 must: minInclusive < maxExclusive
  360.     if ( ((thisFacetsDefined & DatatypeValidator::FACET_MAXEXCLUSIVE) != 0) &&
  361.         ((thisFacetsDefined & DatatypeValidator::FACET_MININCLUSIVE) != 0) )
  362.     {
  363.         int result = compareValues(getMinInclusive(), getMaxExclusive());
  364.         if ( result != -1)
  365.         {
  366.             REPORT_FACET_ERROR(thisMinInclusive
  367.                              , thisMaxExclusive
  368.                              , XMLExcepts::FACET_maxExcl_minIncl)
  369.         }
  370.     }
  371.     checkAdditionalFacetConstraints();
  372. }// end of inspectFacet()
  373. //
  374. //  Check vs base
  375. //         check common facets
  376. //         check enumeration
  377. //         check Additional Facet Constraint
  378. //
  379. void AbstractNumericFacetValidator::inspectFacetBase()
  380. {
  381.     AbstractNumericFacetValidator* numBase = (AbstractNumericFacetValidator*) getBaseValidator();
  382.     int thisFacetsDefined = getFacetsDefined();
  383.     if ( (!thisFacetsDefined && !fEnumeration) ||
  384.          !numBase           )
  385.         return;
  386.     int baseFacetsDefined = numBase->getFacetsDefined();
  387.     XMLNumber *thisMaxInclusive = getMaxInclusive();
  388.     XMLNumber *thisMaxExclusive = getMaxExclusive();
  389.     XMLNumber *thisMinInclusive = getMinInclusive();
  390.     XMLNumber *thisMinExclusive = getMinExclusive();
  391.     XMLNumber *baseMaxInclusive = numBase->getMaxInclusive();
  392.     XMLNumber *baseMaxExclusive = numBase->getMaxExclusive();
  393.     XMLNumber *baseMinInclusive = numBase->getMinInclusive();
  394.     XMLNumber *baseMinExclusive = numBase->getMinExclusive();
  395.     int       baseFixed = numBase->getFixed();
  396.                 //                                     this
  397.                 //                 minExclusive                          maxExclusive
  398.                 //                    minInclusive                  maxInclusive
  399.                 //
  400.                 //                                     base
  401.                 //  minExclusive                                                          maxExclusive
  402.                 //      minInclusive                                                   maxInclusive
  403.                 //
  404.     // check 4.3.7.c2 error:
  405.     // maxInclusive > base.maxInclusive && maxInclusive != base.maxInclusive if (base.fixed)
  406.     // maxInclusive >= base.maxExclusive
  407.     // maxInclusive < base.minInclusive
  408.     // maxInclusive <= base.minExclusive
  409.     if ((thisFacetsDefined & DatatypeValidator::FACET_MAXINCLUSIVE) != 0)
  410.     {
  411.         if ((baseFacetsDefined & DatatypeValidator::FACET_MAXINCLUSIVE) != 0)
  412.         {
  413.             int result = compareValues(thisMaxInclusive, baseMaxInclusive);
  414.             if (((baseFixed & DatatypeValidator::FACET_MAXINCLUSIVE) != 0) &&
  415.                  (result != 0 ))
  416.             {
  417.                 REPORT_FACET_ERROR(thisMaxInclusive
  418.                                  , baseMaxInclusive
  419.                                  , XMLExcepts::FACET_maxIncl_base_fixed)
  420.             }
  421.             if (result == 1 || result == INDETERMINATE)
  422.             {
  423.                 REPORT_FACET_ERROR(thisMaxInclusive
  424.                                  , baseMaxInclusive
  425.                                  , XMLExcepts::FACET_maxIncl_base_maxIncl)
  426.             }
  427.         }
  428.         if ((baseFacetsDefined & DatatypeValidator::FACET_MAXEXCLUSIVE) != 0)
  429.         {
  430.             int result = compareValues(thisMaxInclusive, baseMaxExclusive);
  431.             if (result != -1 )
  432.             {
  433.                 REPORT_FACET_ERROR(thisMaxInclusive
  434.                                  , baseMaxExclusive
  435.                                  , XMLExcepts::FACET_maxIncl_base_maxExcl)
  436.             }
  437.         }
  438.         if ((baseFacetsDefined & DatatypeValidator::FACET_MININCLUSIVE) != 0)
  439.         {
  440.             int result = compareValues(thisMaxInclusive, baseMinInclusive);
  441.             if (result == -1 || result == INDETERMINATE)
  442.             {
  443.                 REPORT_FACET_ERROR(thisMaxInclusive
  444.                                  , baseMinInclusive
  445.                                  , XMLExcepts::FACET_maxIncl_base_minIncl)
  446.             }
  447.         }
  448.         if ((baseFacetsDefined & DatatypeValidator::FACET_MINEXCLUSIVE) != 0)
  449.         {
  450.             int result = compareValues(thisMaxInclusive, baseMinExclusive);
  451.             if (result != 1 )
  452.             {
  453.                 REPORT_FACET_ERROR(thisMaxInclusive
  454.                                  , baseMinExclusive
  455.                                  , XMLExcepts::FACET_maxIncl_base_minExcl)
  456.             }
  457.         }
  458.     }
  459.     // check 4.3.8.c3 error:
  460.     // maxExclusive > base.maxExclusive  && maxExclusive != base.maxExclusive if (base.fixed)
  461.     // maxExclusive > base.maxInclusive
  462.     // maxExclusive <= base.minInclusive
  463.     // maxExclusive <= base.minExclusive
  464.     if ((thisFacetsDefined & DatatypeValidator::FACET_MAXEXCLUSIVE) != 0)
  465.     {
  466.         if (( baseFacetsDefined & DatatypeValidator::FACET_MAXEXCLUSIVE) != 0)
  467.         {
  468.             int result = compareValues(thisMaxExclusive, baseMaxExclusive);
  469.             if (((baseFixed & DatatypeValidator::FACET_MAXEXCLUSIVE) != 0) &&
  470.                  (result != 0 ))
  471.             {
  472.                 REPORT_FACET_ERROR(thisMaxExclusive
  473.                                  , baseMaxExclusive
  474.                                  , XMLExcepts::FACET_maxExcl_base_fixed)
  475.              }
  476.             if (result == 1 || result == INDETERMINATE)
  477.             {
  478.                 REPORT_FACET_ERROR(thisMaxExclusive
  479.                                  , baseMaxExclusive
  480.                                  , XMLExcepts::FACET_maxExcl_base_maxExcl)
  481.             }
  482.             /**
  483.              * Schema Errata
  484.              * E2-16 maxExclusive
  485.              *
  486.              *   derived type's maxExclusive must either be
  487.              *   1) equal to base' maxExclusive or
  488.              *   2) from the base type value space
  489.              *
  490.              */
  491.             if (result != 0)
  492.             {
  493.                 FROM_BASE_VALUE_SPACE(thisMaxExclusive
  494.                         , DatatypeValidator::FACET_MAXEXCLUSIVE
  495.                         , XMLExcepts::FACET_maxExcl_notFromBase)
  496.             }
  497.         }
  498.         else  // base has no maxExclusive
  499.         {
  500.             FROM_BASE_VALUE_SPACE(thisMaxExclusive
  501.                         , DatatypeValidator::FACET_MAXEXCLUSIVE
  502.                         , XMLExcepts::FACET_maxExcl_notFromBase)
  503.         }
  504.         if (( baseFacetsDefined & DatatypeValidator::FACET_MAXINCLUSIVE) != 0)
  505.         {
  506.             int result = compareValues(thisMaxExclusive, baseMaxInclusive);
  507.             if (result == 1 || result == INDETERMINATE)
  508.             {
  509.                 REPORT_FACET_ERROR(thisMaxExclusive
  510.                                  , baseMaxInclusive
  511.                                  , XMLExcepts::FACET_maxExcl_base_maxIncl)
  512.             }
  513.         }
  514.         if (( baseFacetsDefined & DatatypeValidator::FACET_MINEXCLUSIVE) != 0)
  515.         {
  516.             int result = compareValues(thisMaxExclusive, baseMinExclusive);
  517.             if (result != 1)
  518.             {
  519.                 REPORT_FACET_ERROR(thisMaxExclusive
  520.                                  , baseMinExclusive
  521.                                  , XMLExcepts::FACET_maxExcl_base_minExcl)
  522.             }
  523.         }
  524.         if (( baseFacetsDefined & DatatypeValidator::FACET_MININCLUSIVE) != 0)
  525.         {
  526.             int result = compareValues(thisMaxExclusive, baseMinInclusive);
  527.             if (result != 1)
  528.             {
  529.                 REPORT_FACET_ERROR(thisMaxExclusive
  530.                                  , baseMinInclusive
  531.                                  , XMLExcepts::FACET_maxExcl_base_minIncl)
  532.             }
  533.         }
  534.     }
  535.     // check 4.3.9.c3 error:
  536.     // minExclusive < base.minExclusive     minExclusive != base.minExclusive if (base.fixed)
  537.     // minExclusive > base.maxInclusive ??? minExclusive >= base.maxInclusive
  538.     // minExclusive < base.minInclusive
  539.     // minExclusive >= base.maxExclusive
  540.     if ((thisFacetsDefined & DatatypeValidator::FACET_MINEXCLUSIVE) != 0)
  541.     {
  542.         if (( baseFacetsDefined & DatatypeValidator::FACET_MINEXCLUSIVE) != 0)
  543.         {
  544.             int result = compareValues(thisMinExclusive, baseMinExclusive);
  545.             if (((baseFixed & DatatypeValidator::FACET_MINEXCLUSIVE) != 0) &&
  546.                  (result != 0 ))
  547.             {
  548.                 REPORT_FACET_ERROR(thisMinExclusive
  549.                                  , baseMinExclusive
  550.                                  , XMLExcepts::FACET_minExcl_base_fixed)
  551.             }
  552.             if (result == -1 || result == INDETERMINATE)
  553.             {
  554.                 REPORT_FACET_ERROR(thisMinExclusive
  555.                                  , baseMinExclusive
  556.                                  , XMLExcepts::FACET_minExcl_base_minExcl)
  557.             }
  558.             /**
  559.              * Schema Errata
  560.              * E2-16 maxExclusive
  561.              *
  562.              *   derived type's minExclusive must either be
  563.              *   1) equal to base' minxExclusive or
  564.              *   2) from the base type value space
  565.              *
  566.              *  Note: deduced from, not explicitly expressed in the Errata
  567.              */
  568.             if (result != 0)
  569.             {
  570.                 FROM_BASE_VALUE_SPACE(thisMinExclusive
  571.                         , DatatypeValidator::FACET_MINEXCLUSIVE
  572.                         , XMLExcepts::FACET_minExcl_notFromBase)
  573.             }
  574.         }
  575.         else // base has no minExclusive
  576.         {
  577.             FROM_BASE_VALUE_SPACE(thisMinExclusive
  578.                         , DatatypeValidator::FACET_MINEXCLUSIVE
  579.                         , XMLExcepts::FACET_minExcl_notFromBase)
  580.         }
  581.         if (( baseFacetsDefined & DatatypeValidator::FACET_MAXINCLUSIVE) != 0)
  582.         {
  583.             int result = compareValues(thisMinExclusive, baseMaxInclusive);
  584.             if (result == 1 || result == INDETERMINATE)
  585.             {
  586.                 REPORT_FACET_ERROR(thisMinExclusive
  587.                                  , baseMaxInclusive
  588.                                  , XMLExcepts::FACET_minExcl_base_maxIncl)
  589.             }
  590.         }
  591.         if (( baseFacetsDefined & DatatypeValidator::FACET_MININCLUSIVE) != 0)
  592.         {
  593.             int result = compareValues(thisMinExclusive, baseMinInclusive);
  594.             if (result == -1 || result == INDETERMINATE)
  595.             {
  596.                 REPORT_FACET_ERROR(thisMinExclusive
  597.                                  , baseMinInclusive
  598.                                  , XMLExcepts::FACET_minExcl_base_minIncl)
  599.             }
  600.         }
  601.         if (( baseFacetsDefined & DatatypeValidator::FACET_MAXEXCLUSIVE) != 0)
  602.         {
  603.             int result = compareValues(thisMinExclusive, baseMaxExclusive);
  604.             if (result != -1)
  605.             {
  606.                 REPORT_FACET_ERROR(thisMinExclusive
  607.                                  , baseMaxExclusive
  608.                                  , XMLExcepts::FACET_minExcl_base_maxExcl)
  609.             }
  610.         }
  611.     }
  612.     // check 4.3.10.c2 error:
  613.     // minInclusive < base.minInclusive   minInclusive != base.minInclusive if (base.fixed)
  614.     // minInclusive > base.maxInclusive
  615.     // minInclusive <= base.minExclusive
  616.     // minInclusive >= base.maxExclusive
  617.     if ((thisFacetsDefined & DatatypeValidator::FACET_MININCLUSIVE) != 0)
  618.     {
  619.         if ((baseFacetsDefined & DatatypeValidator::FACET_MININCLUSIVE) != 0)
  620.         {
  621.             int result = compareValues(thisMinInclusive, baseMinInclusive);
  622.             if (((baseFixed & DatatypeValidator::FACET_MININCLUSIVE) != 0) &&
  623.                  (result != 0 ))
  624.             {
  625.                 REPORT_FACET_ERROR(thisMinInclusive
  626.                                  , baseMinInclusive
  627.                                  , XMLExcepts::FACET_minIncl_base_fixed)
  628.             }
  629.             if (result == -1 || result == INDETERMINATE)
  630.             {
  631.                 REPORT_FACET_ERROR(thisMinInclusive
  632.                                  , baseMinInclusive
  633.                                  , XMLExcepts::FACET_minIncl_base_minIncl)
  634.             }
  635.         }
  636.         if (( baseFacetsDefined & DatatypeValidator::FACET_MAXINCLUSIVE) != 0)
  637.         {
  638.             int result = compareValues(thisMinInclusive, baseMaxInclusive);
  639.             if (result == 1 || result == INDETERMINATE)
  640.             {
  641.                 REPORT_FACET_ERROR(thisMinInclusive
  642.                                  , baseMaxInclusive
  643.                                  , XMLExcepts::FACET_minIncl_base_maxIncl)
  644.             }
  645.         }
  646.         if (( baseFacetsDefined & DatatypeValidator::FACET_MINEXCLUSIVE) != 0)
  647.         {
  648.             int result = compareValues(thisMinInclusive, baseMinExclusive);
  649.             if (result != 1)
  650.             {
  651.                 REPORT_FACET_ERROR(thisMinInclusive
  652.                                  , baseMinExclusive
  653.                                  , XMLExcepts::FACET_minIncl_base_minExcl)
  654.             }
  655.         }
  656.         if (( baseFacetsDefined & DatatypeValidator::FACET_MAXEXCLUSIVE) != 0)
  657.         {
  658.             int result = compareValues(thisMinInclusive, baseMaxExclusive);
  659.             if (result != -1)
  660.             {
  661.                 REPORT_FACET_ERROR(thisMinInclusive
  662.                                  , baseMaxExclusive
  663.                                  , XMLExcepts::FACET_minIncl_base_maxExcl)
  664.             }
  665.         }
  666.     }
  667.     checkAdditionalFacetConstraintsBase();
  668.     // check 4.3.5.c0 must: enumeration values from the value space of base
  669.     //
  670.     // In fact, the values in the enumeration shall go through validation
  671.     // of this class as well.
  672.     // this->checkContent(value, false);
  673.     //
  674.     if ( ((thisFacetsDefined & DatatypeValidator::FACET_ENUMERATION) != 0) &&
  675.         ( fStrEnumeration ))
  676.     {
  677.         setEnumeration();
  678.     }
  679.     //
  680.     // maxInclusive, maxExclusive, minInclusive and minExclusive
  681.     // shall come from the base's value space as well
  682.     //
  683.     FROM_BASE_VALUE_SPACE(thisMaxInclusive
  684.                         , DatatypeValidator::FACET_MAXINCLUSIVE
  685.                         , XMLExcepts::FACET_maxIncl_notFromBase)
  686.     FROM_BASE_VALUE_SPACE(thisMinInclusive
  687.                         , DatatypeValidator::FACET_MININCLUSIVE
  688.                         , XMLExcepts::FACET_minIncl_notFromBase)
  689. } //end of inspectFacetBase
  690. //
  691. //  Inherit facet from base
  692. //    a. inherit common facets
  693. //    b. inherit additional facet
  694. //
  695. void AbstractNumericFacetValidator::inheritFacet()
  696. {
  697.     AbstractNumericFacetValidator* numBase = (AbstractNumericFacetValidator*) getBaseValidator();
  698.     if (!numBase)
  699.         return;
  700.     int thisFacetsDefined = getFacetsDefined();
  701.     int baseFacetsDefined = numBase->getFacetsDefined();
  702.     // inherit enumeration
  703.     if ((( baseFacetsDefined & DatatypeValidator::FACET_ENUMERATION) != 0) &&
  704.         (( thisFacetsDefined & DatatypeValidator::FACET_ENUMERATION) == 0))
  705.     {
  706.         fEnumeration = numBase->fEnumeration;
  707.         fEnumerationInherited = true;
  708.         setFacetsDefined(DatatypeValidator::FACET_ENUMERATION);
  709.     }
  710.     // inherit maxInclusive
  711.     if ((( baseFacetsDefined & DatatypeValidator::FACET_MAXINCLUSIVE) != 0) &&
  712.         (( thisFacetsDefined & DatatypeValidator::FACET_MAXEXCLUSIVE) == 0) &&
  713.         (( thisFacetsDefined & DatatypeValidator::FACET_MAXINCLUSIVE) == 0) )
  714.     {
  715.         fMaxInclusive = numBase->getMaxInclusive();
  716.         fMaxInclusiveInherited = true;
  717.         setFacetsDefined(DatatypeValidator::FACET_MAXINCLUSIVE);
  718.     }
  719.     // inherit maxExclusive
  720.     if ((( baseFacetsDefined & DatatypeValidator::FACET_MAXEXCLUSIVE) != 0) &&
  721.         (( thisFacetsDefined & DatatypeValidator::FACET_MAXEXCLUSIVE) == 0) &&
  722.         (( thisFacetsDefined & DatatypeValidator::FACET_MAXINCLUSIVE) == 0) )
  723.     {
  724.         fMaxExclusive = numBase->getMaxExclusive();
  725.         fMaxExclusiveInherited = true;
  726.         setFacetsDefined(DatatypeValidator::FACET_MAXEXCLUSIVE);
  727.     }
  728.     // inherit minExclusive
  729.     if ((( baseFacetsDefined & DatatypeValidator::FACET_MININCLUSIVE) != 0) &&
  730.         (( thisFacetsDefined & DatatypeValidator::FACET_MINEXCLUSIVE) == 0) &&
  731.         (( thisFacetsDefined & DatatypeValidator::FACET_MININCLUSIVE) == 0) )
  732.     {
  733.         fMinInclusive = numBase->getMinInclusive();
  734.         fMinInclusiveInherited = true;
  735.         setFacetsDefined(DatatypeValidator::FACET_MININCLUSIVE);
  736.     }
  737.     // inherit minExclusive
  738.     if ((( baseFacetsDefined & DatatypeValidator::FACET_MINEXCLUSIVE) != 0) &&
  739.         (( thisFacetsDefined & DatatypeValidator::FACET_MINEXCLUSIVE) == 0) &&
  740.         (( thisFacetsDefined & DatatypeValidator::FACET_MININCLUSIVE) == 0) )
  741.     {
  742.         fMinExclusive = numBase->getMinExclusive();
  743.         fMinExclusiveInherited = true;
  744.         setFacetsDefined(DatatypeValidator::FACET_MINEXCLUSIVE);
  745.     }
  746.     inheritAdditionalFacet();
  747.     // inherit "fixed" option
  748.     setFixed(getFixed() | numBase->getFixed());
  749. }
  750. const RefArrayVectorOf<XMLCh>* AbstractNumericFacetValidator::getEnumString() const
  751. {
  752. return (fEnumerationInherited? getBaseValidator()->getEnumString() : fStrEnumeration );
  753. }
  754. XERCES_CPP_NAMESPACE_END
  755. /**
  756.   * End of file AbstractNumericFacetValidator::cpp
  757.   */