You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by pe...@apache.org on 2001/06/20 19:56:11 UTC

cvs commit: xml-xerces/c/src/validators/datatype StringDatatypeValidator.cpp

peiyongz    01/06/20 10:56:11

  Modified:    c/src/validators/datatype StringDatatypeValidator.cpp
  Log:
  support for "fixed" option on constrainning facets
  
  Revision  Changes    Path
  1.11      +81 -28    xml-xerces/c/src/validators/datatype/StringDatatypeValidator.cpp
  
  Index: StringDatatypeValidator.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/validators/datatype/StringDatatypeValidator.cpp,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- StringDatatypeValidator.cpp	2001/05/29 19:49:36	1.10
  +++ StringDatatypeValidator.cpp	2001/06/20 17:56:09	1.11
  @@ -56,6 +56,9 @@
   
   /*
    * $Log: StringDatatypeValidator.cpp,v $
  + * Revision 1.11  2001/06/20 17:56:09  peiyongz
  + * support for "fixed" option on constrainning facets
  + *
    * Revision 1.10  2001/05/29 19:49:36  tng
    * Schema: Constraint Checking Fix in datatypeValidators.  By Pei Yong Zhang.
    *
  @@ -141,6 +144,7 @@
           XMLCh* value;
           RefHashTableOfEnumerator<KVStringPair> e(facets);
   
  +
           while (e.hasMoreElements())
           {
               KVStringPair pair = e.nextElement();
  @@ -223,6 +227,27 @@
   
                   setFacetsDefined(DatatypeValidator::FACET_WHITESPACE);
               }
  +            else if (XMLString::compareString(key, SchemaSymbols::fgATT_FIXED)==0)
  +            {
  +                unsigned int val;
  +                bool         retStatus;
  +                try
  +                {
  +                     retStatus = XMLString::textToBin(value, val);
  +                }
  +                catch (RuntimeException)
  +                {
  +                    ThrowXML(InvalidDatatypeFacetException, XMLExcepts::FACET_internalError_fixed);
  +                }
  +
  +                if (!retStatus)
  +                {
  +                    ThrowXML(InvalidDatatypeFacetException, XMLExcepts::FACET_internalError_fixed);
  +                }
  +
  +                setFixed(val);
  +                //no setFacetsDefined here
  +            }
               else
               {
                    ThrowXML(InvalidDatatypeFacetException, XMLExcepts::FACET_Invalid_Tag);
  @@ -297,13 +322,7 @@
               if (((getFacetsDefined() & DatatypeValidator::FACET_LENGTH) !=0) &&
                   ((pBaseValidator->getFacetsDefined() & DatatypeValidator::FACET_LENGTH) !=0))
               {
  -                // if (pBaseVlidator->getFixed(DatatypeValidator::FACET_LENGTH) == true)
  -                //     if ( getLength() != pBaseValidator->getLength() )
  -                //         ThrowXML
  -                // else
  -                //     if ( getLength() > pBaseValidator->getLength() )
  -                //         ThrowXML
  -                if ( getLength() > pBaseValidator->getLength() )
  +                if ( getLength() != pBaseValidator->getLength() )
                   {
                       XMLString::binToText(getLength(), value1, BUF_LEN, 10);
                       XMLString::binToText(pBaseValidator->getLength(), value2, BUF_LEN, 10);
  @@ -312,7 +331,7 @@
                           , XMLExcepts::FACET_Len_baseLen
                           , value1
                           , value2);
  -                }
  +                }                    
               }
   
               /***
  @@ -341,21 +360,31 @@
               if (((getFacetsDefined() & DatatypeValidator::FACET_MINLENGTH) !=0) &&
                   ((pBaseValidator->getFacetsDefined() & DatatypeValidator::FACET_MINLENGTH) != 0))
               {
  -                // if (pBaseVlidator->getFixed(DatatypeValidator::FACET_MINLENGTH) == true)
  -                //     if ( getMinLength() != pBaseValidator->getMinLength() )
  -                //         ThrowXML
  -                // else
  -                //     if ( getMinLength() < pBaseValidator->getMinLength() )
  -                //         ThrowXML
  -                if ( getMinLength() < pBaseValidator->getMinLength() )
  +                if ((pBaseValidator->getFixed() & DatatypeValidator::FACET_MINLENGTH) !=0)
                   {
  -                    XMLString::binToText(getMinLength(), value1, BUF_LEN, 10);
  -                    XMLString::binToText(pBaseValidator->getMinLength(), value2, BUF_LEN, 10);
  +                    if ( getMinLength() != pBaseValidator->getMinLength() )
  +                    {
  +                        XMLString::binToText(getMinLength(), value1, BUF_LEN, 10);
  +                        XMLString::binToText(pBaseValidator->getMinLength(), value2, BUF_LEN, 10);
   
  -                    ThrowXML2(InvalidDatatypeFacetException
  +                        ThrowXML2(InvalidDatatypeFacetException
  +                        , XMLExcepts::FACET_minLen_base_fixed
  +                        , value1
  +                        , value2);
  +                    }
  +                }
  +                else
  +                {
  +                    if ( getMinLength() < pBaseValidator->getMinLength() )
  +                    {
  +                        XMLString::binToText(getMinLength(), value1, BUF_LEN, 10);
  +                        XMLString::binToText(pBaseValidator->getMinLength(), value2, BUF_LEN, 10);
  +
  +                        ThrowXML2(InvalidDatatypeFacetException
                           , XMLExcepts::FACET_minLen_basemaxLen
                           , value1
                           , value2);
  +                    }
                   }
               }
   
  @@ -379,21 +408,31 @@
               if (((getFacetsDefined() & DatatypeValidator::FACET_MAXLENGTH) !=0) &&
                   ((pBaseValidator->getFacetsDefined() & DatatypeValidator::FACET_MAXLENGTH) !=0))
               {
  -                // if (pBaseVlidator->getFixed(DatatypeValidator::FACET_MAXLENGTH) == true)
  -                //     if ( getMaxLength() != pBaseValidator->getMaxLength() )
  -                //         ThrowXML
  -                // else
  -                //     if ( getMaxLength() > pBaseValidator->getMaxLength() )
  -                //         ThrowXML
  -                if ( getMaxLength() > pBaseValidator->getMaxLength() )
  +                if ((pBaseValidator->getFixed() & DatatypeValidator::FACET_MAXLENGTH) !=0)
                   {
  -                    XMLString::binToText(getMaxLength(), value1, BUF_LEN, 10);
  -                    XMLString::binToText(pBaseValidator->getMaxLength(), value2, BUF_LEN, 10);
  +                    if ( getMaxLength() != pBaseValidator->getMaxLength() )
  +                    {
  +                        XMLString::binToText(getMaxLength(), value1, BUF_LEN, 10);
  +                        XMLString::binToText(pBaseValidator->getMaxLength(), value2, BUF_LEN, 10);
   
  -                    ThrowXML2(InvalidDatatypeFacetException
  +                        ThrowXML2(InvalidDatatypeFacetException
  +                        , XMLExcepts::FACET_maxLen_base_fixed
  +                        , value1
  +                        , value2);
  +                    }
  +                }
  +                else
  +                {
  +                    if ( getMaxLength() > pBaseValidator->getMaxLength() )
  +                    {
  +                        XMLString::binToText(getMaxLength(), value1, BUF_LEN, 10);
  +                        XMLString::binToText(pBaseValidator->getMaxLength(), value2, BUF_LEN, 10);
  +
  +                        ThrowXML2(InvalidDatatypeFacetException
                           , XMLExcepts::FACET_maxLen_basemaxLen
                           , value1
                           , value2);
  +                    }
                   }
               }
   
  @@ -422,6 +461,7 @@
                   }
               }
   
  +
               // check 4.3.6.c1 error: whitespace
               if (((getFacetsDefined() & DatatypeValidator::FACET_WHITESPACE) != 0) &&
                   ((pBaseValidator->getFacetsDefined() & DatatypeValidator::FACET_WHITESPACE) != 0 ))
  @@ -434,6 +474,15 @@
                   if ((pBaseValidator->getWSFacet() == DatatypeValidator::REPLACE) &&
                       (getWSFacet() == DatatypeValidator::PRESERVE))
                        ThrowXML(InvalidDatatypeFacetException, XMLExcepts::FACET_WS_replace);
  +
  +                if (((pBaseValidator->getFixed() & DatatypeValidator::FACET_WHITESPACE) !=0) &&
  +                    ( getWSFacet() != pBaseValidator->getWSFacet()))
  +                {
  +                    ThrowXML2(InvalidDatatypeFacetException
  +                        , XMLExcepts::FACET_whitespace_base_fixed
  +                        , getWSstring(getWSFacet())
  +                        , getWSstring(pBaseValidator->getWSFacet()));
  +                }
               }
   
           } //if baseValidator
  @@ -492,6 +541,10 @@
               setWhiteSpace(pBaseValidator->getWSFacet());
               setFacetsDefined(DatatypeValidator::FACET_WHITESPACE);
           }
  +
  +        // inherit "fixed" option
  +        setFixed(getFixed() | pBaseValidator->getFixed());
  +
       } // end of inheritance
   }
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org