From 1a81d557eb4ecde6bb3db5ccfc06d3f1d6a350bb Mon Sep 17 00:00:00 2001 From: PeiYong Zhang <peiyongz@apache.org> Date: Tue, 23 Dec 2003 21:50:36 +0000 Subject: [PATCH] Absorb exception thrown in getCanonicalRepresentation and return 0, only validate when required git-svn-id: https://svn.apache.org/repos/asf/xerces/c/trunk@175616 13f79535-47bb-0310-9956-ffa450edef68 --- .../datatype/AbstractNumericValidator.cpp | 29 ++++++-- .../datatype/AbstractNumericValidator.hpp | 5 ++ .../datatype/BooleanDatatypeValidator.cpp | 24 +++++- .../datatype/BooleanDatatypeValidator.hpp | 1 + .../validators/datatype/DatatypeValidator.cpp | 24 +++++- .../validators/datatype/DatatypeValidator.hpp | 21 +++++- .../datatype/DateTimeDatatypeValidator.cpp | 40 +++++++--- .../datatype/DateTimeDatatypeValidator.hpp | 5 ++ .../datatype/DecimalDatatypeValidator.cpp | 34 ++++++--- .../datatype/DecimalDatatypeValidator.hpp | 7 +- .../datatype/ListDatatypeValidator.cpp | 74 +++++++++++++------ .../datatype/ListDatatypeValidator.hpp | 5 ++ .../datatype/TimeDatatypeValidator.cpp | 39 ++++++++-- .../datatype/TimeDatatypeValidator.hpp | 5 ++ .../datatype/UnionDatatypeValidator.cpp | 31 ++++++-- .../datatype/UnionDatatypeValidator.hpp | 5 ++ 16 files changed, 272 insertions(+), 77 deletions(-) diff --git a/src/xercesc/validators/datatype/AbstractNumericValidator.cpp b/src/xercesc/validators/datatype/AbstractNumericValidator.cpp index 3352875af..f7f208067 100644 --- a/src/xercesc/validators/datatype/AbstractNumericValidator.cpp +++ b/src/xercesc/validators/datatype/AbstractNumericValidator.cpp @@ -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 @@ void AbstractNumericValidator::boundsCheck(const XMLNumber* const theDat } 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); + } /*** diff --git a/src/xercesc/validators/datatype/AbstractNumericValidator.hpp b/src/xercesc/validators/datatype/AbstractNumericValidator.hpp index 1c96fe665..375dbab31 100644 --- a/src/xercesc/validators/datatype/AbstractNumericValidator.hpp +++ b/src/xercesc/validators/datatype/AbstractNumericValidator.hpp @@ -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 @@ public: ( const XMLCh* const rawData , MemoryManager* const memMgr = 0 + , bool toValidate = false ) const; /*** diff --git a/src/xercesc/validators/datatype/BooleanDatatypeValidator.cpp b/src/xercesc/validators/datatype/BooleanDatatypeValidator.cpp index e66a693ee..76687e882 100644 --- a/src/xercesc/validators/datatype/BooleanDatatypeValidator.cpp +++ b/src/xercesc/validators/datatype/BooleanDatatypeValidator.cpp @@ -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 @@ const RefArrayVectorOf<XMLCh>* BooleanDatatypeValidator::getEnumString() const * 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]) ) ? diff --git a/src/xercesc/validators/datatype/BooleanDatatypeValidator.hpp b/src/xercesc/validators/datatype/BooleanDatatypeValidator.hpp index 8736374dc..76fd36060 100644 --- a/src/xercesc/validators/datatype/BooleanDatatypeValidator.hpp +++ b/src/xercesc/validators/datatype/BooleanDatatypeValidator.hpp @@ -104,6 +104,7 @@ public: ( const XMLCh* const rawData , MemoryManager* const memMgr = 0 + , bool toValidate = false ) const; //@} diff --git a/src/xercesc/validators/datatype/DatatypeValidator.cpp b/src/xercesc/validators/datatype/DatatypeValidator.cpp index 6e99fef02..ba66cc536 100644 --- a/src/xercesc/validators/datatype/DatatypeValidator.cpp +++ b/src/xercesc/validators/datatype/DatatypeValidator.cpp @@ -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 @@ DatatypeValidator::isBuiltInDV(DatatypeValidator* const dv) * */ 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); } diff --git a/src/xercesc/validators/datatype/DatatypeValidator.hpp b/src/xercesc/validators/datatype/DatatypeValidator.hpp index 3f184c702..41eaea9bd 100644 --- a/src/xercesc/validators/datatype/DatatypeValidator.hpp +++ b/src/xercesc/validators/datatype/DatatypeValidator.hpp @@ -246,19 +246,32 @@ public: * 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; //@} diff --git a/src/xercesc/validators/datatype/DateTimeDatatypeValidator.cpp b/src/xercesc/validators/datatype/DateTimeDatatypeValidator.cpp index d9d795485..179986618 100644 --- a/src/xercesc/validators/datatype/DateTimeDatatypeValidator.cpp +++ b/src/xercesc/validators/datatype/DateTimeDatatypeValidator.cpp @@ -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 @@ void DateTimeDatatypeValidator::parse(XMLDateTime* const pDate) } 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; + } + } /*** diff --git a/src/xercesc/validators/datatype/DateTimeDatatypeValidator.hpp b/src/xercesc/validators/datatype/DateTimeDatatypeValidator.hpp index 23be0da3c..b44578c5a 100644 --- a/src/xercesc/validators/datatype/DateTimeDatatypeValidator.hpp +++ b/src/xercesc/validators/datatype/DateTimeDatatypeValidator.hpp @@ -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 @@ public: ( const XMLCh* const rawData , MemoryManager* const memMgr = 0 + , bool toValidate = false ) const; /*** diff --git a/src/xercesc/validators/datatype/DecimalDatatypeValidator.cpp b/src/xercesc/validators/datatype/DecimalDatatypeValidator.cpp index 90158afc2..60be2819f 100644 --- a/src/xercesc/validators/datatype/DecimalDatatypeValidator.cpp +++ b/src/xercesc/validators/datatype/DecimalDatatypeValidator.cpp @@ -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 @@ void DecimalDatatypeValidator::checkContent(const XMLCh* const conte ***/ 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 @@ const XMLCh* DecimalDatatypeValidator::getCanonicalRepresentation(const XMLCh* { return XMLString::replicate(rawData, toUse); } + } /*** diff --git a/src/xercesc/validators/datatype/DecimalDatatypeValidator.hpp b/src/xercesc/validators/datatype/DecimalDatatypeValidator.hpp index f4569b9f3..9cd7a2c8b 100644 --- a/src/xercesc/validators/datatype/DecimalDatatypeValidator.hpp +++ b/src/xercesc/validators/datatype/DecimalDatatypeValidator.hpp @@ -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 @@ public: ( const XMLCh* const rawData , MemoryManager* const memMgr = 0 + , bool toValidate = false ) const; /*** @@ -259,6 +261,7 @@ private: // ----------------------------------------------------------------------- unsigned int fTotalDigits; unsigned int fFractionDigits; + }; // ----------------------------------------------------------------------- diff --git a/src/xercesc/validators/datatype/ListDatatypeValidator.cpp b/src/xercesc/validators/datatype/ListDatatypeValidator.cpp index 70ffb0a78..c956cc955 100644 --- a/src/xercesc/validators/datatype/ListDatatypeValidator.cpp +++ b/src/xercesc/validators/datatype/ListDatatypeValidator.cpp @@ -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 @@ void ListDatatypeValidator::inheritFacet() * 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; + } /*** diff --git a/src/xercesc/validators/datatype/ListDatatypeValidator.hpp b/src/xercesc/validators/datatype/ListDatatypeValidator.hpp index 48c4716b4..edd425612 100644 --- a/src/xercesc/validators/datatype/ListDatatypeValidator.hpp +++ b/src/xercesc/validators/datatype/ListDatatypeValidator.hpp @@ -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 @@ public: ( const XMLCh* const rawData , MemoryManager* const memMgr = 0 + , bool toValidate = false ) const; //@} diff --git a/src/xercesc/validators/datatype/TimeDatatypeValidator.cpp b/src/xercesc/validators/datatype/TimeDatatypeValidator.cpp index 0cefd6456..3d917bb84 100644 --- a/src/xercesc/validators/datatype/TimeDatatypeValidator.cpp +++ b/src/xercesc/validators/datatype/TimeDatatypeValidator.cpp @@ -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 @@ void TimeDatatypeValidator::parse(XMLDateTime* const pDate) } 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; + } + } /*** diff --git a/src/xercesc/validators/datatype/TimeDatatypeValidator.hpp b/src/xercesc/validators/datatype/TimeDatatypeValidator.hpp index 855b40a35..7300e6204 100644 --- a/src/xercesc/validators/datatype/TimeDatatypeValidator.hpp +++ b/src/xercesc/validators/datatype/TimeDatatypeValidator.hpp @@ -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 @@ public: ( const XMLCh* const rawData , MemoryManager* const memMgr = 0 + , bool toValidate = false ) const; /*** diff --git a/src/xercesc/validators/datatype/UnionDatatypeValidator.cpp b/src/xercesc/validators/datatype/UnionDatatypeValidator.cpp index 644b6a330..fb87977cd 100644 --- a/src/xercesc/validators/datatype/UnionDatatypeValidator.cpp +++ b/src/xercesc/validators/datatype/UnionDatatypeValidator.cpp @@ -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 @@ const RefArrayVectorOf<XMLCh>* UnionDatatypeValidator::getEnumString() const * 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 @@ const XMLCh* UnionDatatypeValidator::getCanonicalRepresentation(const XMLCh* //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 @@ const XMLCh* UnionDatatypeValidator::getCanonicalRepresentation(const XMLCh* } } - //its not likely we reach here, but who knows ... + //if no member dv recognize it return 0; } diff --git a/src/xercesc/validators/datatype/UnionDatatypeValidator.hpp b/src/xercesc/validators/datatype/UnionDatatypeValidator.hpp index 8afe91f37..9470c732b 100644 --- a/src/xercesc/validators/datatype/UnionDatatypeValidator.hpp +++ b/src/xercesc/validators/datatype/UnionDatatypeValidator.hpp @@ -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 @@ public: ( const XMLCh* const rawData , MemoryManager* const memMgr = 0 + , bool toValidate = false ) const; //@} -- GitLab