AbstractNumericFacetValidator.cpp
上传用户:huihehuasu
上传日期:2007-01-10
资源大小:6948k
文件大小:28k
源码类别:

xml/soap/webservice

开发平台:

C/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.4 2001/11/12 20:37:57 peiyongz Exp $
  58.  * $Log: AbstractNumericFacetValidator.cpp,v $
  59.  * Revision 1.4  2001/11/12 20:37:57  peiyongz
  60.  * SchemaDateTimeException defined
  61.  *
  62.  * Revision 1.3  2001/10/16 16:29:34  tng
  63.  * Schema: Fix Typo
  64.  *
  65.  * Revision 1.2  2001/10/09 21:17:41  peiyongz
  66.  * . macro to simplify code
  67.  * .save get***() to temp vars.
  68.  *
  69.  * Revision 1.1  2001/10/01 16:13:56  peiyongz
  70.  * DTV Reorganization:new classes: AbstractNumericFactValidator/ AbstractNumericValidator
  71.  *
  72.  */
  73. // ---------------------------------------------------------------------------
  74. //  Includes
  75. // ---------------------------------------------------------------------------
  76. #include <validators/datatype/AbstractNumericFacetValidator.hpp>
  77. #include <validators/schema/SchemaSymbols.hpp>
  78. #include <validators/datatype/InvalidDatatypeFacetException.hpp>
  79. #include <util/NumberFormatException.hpp>
  80. const int AbstractNumericFacetValidator::INDETERMINATE = 2;
  81. #define  REPORT_FACET_ERROR(val1, val2, except_code)    
  82.   XMLCh* value1 = (val1)->toString();                   
  83.   ArrayJanitor<XMLCh> jan1(value1);                     
  84.   XMLCh* value2 = (val2)->toString();                   
  85.   ArrayJanitor<XMLCh> jan2(value2);                     
  86.   ThrowXML2(InvalidDatatypeFacetException               
  87.           , except_code                                 
  88.           , value2                                      
  89.           , value1);
  90. #define  FROM_BASE_VALUE_SPACE(val, facetFlag, except_code)   
  91.   if ((thisFacetsDefined & facetFlag) != 0)                   
  92. {                                                             
  93.     XMLCh* value1 = (val)->toString();                        
  94.     ArrayJanitor<XMLCh> jan(value1);                          
  95.     try                                                       
  96. {                                                             
  97.         numBase->checkContent(value1, false);                 
  98. }                                                             
  99.     catch ( XMLException& )                                   
  100. {                                                             
  101.         ThrowXML1(InvalidDatatypeFacetException               
  102.                 , except_code                                 
  103.                 , value1);                                    
  104. }                                                             
  105. }
  106. // ---------------------------------------------------------------------------
  107. //  Constructors and Destructor
  108. // ---------------------------------------------------------------------------
  109. AbstractNumericFacetValidator::~AbstractNumericFacetValidator()
  110. {
  111.     if (fMaxInclusive && !fMaxInclusiveInherited)
  112.         delete fMaxInclusive;
  113.     if (fMaxExclusive && !fMaxExclusiveInherited)
  114.         delete fMaxExclusive;
  115.     if (fMinInclusive && !fMinInclusiveInherited)
  116.         delete fMinInclusive;
  117.     if (fMinExclusive && !fMinExclusiveInherited)
  118.         delete fMinExclusive;
  119.     //~RefVectorOf will delete all adopted elements
  120.     if (fEnumeration && !fEnumerationInherited)
  121.         delete fEnumeration;
  122. }
  123. AbstractNumericFacetValidator::AbstractNumericFacetValidator(
  124.                           DatatypeValidator*            const baseValidator
  125.                         , RefHashTableOf<KVStringPair>* const facets
  126.                         , const int                           finalSet
  127.                         , const ValidatorType                 type)
  128. :DatatypeValidator(baseValidator, facets, finalSet, type)
  129. , fMaxInclusiveInherited(false)
  130. , fMaxExclusiveInherited(false)
  131. , fMinInclusiveInherited(false)
  132. , fMinExclusiveInherited(false)
  133. , fEnumerationInherited(false)
  134. , fMaxInclusive(0)
  135. , fMaxExclusive(0)
  136. , fMinInclusive(0)
  137. , fMinExclusive(0)
  138. , fEnumeration(0)
  139. , fStrEnumeration(0)
  140. {
  141.     //do not invoke init() here !!!
  142. }
  143. //
  144. //  P1. Enumeration
  145. //
  146. void AbstractNumericFacetValidator::init(RefVectorOf<XMLCh>* const enums)
  147. {
  148.     fStrEnumeration = enums; // save the literal value
  149.     Janitor<RefVectorOf<XMLCh> >    janStrEnum(fStrEnumeration);
  150.     if (enums)
  151.     {
  152.         setFacetsDefined(DatatypeValidator::FACET_ENUMERATION);
  153.     }
  154.     assignFacet();
  155.     inspectFacet();
  156.     inspectFacetBase();
  157.     inheritFacet();
  158. }
  159. //
  160. //   Assign facets
  161. //        assign common facets
  162. //        assign additional facet
  163. //
  164. void AbstractNumericFacetValidator::assignFacet()
  165. {
  166.     RefHashTableOf<KVStringPair>* facets = getFacets();
  167.     if (!facets)     // no facets defined
  168.         return;
  169.     XMLCh* key;
  170.     XMLCh* value;
  171.     RefHashTableOfEnumerator<KVStringPair> e(facets);
  172.     while (e.hasMoreElements())
  173.     {
  174.         KVStringPair pair = e.nextElement();
  175.         key = pair.getKey();
  176.         value = pair.getValue();
  177.         if (XMLString::compareString(key, SchemaSymbols::fgELT_PATTERN) == 0)
  178.         {
  179.             setPattern(value);
  180.             if (getPattern())
  181.                 setFacetsDefined(DatatypeValidator::FACET_PATTERN);
  182.             // do not construct regex until needed
  183.         }
  184.         else if (XMLString::compareString(key, SchemaSymbols::fgELT_MAXINCLUSIVE)==0)
  185.         {
  186.             try
  187.             {
  188.                 setMaxInclusive(value);
  189.             }
  190.             catch (NumberFormatException)
  191.             {
  192.                 ThrowXML1(InvalidDatatypeFacetException, XMLExcepts::FACET_Invalid_MaxIncl, value);
  193.             }
  194.             setFacetsDefined(DatatypeValidator::FACET_MAXINCLUSIVE);
  195.         }
  196.         else if (XMLString::compareString(key, SchemaSymbols::fgELT_MAXEXCLUSIVE)==0)
  197.         {
  198.             try
  199.             {
  200.                 setMaxExclusive(value);
  201.             }
  202.             catch (NumberFormatException)
  203.             {
  204.                 ThrowXML1(InvalidDatatypeFacetException, XMLExcepts::FACET_Invalid_MaxExcl, value);
  205.             }
  206.             setFacetsDefined(DatatypeValidator::FACET_MAXEXCLUSIVE);
  207.         }
  208.         else if (XMLString::compareString(key, SchemaSymbols::fgELT_MININCLUSIVE)==0)
  209.         {
  210.             try
  211.             {
  212.                 setMinInclusive(value);
  213.             }
  214.             catch (NumberFormatException)
  215.             {
  216.                 ThrowXML1(InvalidDatatypeFacetException, XMLExcepts::FACET_Invalid_MinIncl, value);
  217.             }
  218.             setFacetsDefined(DatatypeValidator::FACET_MININCLUSIVE);
  219.         }
  220.         else if (XMLString::compareString(key, SchemaSymbols::fgELT_MINEXCLUSIVE)==0)
  221.         {
  222.             try
  223.             {
  224.                 setMinExclusive(value);
  225.             }
  226.             catch (NumberFormatException)
  227.             {
  228.                 ThrowXML1(InvalidDatatypeFacetException, XMLExcepts::FACET_Invalid_MinExcl, value);
  229.             }
  230.             setFacetsDefined(DatatypeValidator::FACET_MINEXCLUSIVE);
  231.         }
  232.         else if (XMLString::compareString(key, SchemaSymbols::fgATT_FIXED)==0)
  233.         {
  234.             unsigned int val;
  235.             bool         retStatus;
  236.             try
  237.             {
  238.                 retStatus = XMLString::textToBin(value, val);
  239.             }
  240.             catch (RuntimeException)
  241.             {
  242.                 ThrowXML(InvalidDatatypeFacetException, XMLExcepts::FACET_internalError_fixed);
  243.             }
  244.             if (!retStatus)
  245.             {
  246.                 ThrowXML(InvalidDatatypeFacetException, XMLExcepts::FACET_internalError_fixed);
  247.             }
  248.             setFixed(val);
  249.             //no setFacetsDefined here
  250.         }
  251.         else
  252.         {
  253.             assignAdditionalFacet(key, value);
  254.         }
  255.     }//while
  256. }// end of assigneFacet()
  257. //
  258. // Check facet among self
  259. //         check common facets
  260. //         check Additional Facet Constraint
  261. //
  262. void AbstractNumericFacetValidator::inspectFacet()
  263. {
  264.     int thisFacetsDefined = getFacetsDefined();
  265.     XMLNumber *thisMaxInclusive = getMaxInclusive();
  266.     XMLNumber *thisMaxExclusive = getMaxExclusive();
  267.     XMLNumber *thisMinInclusive = getMinInclusive();
  268.     XMLNumber *thisMinExclusive = getMinExclusive();
  269.     if (!thisFacetsDefined)
  270.         return;
  271.     // non co-existence checking
  272.     // check 4.3.8.c1 error: maxInclusive + maxExclusive
  273.     if (((thisFacetsDefined & DatatypeValidator::FACET_MAXEXCLUSIVE) != 0) &&
  274.         ((thisFacetsDefined & DatatypeValidator::FACET_MAXINCLUSIVE) != 0) )
  275.         ThrowXML(InvalidDatatypeFacetException, XMLExcepts::FACET_max_Incl_Excl);
  276.     // non co-existence checking
  277.     // check 4.3.9.c1 error: minInclusive + minExclusive
  278.     if (((thisFacetsDefined & DatatypeValidator::FACET_MINEXCLUSIVE) != 0) &&
  279.         ((thisFacetsDefined & DatatypeValidator::FACET_MININCLUSIVE) != 0) )
  280.         ThrowXML(InvalidDatatypeFacetException, XMLExcepts::FACET_min_Incl_Excl);
  281.     //
  282.     // minExclusive < minInclusive <= maxInclusive < maxExclusive
  283.     //
  284.     // check 4.3.7.c1 must: minInclusive <= maxInclusive
  285.     if (((thisFacetsDefined & DatatypeValidator::FACET_MAXINCLUSIVE) != 0) &&
  286.         ((thisFacetsDefined & DatatypeValidator::FACET_MININCLUSIVE) != 0) )
  287.     {
  288.         int result = compareValues(thisMinInclusive, thisMaxInclusive);
  289.         if ( result == 1 || result == INDETERMINATE )
  290.         {
  291.             REPORT_FACET_ERROR(thisMinInclusive
  292.                              , thisMaxInclusive
  293.                              , XMLExcepts::FACET_maxIncl_minIncl)
  294.         }
  295.     }
  296.     // check 4.3.8.c2 must: minExclusive <= maxExclusive
  297.     if ( ((thisFacetsDefined & DatatypeValidator::FACET_MAXEXCLUSIVE) != 0) &&
  298.         ((thisFacetsDefined & DatatypeValidator::FACET_MINEXCLUSIVE) != 0) )
  299.     {
  300.         int result = compareValues(getMinExclusive(), getMaxExclusive());
  301.         if ( result == 1 || result == INDETERMINATE )
  302.         {
  303.             REPORT_FACET_ERROR(thisMinExclusive
  304.                              , thisMaxExclusive
  305.                              , XMLExcepts::FACET_maxExcl_minExcl)
  306.         }
  307.     }
  308.     // check 4.3.9.c2 must: minExclusive < maxInclusive
  309.     if ( ((thisFacetsDefined & DatatypeValidator::FACET_MAXINCLUSIVE) != 0) &&
  310.         ((thisFacetsDefined & DatatypeValidator::FACET_MINEXCLUSIVE) != 0) )
  311.     {
  312.         int result = compareValues(getMinExclusive(), getMaxInclusive());
  313.         if ( result != -1 )
  314.         {
  315.             REPORT_FACET_ERROR(thisMinExclusive
  316.                              , thisMaxInclusive
  317.                              , XMLExcepts::FACET_maxIncl_minExcl)
  318.         }
  319.     }
  320.     // check 4.3.10.c1 must: minInclusive < maxExclusive
  321.     if ( ((thisFacetsDefined & DatatypeValidator::FACET_MAXEXCLUSIVE) != 0) &&
  322.         ((thisFacetsDefined & DatatypeValidator::FACET_MININCLUSIVE) != 0) )
  323.     {
  324.         int result = compareValues(getMinInclusive(), getMaxExclusive());
  325.         if ( result != -1)
  326.         {
  327.             REPORT_FACET_ERROR(thisMinInclusive
  328.                              , thisMaxExclusive
  329.                              , XMLExcepts::FACET_maxExcl_minIncl)
  330.         }
  331.     }
  332.     checkAdditionalFacetConstraints();
  333. }// end of inspectFacet()
  334. //
  335. //  Check vs base
  336. //         check common facets
  337. //         check enumeration
  338. //         check Additional Facet Constraint
  339. //
  340. void AbstractNumericFacetValidator::inspectFacetBase()
  341. {
  342.     AbstractNumericFacetValidator* numBase = (AbstractNumericFacetValidator*) getBaseValidator();
  343.     int thisFacetsDefined = getFacetsDefined();
  344.     if ( (!thisFacetsDefined && !fEnumeration) ||
  345.          !numBase           )
  346.         return;
  347.     int baseFacetsDefined = numBase->getFacetsDefined();
  348.     XMLNumber *thisMaxInclusive = getMaxInclusive();
  349.     XMLNumber *thisMaxExclusive = getMaxExclusive();
  350.     XMLNumber *thisMinInclusive = getMinInclusive();
  351.     XMLNumber *thisMinExclusive = getMinExclusive();
  352.     XMLNumber *baseMaxInclusive = numBase->getMaxInclusive();
  353.     XMLNumber *baseMaxExclusive = numBase->getMaxExclusive();
  354.     XMLNumber *baseMinInclusive = numBase->getMinInclusive();
  355.     XMLNumber *baseMinExclusive = numBase->getMinExclusive();
  356.     int       baseFixed = numBase->getFixed();
  357.                 //                                     this
  358.                 //                 minExclusive                          maxExclusive
  359.                 //                    minInclusive                  maxInclusive
  360.                 //
  361.                 //                                     base
  362.                 //  minExclusive                                                          maxExclusive
  363.                 //      minInclusive                                                   maxInclusive
  364.                 //
  365.     // check 4.3.7.c2 error:
  366.     // maxInclusive > base.maxInclusive && maxInclusive != base.maxInclusive if (base.fixed)
  367.     // maxInclusive >= base.maxExclusive
  368.     // maxInclusive < base.minInclusive
  369.     // maxInclusive <= base.minExclusive
  370.     if ((thisFacetsDefined & DatatypeValidator::FACET_MAXINCLUSIVE) != 0)
  371.     {
  372.         if ((baseFacetsDefined & DatatypeValidator::FACET_MAXINCLUSIVE) != 0)
  373.         {
  374.             int result = compareValues(thisMaxInclusive, baseMaxInclusive);
  375.             if (((baseFixed & DatatypeValidator::FACET_MAXINCLUSIVE) != 0) &&
  376.                  (result != 0 ))
  377.             {
  378.                 REPORT_FACET_ERROR(baseMaxInclusive
  379.                                  , thisMaxInclusive
  380.                                  , XMLExcepts::FACET_maxIncl_base_fixed)
  381.             }
  382.             if (result == 1 || result == INDETERMINATE)
  383.             {
  384.                 REPORT_FACET_ERROR(baseMaxInclusive
  385.                                  , thisMaxInclusive
  386.                                  , XMLExcepts::FACET_maxIncl_base_maxIncl)
  387.             }
  388.         }
  389.         if ((baseFacetsDefined & DatatypeValidator::FACET_MAXEXCLUSIVE) != 0)
  390.         {
  391.             int result = compareValues(thisMaxInclusive, baseMaxExclusive);
  392.             if (result != -1 )
  393.             {
  394.                 REPORT_FACET_ERROR(baseMaxExclusive
  395.                                  , thisMaxInclusive
  396.                                  , XMLExcepts::FACET_maxIncl_base_maxExcl)
  397.             }
  398.         }
  399.         if ((baseFacetsDefined & DatatypeValidator::FACET_MININCLUSIVE) != 0)
  400.         {
  401.             int result = compareValues(thisMaxInclusive, baseMinInclusive);
  402.             if (result == -1 || result == INDETERMINATE)
  403.             {
  404.                 REPORT_FACET_ERROR(baseMinInclusive
  405.                                  , thisMaxInclusive
  406.                                  , XMLExcepts::FACET_maxIncl_base_minIncl)
  407.             }
  408.         }
  409.         if ((baseFacetsDefined & DatatypeValidator::FACET_MINEXCLUSIVE) != 0)
  410.         {
  411.             int result = compareValues(thisMaxInclusive, baseMinExclusive);
  412.             if (result != 1 )
  413.             {
  414.                 REPORT_FACET_ERROR(baseMinExclusive
  415.                                  , thisMaxInclusive
  416.                                  , XMLExcepts::FACET_maxIncl_base_minExcl)
  417.             }
  418.         }
  419.     }
  420.     // check 4.3.8.c3 error:
  421.     // maxExclusive > base.maxExclusive  && maxExclusive != base.maxExclusive if (base.fixed)
  422.     // maxExclusive > base.maxInclusive
  423.     // maxExclusive <= base.minInclusive
  424.     // maxExclusive <= base.minExclusive
  425.     if ((thisFacetsDefined & DatatypeValidator::FACET_MAXEXCLUSIVE) != 0)
  426.     {
  427.         if (( baseFacetsDefined & DatatypeValidator::FACET_MAXEXCLUSIVE) != 0)
  428.         {
  429.             int result = compareValues(thisMaxExclusive, baseMaxExclusive);
  430.             if (((baseFixed & DatatypeValidator::FACET_MAXEXCLUSIVE) != 0) &&
  431.                  (result != 0 ))
  432.             {
  433.                 REPORT_FACET_ERROR(baseMaxExclusive
  434.                                  , thisMaxExclusive
  435.                                  , XMLExcepts::FACET_maxExcl_base_fixed)
  436.              }
  437.             if (result == 1 || result == INDETERMINATE)
  438.             {
  439.                 REPORT_FACET_ERROR(baseMaxExclusive
  440.                                  , thisMaxExclusive
  441.                                  , XMLExcepts::FACET_maxExcl_base_maxExcl)
  442.             }
  443.         }
  444.         if (( baseFacetsDefined & DatatypeValidator::FACET_MAXINCLUSIVE) != 0)
  445.         {
  446.             int result = compareValues(thisMaxExclusive, baseMaxInclusive);
  447.             if (result == 1 || result == INDETERMINATE)
  448.             {
  449.                 REPORT_FACET_ERROR(baseMaxInclusive
  450.                                  , thisMaxExclusive
  451.                                  , XMLExcepts::FACET_maxExcl_base_maxIncl)
  452.             }
  453.         }
  454.         if (( baseFacetsDefined & DatatypeValidator::FACET_MINEXCLUSIVE) != 0)
  455.         {
  456.             int result = compareValues(thisMaxExclusive, baseMinExclusive);
  457.             if (result != 1)
  458.             {
  459.                 REPORT_FACET_ERROR(baseMinExclusive
  460.                                  , thisMaxExclusive
  461.                                  , XMLExcepts::FACET_maxExcl_base_minExcl)
  462.             }
  463.         }
  464.         if (( baseFacetsDefined & DatatypeValidator::FACET_MININCLUSIVE) != 0)
  465.         {
  466.             int result = compareValues(thisMaxExclusive, baseMinInclusive);
  467.             if (result != 1)
  468.             {
  469.                 REPORT_FACET_ERROR(baseMinInclusive
  470.                                  , thisMaxExclusive
  471.                                  , XMLExcepts::FACET_maxExcl_base_minExcl)
  472.             }
  473.         }
  474.     }
  475.     // check 4.3.9.c3 error:
  476.     // minExclusive < base.minExclusive     minExclusive != base.minExclusive if (base.fixed)
  477.     // minExclusive > base.maxInclusive ??? minExclusive >= base.maxInclusive
  478.     // minExclusive < base.minInclusive
  479.     // minExclusive >= base.maxExclusive
  480.     if ((thisFacetsDefined & DatatypeValidator::FACET_MINEXCLUSIVE) != 0)
  481.     {
  482.         if (( baseFacetsDefined & DatatypeValidator::FACET_MINEXCLUSIVE) != 0)
  483.         {
  484.             int result = compareValues(thisMinExclusive, baseMinExclusive);
  485.             if (((baseFixed & DatatypeValidator::FACET_MINEXCLUSIVE) != 0) &&
  486.                  (result != 0 ))
  487.             {
  488.                 REPORT_FACET_ERROR(baseMinExclusive
  489.                                  , thisMinExclusive
  490.                                  , XMLExcepts::FACET_minExcl_base_fixed)
  491.             }
  492.             if (result == -1 || result == INDETERMINATE)
  493.             {
  494.                 REPORT_FACET_ERROR(baseMinExclusive
  495.                                  , thisMinExclusive
  496.                                  , XMLExcepts::FACET_minExcl_base_minExcl)
  497.             }
  498.         }
  499.         if (( baseFacetsDefined & DatatypeValidator::FACET_MAXINCLUSIVE) != 0)
  500.         {
  501.             int result = compareValues(thisMinExclusive, baseMaxInclusive);
  502.             if (result == 1 || result == INDETERMINATE)
  503.             {
  504.                 REPORT_FACET_ERROR(baseMaxInclusive
  505.                                  , thisMinExclusive
  506.                                  , XMLExcepts::FACET_minExcl_base_maxIncl)
  507.             }
  508.         }
  509.         if (( baseFacetsDefined & DatatypeValidator::FACET_MININCLUSIVE) != 0)
  510.         {
  511.             int result = compareValues(thisMinExclusive, baseMinInclusive);
  512.             if (result == -1 || result == INDETERMINATE)
  513.             {
  514.                 REPORT_FACET_ERROR(baseMinInclusive
  515.                                  , thisMinExclusive
  516.                                  , XMLExcepts::FACET_minExcl_base_minIncl)
  517.             }
  518.         }
  519.         if (( baseFacetsDefined & DatatypeValidator::FACET_MAXEXCLUSIVE) != 0)
  520.         {
  521.             int result = compareValues(thisMinExclusive, baseMaxExclusive);
  522.             if (result != -1)
  523.             {
  524.                 REPORT_FACET_ERROR(baseMaxExclusive
  525.                                  , thisMinExclusive
  526.                                  , XMLExcepts::FACET_minExcl_base_maxExcl)
  527.             }
  528.         }
  529.     }
  530.     // check 4.3.10.c2 error:
  531.     // minInclusive < base.minInclusive   minInclusive != base.minInclusive if (base.fixed)
  532.     // minInclusive > base.maxInclusive
  533.     // minInclusive <= base.minExclusive
  534.     // minInclusive >= base.maxExclusive
  535.     if ((thisFacetsDefined & DatatypeValidator::FACET_MININCLUSIVE) != 0)
  536.     {
  537.         if ((baseFacetsDefined & DatatypeValidator::FACET_MININCLUSIVE) != 0)
  538.         {
  539.             int result = compareValues(thisMinInclusive, baseMinInclusive);
  540.             if (((baseFixed & DatatypeValidator::FACET_MININCLUSIVE) != 0) &&
  541.                  (result != 0 ))
  542.             {
  543.                 REPORT_FACET_ERROR(baseMinInclusive
  544.                                  , thisMinInclusive
  545.                                  , XMLExcepts::FACET_minIncl_base_fixed)
  546.             }
  547.             if (result == -1 || result == INDETERMINATE)
  548.             {
  549.                 REPORT_FACET_ERROR(baseMinInclusive
  550.                                  , thisMinInclusive
  551.                                  , XMLExcepts::FACET_minIncl_base_minIncl)
  552.             }
  553.         }
  554.         if (( baseFacetsDefined & DatatypeValidator::FACET_MAXINCLUSIVE) != 0)
  555.         {
  556.             int result = compareValues(thisMinInclusive, baseMaxInclusive);
  557.             if (result == 1 || result == INDETERMINATE)
  558.             {
  559.                 REPORT_FACET_ERROR(baseMaxInclusive
  560.                                  , thisMinInclusive
  561.                                  , XMLExcepts::FACET_minIncl_base_maxIncl)
  562.             }
  563.         }
  564.         if (( baseFacetsDefined & DatatypeValidator::FACET_MINEXCLUSIVE) != 0)
  565.         {
  566.             int result = compareValues(thisMinInclusive, baseMinExclusive);
  567.             if (result != 1)
  568.             {
  569.                 REPORT_FACET_ERROR(baseMinExclusive
  570.                                  , thisMinInclusive
  571.                                  , XMLExcepts::FACET_minIncl_base_minExcl)
  572.             }
  573.         }
  574.         if (( baseFacetsDefined & DatatypeValidator::FACET_MAXEXCLUSIVE) != 0)
  575.         {
  576.             int result = compareValues(thisMinInclusive, baseMaxExclusive);
  577.             if (result != -1)
  578.             {
  579.                 REPORT_FACET_ERROR(baseMaxExclusive
  580.                                  , thisMinInclusive
  581.                                  , XMLExcepts::FACET_minIncl_base_maxExcl)
  582.             }
  583.         }
  584.     }
  585.     checkAdditionalFacetConstraintsBase();
  586.     // check 4.3.5.c0 must: enumeration values from the value space of base
  587.     //
  588.     // In fact, the values in the enumeration shall go through validation
  589.     // of this class as well.
  590.     // this->checkContent(value, false);
  591.     //
  592.     if ( ((thisFacetsDefined & DatatypeValidator::FACET_ENUMERATION) != 0) &&
  593.         ( fStrEnumeration ))
  594.     {
  595.         setEnumeration();
  596.     }
  597.     //
  598.     // maxInclusive, maxExclusive, minInclusive and minExclusive
  599.     // shall come from the base's value space as well
  600.     //
  601.     FROM_BASE_VALUE_SPACE(thisMaxInclusive
  602.                         , DatatypeValidator::FACET_MAXINCLUSIVE
  603.                         , XMLExcepts::FACET_maxIncl_notFromBase)
  604.     FROM_BASE_VALUE_SPACE(thisMaxExclusive
  605.                         , DatatypeValidator::FACET_MAXEXCLUSIVE
  606.                         , XMLExcepts::FACET_maxExcl_notFromBase)
  607.     FROM_BASE_VALUE_SPACE(thisMinInclusive
  608.                         , DatatypeValidator::FACET_MININCLUSIVE
  609.                         , XMLExcepts::FACET_minIncl_notFromBase)
  610.     FROM_BASE_VALUE_SPACE(thisMinExclusive
  611.                         , DatatypeValidator::FACET_MINEXCLUSIVE
  612.                         , XMLExcepts::FACET_minExcl_notFromBase)
  613. } //end of inspectFacetBase
  614. //
  615. //  Inherit facet from base
  616. //    a. inherit common facets
  617. //    b. inherit additional facet
  618. //
  619. void AbstractNumericFacetValidator::inheritFacet()
  620. {
  621.     AbstractNumericFacetValidator* numBase = (AbstractNumericFacetValidator*) getBaseValidator();
  622.     if (!numBase)
  623.         return;
  624.     int thisFacetsDefined = getFacetsDefined();
  625.     int baseFacetsDefined = numBase->getFacetsDefined();
  626.     // inherit enumeration
  627.     if ((( baseFacetsDefined & DatatypeValidator::FACET_ENUMERATION) != 0) &&
  628.         (( thisFacetsDefined & DatatypeValidator::FACET_ENUMERATION) == 0))
  629.     {
  630.         fEnumeration = numBase->fEnumeration;
  631.         fEnumerationInherited = true;
  632.         setFacetsDefined(DatatypeValidator::FACET_ENUMERATION);
  633.     }
  634.     // inherit maxInclusive
  635.     if ((( baseFacetsDefined & DatatypeValidator::FACET_MAXINCLUSIVE) != 0) &&
  636.         (( thisFacetsDefined & DatatypeValidator::FACET_MAXEXCLUSIVE) == 0) &&
  637.         (( thisFacetsDefined & DatatypeValidator::FACET_MAXINCLUSIVE) == 0) )
  638.     {
  639.         fMaxInclusive = numBase->getMaxInclusive();
  640.         fMaxInclusiveInherited = true;
  641.         setFacetsDefined(DatatypeValidator::FACET_MAXINCLUSIVE);
  642.     }
  643.     // inherit maxExclusive
  644.     if ((( baseFacetsDefined & DatatypeValidator::FACET_MAXEXCLUSIVE) != 0) &&
  645.         (( thisFacetsDefined & DatatypeValidator::FACET_MAXEXCLUSIVE) == 0) &&
  646.         (( thisFacetsDefined & DatatypeValidator::FACET_MAXINCLUSIVE) == 0) )
  647.     {
  648.         fMaxExclusive = numBase->getMaxExclusive();
  649.         fMaxExclusiveInherited = true;
  650.         setFacetsDefined(DatatypeValidator::FACET_MAXEXCLUSIVE);
  651.     }
  652.     // inherit minExclusive
  653.     if ((( baseFacetsDefined & DatatypeValidator::FACET_MININCLUSIVE) != 0) &&
  654.         (( thisFacetsDefined & DatatypeValidator::FACET_MINEXCLUSIVE) == 0) &&
  655.         (( thisFacetsDefined & DatatypeValidator::FACET_MININCLUSIVE) == 0) )
  656.     {
  657.         fMinInclusive = numBase->getMinInclusive();
  658.         fMinInclusiveInherited = true;
  659.         setFacetsDefined(DatatypeValidator::FACET_MININCLUSIVE);
  660.     }
  661.     // inherit minExclusive
  662.     if ((( baseFacetsDefined & DatatypeValidator::FACET_MINEXCLUSIVE) != 0) &&
  663.         (( thisFacetsDefined & DatatypeValidator::FACET_MINEXCLUSIVE) == 0) &&
  664.         (( thisFacetsDefined & DatatypeValidator::FACET_MININCLUSIVE) == 0) )
  665.     {
  666.         fMinExclusive = numBase->getMinExclusive();
  667.         fMinExclusiveInherited = true;
  668.         setFacetsDefined(DatatypeValidator::FACET_MINEXCLUSIVE);
  669.     }
  670.     inheritAdditionalFacet();
  671.     // inherit "fixed" option
  672.     setFixed(getFixed() | numBase->getFixed());
  673. }
  674. /**
  675.   * End of file AbstractNumericFacetValidator::cpp
  676.   */