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:48 UTC

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

peiyongz    01/06/20 10:56:48

  Modified:    c/src/validators/datatype Base64BinaryDatatypeValidator.cpp
  Log:
  support for "fixed" option on constrainning facets
  
  Revision  Changes    Path
  1.7       +68 -27    xml-xerces/c/src/validators/datatype/Base64BinaryDatatypeValidator.cpp
  
  Index: Base64BinaryDatatypeValidator.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/validators/datatype/Base64BinaryDatatypeValidator.cpp,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- Base64BinaryDatatypeValidator.cpp	2001/05/29 19:49:31	1.6
  +++ Base64BinaryDatatypeValidator.cpp	2001/06/20 17:56:47	1.7
  @@ -56,6 +56,9 @@
   
   /*
    * $Log: Base64BinaryDatatypeValidator.cpp,v $
  + * Revision 1.7  2001/06/20 17:56:47  peiyongz
  + * support for "fixed" option on constrainning facets
  + *
    * Revision 1.6  2001/05/29 19:49:31  tng
    * Schema: Constraint Checking Fix in datatypeValidators.  By Pei Yong Zhang.
    *
  @@ -199,6 +202,27 @@
                       setFacetsDefined(DatatypeValidator::FACET_PATTERN);
                   // do not construct regex until needed
               } 
  +            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);
  @@ -273,13 +297,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);
  @@ -317,21 +335,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);
  +                    }
                   }
               }
   
  @@ -355,21 +383,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);
  +                    }
                   }
               }
   
  @@ -445,6 +483,9 @@
           }
   
           // we don't inherit pattern
  +
  +        // 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