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 2003/12/23 22:50:36 UTC

cvs commit: xml-xerces/c/src/xercesc/validators/datatype AbstractNumericValidator.cpp AbstractNumericValidator.hpp BooleanDatatypeValidator.cpp BooleanDatatypeValidator.hpp DatatypeValidator.cpp DatatypeValidator.hpp DateTimeDatatypeValidator.cpp DateTimeDatatypeValidator.hpp DecimalDatatypeValidator.cpp DecimalDatatypeValidator.hpp ListDatatypeValidator.cpp ListDatatypeValidator.hpp TimeDatatypeValidator.cpp TimeDatatypeValidator.hpp UnionDatatypeValidator.cpp UnionDatatypeValidator.hpp

peiyongz    2003/12/23 13:50:36

  Modified:    c/src/xercesc/validators/datatype
                        AbstractNumericValidator.cpp
                        AbstractNumericValidator.hpp
                        BooleanDatatypeValidator.cpp
                        BooleanDatatypeValidator.hpp DatatypeValidator.cpp
                        DatatypeValidator.hpp DateTimeDatatypeValidator.cpp
                        DateTimeDatatypeValidator.hpp
                        DecimalDatatypeValidator.cpp
                        DecimalDatatypeValidator.hpp
                        ListDatatypeValidator.cpp ListDatatypeValidator.hpp
                        TimeDatatypeValidator.cpp TimeDatatypeValidator.hpp
                        UnionDatatypeValidator.cpp
                        UnionDatatypeValidator.hpp
  Log:
  Absorb exception thrown in getCanonicalRepresentation and return 0,
  only validate when required
  
  Revision  Changes    Path
  1.11      +24 -6     xml-xerces/c/src/xercesc/validators/datatype/AbstractNumericValidator.cpp
  
  Index: AbstractNumericValidator.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/datatype/AbstractNumericValidator.cpp,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- AbstractNumericValidator.cpp	17 Dec 2003 00:18:38 -0000	1.10
  +++ AbstractNumericValidator.cpp	23 Dec 2003 21:50:36 -0000	1.11
  @@ -57,6 +57,10 @@
   /*
    * $Id$
    * $Log$
  + * Revision 1.11  2003/12/23 21:50:36  peiyongz
  + * Absorb exception thrown in getCanonicalRepresentation and return 0,
  + * only validate when required
  + *
    * Revision 1.10  2003/12/17 00:18:38  cargilld
    * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data.
    *
  @@ -204,14 +208,29 @@
   }
   
   const XMLCh* AbstractNumericValidator::getCanonicalRepresentation(const XMLCh*         const rawData
  -                                                                 ,      MemoryManager* const memMgr) const
  +                                                                 ,      MemoryManager* const memMgr
  +                                                                 ,      bool                 toValidate) const
   {
  -    //Validate the content
  -    AbstractNumericValidator* temp = (AbstractNumericValidator*) this;
       MemoryManager* toUse = memMgr? memMgr : fMemoryManager;
  -    temp->checkContent(rawData, 0, false, toUse);
  -    
  +
  +    if (toValidate)
  +    {
  +        AbstractNumericValidator* temp = (AbstractNumericValidator*) this;
  +
  +        try 
  +        {
  +            temp->checkContent(rawData, 0, false, toUse);
  +        }
  +        catch (...)
  +        {
  +            return 0;
  +        }
  +    }
  +
  +    // XMLAbstractDoubleFloat::getCanonicalRepresentation handles
  +    // exceptional cases
       return XMLAbstractDoubleFloat::getCanonicalRepresentation(rawData, toUse);
  +
   }
   
   /***
  
  
  
  1.9       +5 -1      xml-xerces/c/src/xercesc/validators/datatype/AbstractNumericValidator.hpp
  
  Index: AbstractNumericValidator.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/datatype/AbstractNumericValidator.hpp,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- AbstractNumericValidator.hpp	17 Dec 2003 00:18:38 -0000	1.8
  +++ AbstractNumericValidator.hpp	23 Dec 2003 21:50:36 -0000	1.9
  @@ -57,6 +57,10 @@
   /*
    * $Id$
    * $Log$
  + * Revision 1.9  2003/12/23 21:50:36  peiyongz
  + * Absorb exception thrown in getCanonicalRepresentation and return 0,
  + * only validate when required
  + *
    * Revision 1.8  2003/12/17 00:18:38  cargilld
    * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data.
    *
  @@ -122,6 +126,7 @@
                           (
                             const XMLCh*         const rawData
                           ,       MemoryManager* const memMgr = 0
  +                        ,       bool                 toValidate = false
                           ) const;
   
       /***
  
  
  
  1.13      +20 -3     xml-xerces/c/src/xercesc/validators/datatype/BooleanDatatypeValidator.cpp
  
  Index: BooleanDatatypeValidator.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/datatype/BooleanDatatypeValidator.cpp,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- BooleanDatatypeValidator.cpp	17 Dec 2003 00:18:38 -0000	1.12
  +++ BooleanDatatypeValidator.cpp	23 Dec 2003 21:50:36 -0000	1.13
  @@ -56,6 +56,10 @@
   
   /*
    * $Log$
  + * Revision 1.13  2003/12/23 21:50:36  peiyongz
  + * Absorb exception thrown in getCanonicalRepresentation and return 0,
  + * only validate when required
  + *
    * Revision 1.12  2003/12/17 00:18:38  cargilld
    * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data.
    *
  @@ -278,11 +282,25 @@
    * The canonical representation for boolean is the set of literals {true, false}.
    ***/
   const XMLCh* BooleanDatatypeValidator::getCanonicalRepresentation(const XMLCh*         const rawData
  -                                                                ,       MemoryManager* const memMgr) const
  +                                                                ,       MemoryManager* const memMgr
  +                                                                ,       bool           toValidate) const
   {
  -    BooleanDatatypeValidator *temp = (BooleanDatatypeValidator*) this;
  +
       MemoryManager* toUse = memMgr? memMgr : getMemoryManager();
  -    temp->checkContent(rawData, 0, false, toUse);   
  +    
  +    if (toValidate)
  +    {
  +        BooleanDatatypeValidator *temp = (BooleanDatatypeValidator*) this;
  +
  +        try
  +        {
  +            temp->checkContent(rawData, 0, false, toUse);   
  +        }
  +        catch (...)
  +        {
  +            return 0;
  +        }
  +    }
   
       return ( XMLString::equals(rawData, fgValueSpace[0]) ||
                XMLString::equals(rawData, fgValueSpace[2])  ) ?
  
  
  
  1.11      +2 -1      xml-xerces/c/src/xercesc/validators/datatype/BooleanDatatypeValidator.hpp
  
  Index: BooleanDatatypeValidator.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/datatype/BooleanDatatypeValidator.hpp,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- BooleanDatatypeValidator.hpp	17 Dec 2003 00:18:38 -0000	1.10
  +++ BooleanDatatypeValidator.hpp	23 Dec 2003 21:50:36 -0000	1.11
  @@ -104,6 +104,7 @@
                           (
                             const XMLCh*         const rawData
                           ,       MemoryManager* const memMgr = 0
  +                        ,       bool                 toValidate = false
                           ) const;
       //@}
   
  
  
  
  1.20      +20 -3     xml-xerces/c/src/xercesc/validators/datatype/DatatypeValidator.cpp
  
  Index: DatatypeValidator.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/datatype/DatatypeValidator.cpp,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- DatatypeValidator.cpp	17 Dec 2003 00:18:38 -0000	1.19
  +++ DatatypeValidator.cpp	23 Dec 2003 21:50:36 -0000	1.20
  @@ -56,6 +56,10 @@
   
   /*
    * $Log$
  + * Revision 1.20  2003/12/23 21:50:36  peiyongz
  + * Absorb exception thrown in getCanonicalRepresentation and return 0,
  + * only validate when required
  + *
    * Revision 1.19  2003/12/17 00:18:38  cargilld
    * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data.
    *
  @@ -639,11 +643,25 @@
    *
    */
   const XMLCh* DatatypeValidator::getCanonicalRepresentation(const XMLCh*         const rawData
  -                                                          ,      MemoryManager* const memMgr) const
  +                                                          ,      MemoryManager* const memMgr
  +                                                          ,      bool                 toValidate) const
   {
  -    DatatypeValidator *temp = (DatatypeValidator*) this;
       MemoryManager* toUse = memMgr? memMgr : fMemoryManager;
  -    temp->validate(rawData, 0, toUse);    
  +
  +    if (toValidate)
  +    {
  +        DatatypeValidator *temp = (DatatypeValidator*) this;
  +
  +        try
  +        {
  +            temp->validate(rawData, 0, toUse);    
  +        }
  +        catch (...)
  +        {
  +            return 0;
  +        }
  +    }
  +
       return XMLString::replicate(rawData, toUse);
   }
   
  
  
  
  1.23      +18 -5     xml-xerces/c/src/xercesc/validators/datatype/DatatypeValidator.hpp
  
  Index: DatatypeValidator.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/datatype/DatatypeValidator.hpp,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- DatatypeValidator.hpp	17 Dec 2003 00:18:38 -0000	1.22
  +++ DatatypeValidator.hpp	23 Dec 2003 21:50:36 -0000	1.23
  @@ -246,19 +246,32 @@
        *    it has its own canonical representation other than
        *    the default one.
        *
  -     * @param rawData: data in raw string
  -     * @param memMgr:  memory manager
  +     * @param rawData:    data in raw string
  +     * @param memMgr:     memory manager
  +     * @param toValiate:  to validate the raw string or not
        *
        * @return: canonical representation of the data
        * 
  -     * Note:  user need to use the dv's memory manager to
  -     *        deallocate the memory for the string returned.
  +     * Note:  
  +     *
  +     *    1. the return value is kept in memory allocated
  +     *       by the memory manager passed in or by dv's
  +     *       if no memory manager is provided.
  +     *
  +     *    2. client application is responsible for the 
  +     *       proper deallcation of the memory allocated
  +     *       for the returned value.
  +     *
  +     *    3. In the case where the rawData is not valid
  +     *       with regards to the fundamental datatype,
  +     *       a null string is returned.
        *
        */
       virtual const XMLCh* getCanonicalRepresentation
                           (
                             const XMLCh*         const rawData
                           ,       MemoryManager* const memMgr = 0
  +                        ,       bool                 toValidate = false
                           ) const;
   
       //@}
  
  
  
  1.14      +27 -8     xml-xerces/c/src/xercesc/validators/datatype/DateTimeDatatypeValidator.cpp
  
  Index: DateTimeDatatypeValidator.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/datatype/DateTimeDatatypeValidator.cpp,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- DateTimeDatatypeValidator.cpp	19 Dec 2003 23:02:25 -0000	1.13
  +++ DateTimeDatatypeValidator.cpp	23 Dec 2003 21:50:36 -0000	1.14
  @@ -57,8 +57,9 @@
   /*
    * $Id$
    * $Log$
  - * Revision 1.13  2003/12/19 23:02:25  cargilld
  - * More memory management updates.
  + * Revision 1.14  2003/12/23 21:50:36  peiyongz
  + * Absorb exception thrown in getCanonicalRepresentation and return 0,
  + * only validate when required
    *
    * Revision 1.12  2003/12/17 00:18:38  cargilld
    * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data.
  @@ -179,17 +180,36 @@
   }
   
   const XMLCh* DateTimeDatatypeValidator::getCanonicalRepresentation(const XMLCh*         const rawData
  -                                                                  ,      MemoryManager* const memMgr) const
  +                                                                  ,      MemoryManager* const memMgr
  +                                                                  ,      bool                 toValidate) const
   {
  -    // we need the checkContent to build the fDateTime
  -    // to get the canonical representation
  -    DateTimeDatatypeValidator* temp = (DateTimeDatatypeValidator*) this;
       MemoryManager* toUse = memMgr? memMgr : fMemoryManager;
  -    temp->checkContent(rawData, 0, false, toUse);
  +
  +    if (toValidate)
  +    {
  +        DateTimeDatatypeValidator* temp = (DateTimeDatatypeValidator*) this;
  +
  +        try
  +        {
  +            temp->checkContent(rawData, 0, false, toUse);   
  +        }
  +        catch (...)
  +        {
  +            return 0;
  +        }
  +    }
       
  -    //Have the fDateTime to do the job
  -    XMLDateTime aDateTime(rawData, toUse);
  -    return aDateTime.getDateTimeCanonicalRepresentation(toUse);
  +    try
  +    {
  +        XMLDateTime aDateTime(rawData, toUse);
  +        aDateTime.parseDateTime();
  +        return aDateTime.getDateTimeCanonicalRepresentation(toUse);
  +    }
  +    catch (...)
  +    {
  +        return 0;
  +    }
  +
   }
   
   /***
  
  
  
  1.9       +5 -1      xml-xerces/c/src/xercesc/validators/datatype/DateTimeDatatypeValidator.hpp
  
  Index: DateTimeDatatypeValidator.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/datatype/DateTimeDatatypeValidator.hpp,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- DateTimeDatatypeValidator.hpp	17 Dec 2003 00:18:38 -0000	1.8
  +++ DateTimeDatatypeValidator.hpp	23 Dec 2003 21:50:36 -0000	1.9
  @@ -57,6 +57,10 @@
   /*
    * $Id$
    * $Log$
  + * Revision 1.9  2003/12/23 21:50:36  peiyongz
  + * Absorb exception thrown in getCanonicalRepresentation and return 0,
  + * only validate when required
  + *
    * Revision 1.8  2003/12/17 00:18:38  cargilld
    * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data.
    *
  @@ -135,6 +139,7 @@
                           (
                             const XMLCh*         const rawData
                           ,       MemoryManager* const memMgr = 0
  +                        ,       bool                 toValidate = false
                           ) const;
   
       /***
  
  
  
  1.21      +23 -10    xml-xerces/c/src/xercesc/validators/datatype/DecimalDatatypeValidator.cpp
  
  Index: DecimalDatatypeValidator.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/datatype/DecimalDatatypeValidator.cpp,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- DecimalDatatypeValidator.cpp	19 Dec 2003 23:02:25 -0000	1.20
  +++ DecimalDatatypeValidator.cpp	23 Dec 2003 21:50:36 -0000	1.21
  @@ -56,6 +56,10 @@
   
   /*
    * $Log$
  + * Revision 1.21  2003/12/23 21:50:36  peiyongz
  + * Absorb exception thrown in getCanonicalRepresentation and return 0,
  + * only validate when required
  + *
    * Revision 1.20  2003/12/19 23:02:25  cargilld
    * More memory management updates.
    *
  @@ -687,24 +691,33 @@
    ***/
   
   const XMLCh* DecimalDatatypeValidator::getCanonicalRepresentation(const XMLCh*         const rawData
  -                                                                 ,      MemoryManager* const memMgr) const
  +                                                                 ,      MemoryManager* const memMgr
  +                                                                 ,      bool                 toValidate) const
   {
  -    //Validate it first
  -    DecimalDatatypeValidator* temp = (DecimalDatatypeValidator*) this;
       MemoryManager* toUse = memMgr? memMgr : fMemoryManager;
  -    temp->checkContent(rawData, 0, false, toUse);
  -    
  +    DecimalDatatypeValidator* temp = (DecimalDatatypeValidator*) this;
  +
  +    if (toValidate)
  +    {
  +        try
  +        {
  +            temp->checkContent(rawData, 0, false, toUse);   
  +        }
  +        catch (...)
  +        {
  +            return 0;
  +        }
  +    }
  +
  +    // XMLBigInteger::getCanonicalRepresentation and
  +    // XMLBigDecimal::getCanonicalRepresentation will handle exceptional cases
       XMLCanRepGroup::CanRepGroup dvType = DatatypeValidatorFactory::getCanRepGroup(temp);
   
       if ((dvType == XMLCanRepGroup::Decimal_Derivated_signed)   ||
           (dvType == XMLCanRepGroup::Decimal_Derivated_unsigned) ||
           (dvType == XMLCanRepGroup::Decimal_Derivated_npi)        )
       {          
  -        return XMLBigInteger::getCanonicalRepresentation
  -               (
  -                rawData
  -              , toUse
  -               );
  +        return XMLBigInteger::getCanonicalRepresentation(rawData, toUse);
       }
       else if (dvType == XMLCanRepGroup::Decimal) 
       {
  @@ -714,6 +727,7 @@
       {
           return XMLString::replicate(rawData, toUse);
       }
  +
   }
   
   /***
  
  
  
  1.13      +2 -0      xml-xerces/c/src/xercesc/validators/datatype/DecimalDatatypeValidator.hpp
  
  Index: DecimalDatatypeValidator.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/datatype/DecimalDatatypeValidator.hpp,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- DecimalDatatypeValidator.hpp	19 Dec 2003 23:02:25 -0000	1.12
  +++ DecimalDatatypeValidator.hpp	23 Dec 2003 21:50:36 -0000	1.13
  @@ -57,8 +57,9 @@
   /*
    * $Id$
    * $Log$
  - * Revision 1.12  2003/12/19 23:02:25  cargilld
  - * More memory management updates.
  + * Revision 1.13  2003/12/23 21:50:36  peiyongz
  + * Absorb exception thrown in getCanonicalRepresentation and return 0,
  + * only validate when required
    *
    * Revision 1.11  2003/12/17 00:18:38  cargilld
    * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data.
  @@ -178,6 +179,7 @@
                           (
                             const XMLCh*         const rawData
                           ,       MemoryManager* const memMgr = 0
  +                        ,       bool                 toValidate = false
                           ) const;
   
       /***
  @@ -259,6 +261,7 @@
       // -----------------------------------------------------------------------
       unsigned int         fTotalDigits;
       unsigned int         fFractionDigits;
  +
   };
   
   // -----------------------------------------------------------------------
  
  
  
  1.17      +51 -26    xml-xerces/c/src/xercesc/validators/datatype/ListDatatypeValidator.cpp
  
  Index: ListDatatypeValidator.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/datatype/ListDatatypeValidator.cpp,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- ListDatatypeValidator.cpp	17 Dec 2003 20:41:47 -0000	1.16
  +++ ListDatatypeValidator.cpp	23 Dec 2003 21:50:36 -0000	1.17
  @@ -57,6 +57,10 @@
   /*
    * $Id$
    * $Log$
  + * Revision 1.17  2003/12/23 21:50:36  peiyongz
  + * Absorb exception thrown in getCanonicalRepresentation and return 0,
  + * only validate when required
  + *
    * Revision 1.16  2003/12/17 20:41:47  neilg
    * fix a segfault and a possible buffer overflow condition
    *
  @@ -502,45 +506,67 @@
    * lexical representation of its �itemType�.
    ***/
   const XMLCh* ListDatatypeValidator::getCanonicalRepresentation(const XMLCh*         const rawData
  -                                                             ,       MemoryManager* const memMgr) const
  +                                                             ,       MemoryManager* const memMgr
  +                                                             ,       bool                 toValidate) const
   {
  +    MemoryManager* toUse = memMgr? memMgr : getMemoryManager();
       ListDatatypeValidator* temp = (ListDatatypeValidator*) this;
  -
       temp->setContent(rawData);
  -    MemoryManager* toUse = memMgr? memMgr : getMemoryManager();
       BaseRefVectorOf<XMLCh>* tokenVector = XMLString::tokenizeString(rawData, toUse);
       Janitor<BaseRefVectorOf<XMLCh> > janName(tokenVector);    
  -    temp->checkContent(tokenVector, rawData, 0, false, toUse);
  -    
  -    unsigned int  retBufSize = 2 * XMLString::stringLen(rawData);
   
  +    if (toValidate)
  +    {
  +        try
  +        {
  +            temp->checkContent(tokenVector, rawData, 0, false, toUse);
  +        }
  +        catch (...)
  +        {
  +            return 0;
  +        }
  +    }
  +   
  +    unsigned int  retBufSize = 2 * XMLString::stringLen(rawData);
       XMLCh* retBuf = (XMLCh*) toUse->allocate(retBufSize * sizeof(XMLCh));
       retBuf[0] = 0;
       XMLCh* retBufPtr = retBuf;
  -
       DatatypeValidator* itemDv = this->getItemTypeDTV();
  -    for (unsigned int i = 0; i < tokenVector->size(); i++)
  +
  +    try 
       {
  -        XMLCh* itemCanRep = (XMLCh*) itemDv->getCanonicalRepresentation(tokenVector->elementAt(i), toUse);
  -        unsigned int itemLen = XMLString::stringLen(itemCanRep); 
  -        if(retBufPtr+itemLen+2 >= retBuf+retBufSize)
  +        for (unsigned int i = 0; i < tokenVector->size(); i++)
           {
  -            // need to resize
  -            XMLCh * oldBuf = retBuf;
  -            retBuf = (XMLCh*) toUse->allocate(retBufSize * sizeof(XMLCh) * 2);
  -            memcpy(retBuf, oldBuf, retBufSize * sizeof(XMLCh ));
  -            retBufPtr = (retBufPtr - oldBuf) + retBuf;
  -            toUse->deallocate(oldBuf);
  -            retBufSize <<= 1;
  +            XMLCh* itemCanRep = (XMLCh*) itemDv->getCanonicalRepresentation(tokenVector->elementAt(i), toUse, false);
  +            unsigned int itemLen = XMLString::stringLen(itemCanRep); 
  +
  +            if(retBufPtr+itemLen+2 >= retBuf+retBufSize)
  +            {
  +                // need to resize
  +                XMLCh * oldBuf = retBuf;
  +                retBuf = (XMLCh*) toUse->allocate(retBufSize * sizeof(XMLCh) * 2);
  +                memcpy(retBuf, oldBuf, retBufSize * sizeof(XMLCh ));
  +                retBufPtr = (retBufPtr - oldBuf) + retBuf;
  +                toUse->deallocate(oldBuf);
  +                retBufSize <<= 1;
  +            }
  +
  +            XMLString::catString(retBufPtr, itemCanRep);
  +            retBufPtr = retBufPtr + itemLen + 1;
  +            *(retBufPtr++) = chSpace;
  +            *(retBufPtr) = chNull;
  +            toUse->deallocate(itemCanRep);
           }
  -        XMLString::catString(retBufPtr, itemCanRep);
  -        retBufPtr = retBufPtr + itemLen + 1;
  -        *(retBufPtr++) = chSpace;
  -        *(retBufPtr) = chNull;
  -        toUse->deallocate(itemCanRep);
  +
  +        return retBuf;
  +
  +    }
  +    catch (...)
  +    {
  +        return 0;
       }
   
  -    return retBuf;
  +
   }
   
   /***
  
  
  
  1.11      +5 -1      xml-xerces/c/src/xercesc/validators/datatype/ListDatatypeValidator.hpp
  
  Index: ListDatatypeValidator.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/datatype/ListDatatypeValidator.hpp,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- ListDatatypeValidator.hpp	17 Dec 2003 00:18:39 -0000	1.10
  +++ ListDatatypeValidator.hpp	23 Dec 2003 21:50:36 -0000	1.11
  @@ -57,6 +57,10 @@
   /*
    * $Id$
    * $Log$
  + * Revision 1.11  2003/12/23 21:50:36  peiyongz
  + * Absorb exception thrown in getCanonicalRepresentation and return 0,
  + * only validate when required
  + *
    * Revision 1.10  2003/12/17 00:18:39  cargilld
    * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data.
    *
  @@ -167,6 +171,7 @@
                           (
                             const XMLCh*         const rawData
                           ,       MemoryManager* const memMgr = 0
  +                        ,       bool                 toValidate = false
                           ) const;
   
       //@}
  
  
  
  1.14      +31 -9     xml-xerces/c/src/xercesc/validators/datatype/TimeDatatypeValidator.cpp
  
  Index: TimeDatatypeValidator.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/datatype/TimeDatatypeValidator.cpp,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- TimeDatatypeValidator.cpp	19 Dec 2003 23:02:25 -0000	1.13
  +++ TimeDatatypeValidator.cpp	23 Dec 2003 21:50:36 -0000	1.14
  @@ -57,6 +57,10 @@
   /*
    * $Id$
    * $Log$
  + * Revision 1.14  2003/12/23 21:50:36  peiyongz
  + * Absorb exception thrown in getCanonicalRepresentation and return 0,
  + * only validate when required
  + *
    * Revision 1.13  2003/12/19 23:02:25  cargilld
    * More memory management updates.
    *
  @@ -179,17 +183,36 @@
   }
   
   const XMLCh* TimeDatatypeValidator::getCanonicalRepresentation(const XMLCh*         const rawData
  -                                                              ,      MemoryManager* const memMgr) const
  +                                                              ,      MemoryManager* const memMgr
  +                                                              ,      bool                 toValidate) const
   {
  -    // we need the checkContent to build the fDateTime
  -    // to get the canonical representation
  -    TimeDatatypeValidator* temp = (TimeDatatypeValidator*) this;
       MemoryManager* toUse = memMgr? memMgr : fMemoryManager;
  -    temp->checkContent(rawData, 0, false, toUse);
  +
  +    if (toValidate)
  +    {
  +        TimeDatatypeValidator* temp = (TimeDatatypeValidator*) this;
  +
  +        try
  +        {
  +            temp->checkContent(rawData, 0, false, toUse);   
  +        }
  +        catch (...)
  +        {
  +            return 0;
  +        }
  +    }
       
  -    //Have the fDateTime to do the job
  -    XMLDateTime aDateTime(rawData, toUse);
  -    return aDateTime.getTimeCanonicalRepresentation(toUse);
  +    try
  +    {
  +        XMLDateTime aDateTime(rawData, toUse);
  +        aDateTime.parseTime();
  +        return aDateTime.getTimeCanonicalRepresentation(toUse);
  +    }
  +    catch (...)
  +    {
  +        return 0;
  +    }
  +
   }
   
   /***
  
  
  
  1.9       +5 -1      xml-xerces/c/src/xercesc/validators/datatype/TimeDatatypeValidator.hpp
  
  Index: TimeDatatypeValidator.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/datatype/TimeDatatypeValidator.hpp,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- TimeDatatypeValidator.hpp	17 Dec 2003 00:18:39 -0000	1.8
  +++ TimeDatatypeValidator.hpp	23 Dec 2003 21:50:36 -0000	1.9
  @@ -57,6 +57,10 @@
   /*
    * $Id$
    * $Log$
  + * Revision 1.9  2003/12/23 21:50:36  peiyongz
  + * Absorb exception thrown in getCanonicalRepresentation and return 0,
  + * only validate when required
  + *
    * Revision 1.8  2003/12/17 00:18:39  cargilld
    * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data.
    *
  @@ -137,6 +141,7 @@
                           (
                             const XMLCh*         const rawData
                           ,       MemoryManager* const memMgr = 0
  +                        ,       bool                 toValidate = false
                           ) const;
   
       /***
  
  
  
  1.22      +23 -9     xml-xerces/c/src/xercesc/validators/datatype/UnionDatatypeValidator.cpp
  
  Index: UnionDatatypeValidator.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/datatype/UnionDatatypeValidator.cpp,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- UnionDatatypeValidator.cpp	17 Dec 2003 00:18:39 -0000	1.21
  +++ UnionDatatypeValidator.cpp	23 Dec 2003 21:50:36 -0000	1.22
  @@ -57,6 +57,10 @@
   /*
    * $Id$
    * $Log$
  + * Revision 1.22  2003/12/23 21:50:36  peiyongz
  + * Absorb exception thrown in getCanonicalRepresentation and return 0,
  + * only validate when required
  + *
    * Revision 1.21  2003/12/17 00:18:39  cargilld
    * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data.
    *
  @@ -493,15 +497,26 @@
    * in which the values have the canonical lexical representation of the appropriate �memberTypes�.       
    ***/
   const XMLCh* UnionDatatypeValidator::getCanonicalRepresentation(const XMLCh*         const rawData
  -                                                              ,       MemoryManager* const memMgr ) const
  +                                                              ,       MemoryManager* const memMgr
  +                                                              ,       bool                 toValidate) const
   {
  -
  +    MemoryManager* toUse = memMgr? memMgr : getMemoryManager();
       UnionDatatypeValidator* temp = (UnionDatatypeValidator*) this;
  -    temp->checkContent(rawData, 0, false, memMgr);
  +
  +    if (toValidate)
  +    {
  +        try
  +        {
  +            temp->checkContent(rawData, 0, false, toUse);
  +        }
  +        catch (...)
  +        {
  +            return 0;
  +        }
  +    }    
   
       //get the native unionDv
       UnionDatatypeValidator* bdv = (UnionDatatypeValidator*) temp->getBaseValidator();
  -    MemoryManager* toUse = memMgr? memMgr : getMemoryManager();
       while (bdv)
       {
           temp = bdv;
  @@ -510,12 +525,12 @@
   
       //let the member dv which recognize the rawData, to return
       //us the canonical form
  -    for ( unsigned int i = 0; i < fMemberTypeValidators->size(); ++i )
  +    for ( unsigned int i = 0; i < temp->fMemberTypeValidators->size(); ++i )
       {
           try
           {
  -            fMemberTypeValidators->elementAt(i)->validate(rawData, 0, toUse);                       
  -            return fMemberTypeValidators->elementAt(i)->getCanonicalRepresentation(rawData, toUse);
  +            temp->fMemberTypeValidators->elementAt(i)->validate(rawData, 0, toUse);                       
  +            return temp->fMemberTypeValidators->elementAt(i)->getCanonicalRepresentation(rawData, toUse, false);
           }
           catch (XMLException&)
           {
  @@ -523,7 +538,7 @@
           }
       }
   
  -    //its not likely we reach here, but who knows ...
  +    //if no member dv recognize it
       return 0;
   }
   
  
  
  
  1.16      +5 -1      xml-xerces/c/src/xercesc/validators/datatype/UnionDatatypeValidator.hpp
  
  Index: UnionDatatypeValidator.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/datatype/UnionDatatypeValidator.hpp,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- UnionDatatypeValidator.hpp	17 Dec 2003 00:18:39 -0000	1.15
  +++ UnionDatatypeValidator.hpp	23 Dec 2003 21:50:36 -0000	1.16
  @@ -57,6 +57,10 @@
   /*
    * $Id$
    * $Log$
  + * Revision 1.16  2003/12/23 21:50:36  peiyongz
  + * Absorb exception thrown in getCanonicalRepresentation and return 0,
  + * only validate when required
  + *
    * Revision 1.15  2003/12/17 00:18:39  cargilld
    * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data.
    *
  @@ -204,6 +208,7 @@
                           (
                             const XMLCh*         const rawData
                           ,       MemoryManager* const memMgr = 0
  +                        ,       bool                 toValidate = false
                           ) const;
   
       //@}
  
  
  

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