// --------------------------------------------------------------------------- // Utilities // --------------------------------------------------------------------------- void StringDatatypeValidator::assignAdditionalFacet(const XMLCh* const key , const XMLCh* const value , MemoryManager* const manager) { if (XMLString::equals(key, SchemaSymbols::fgELT_WHITESPACE)) { // whiteSpace = preserve | replace | collapse if (XMLString::equals(value, SchemaSymbols::fgWS_PRESERVE)) setWhiteSpace(DatatypeValidator::PRESERVE); else if (XMLString::equals(value, SchemaSymbols::fgWS_REPLACE)) setWhiteSpace(DatatypeValidator::REPLACE); else if (XMLString::equals(value, SchemaSymbols::fgWS_COLLAPSE)) setWhiteSpace(DatatypeValidator::COLLAPSE); else ThrowXMLwithMemMgr1(InvalidDatatypeFacetException, XMLExcepts::FACET_Invalid_WS, value, manager); //("whiteSpace value '" + ws + "' must be one of 'preserve', 'replace', 'collapse'."); setFacetsDefined(DatatypeValidator::FACET_WHITESPACE); } else { ThrowXMLwithMemMgr1(InvalidDatatypeFacetException , XMLExcepts::FACET_Invalid_Tag , key , manager); } }
void ValidationContextImpl::checkEntity(const XMLCh * const content) const { if (fEntityDeclPool) { const DTDEntityDecl* decl = fEntityDeclPool->getByKey(content); if (!decl || !decl->isUnparsed()) { ThrowXMLwithMemMgr1(InvalidDatatypeValueException , XMLExcepts::VALUE_ENTITY_Invalid , content , fMemoryManager); } } else { ThrowXMLwithMemMgr1 ( InvalidDatatypeValueException , XMLExcepts::VALUE_ENTITY_Invalid , content , fMemoryManager ); } }
XERCES_CPP_NAMESPACE_BEGIN // --------------------------------------------------------------------------- // Constructors and Destructor // --------------------------------------------------------------------------- BooleanDatatypeValidator::BooleanDatatypeValidator( DatatypeValidator* const baseValidator , RefHashTableOf<KVStringPair>* const facets , RefArrayVectorOf<XMLCh>* const enums , const int finalSet , MemoryManager* const manager) :DatatypeValidator(baseValidator, facets, finalSet, DatatypeValidator::Boolean, manager) { // Set Facets if any defined if ( facets ) { // Boolean shall NOT have enumeration if (enums) { delete enums; ThrowXMLwithMemMgr1(InvalidDatatypeFacetException , XMLExcepts::FACET_Invalid_Tag , "enumeration" , manager); } XMLCh* key; XMLCh* value; RefHashTableOfEnumerator<KVStringPair> e(facets, false, manager); while (e.hasMoreElements()) { KVStringPair pair = e.nextElement(); key = pair.getKey(); value = pair.getValue(); if (XMLString::equals(key, SchemaSymbols::fgELT_PATTERN)) { setPattern(value); setFacetsDefined(DatatypeValidator::FACET_PATTERN); } else { ThrowXMLwithMemMgr1(InvalidDatatypeFacetException , XMLExcepts::FACET_Invalid_Tag , key , manager); } } }// End of facet setting }
void DecimalDatatypeValidator::assignAdditionalFacet(const XMLCh* const key , const XMLCh* const value , MemoryManager* const manager) { if (XMLString::equals(key, SchemaSymbols::fgELT_TOTALDIGITS)) { int val; try { val = XMLString::parseInt(value, manager); } catch (NumberFormatException&) { ThrowXMLwithMemMgr1(InvalidDatatypeFacetException, XMLExcepts::FACET_Invalid_TotalDigit, value, manager); } // check 4.3.11.c0 must: totalDigits > 0 if ( val <= 0 ) ThrowXMLwithMemMgr1(InvalidDatatypeFacetException, XMLExcepts::FACET_PosInt_TotalDigit, value, manager); setTotalDigits(val); setFacetsDefined(DatatypeValidator::FACET_TOTALDIGITS); } else if (XMLString::equals(key, SchemaSymbols::fgELT_FRACTIONDIGITS)) { int val; try { val = XMLString::parseInt(value, manager); } catch (NumberFormatException&) { ThrowXMLwithMemMgr1(InvalidDatatypeFacetException, XMLExcepts::FACET_Invalid_FractDigit, value, manager); } // check 4.3.12.c0 must: fractionDigits > 0 if ( val < 0 ) ThrowXMLwithMemMgr1(InvalidDatatypeFacetException, XMLExcepts::FACET_NonNeg_FractDigit, value, manager); setFractionDigits(val); setFacetsDefined(DatatypeValidator::FACET_FRACTIONDIGITS); } else { ThrowXMLwithMemMgr1(InvalidDatatypeFacetException , XMLExcepts::FACET_Invalid_Tag , key , manager); } }
FileHandle XMLPlatformUtils::openStdInHandle(MemoryManager* const manager) { // // Get the standard input handle. Duplicate it and return that copy // since the outside world cannot tell the difference and will shut // down this handle when its done with it. If we gave out the orignal, // shutting it would prevent any further output. // HANDLE stdInOrg = ::GetStdHandle(STD_INPUT_HANDLE); if (stdInOrg == INVALID_HANDLE_VALUE) { XMLCh stdinStr[] = {chLatin_s, chLatin_t, chLatin_d, chLatin_i, chLatin_n, chNull}; ThrowXMLwithMemMgr1(XMLPlatformUtilsException, XMLExcepts::File_CouldNotOpenFile, stdinStr, manager); } HANDLE retHandle; if (!::DuplicateHandle ( ::GetCurrentProcess() , stdInOrg , ::GetCurrentProcess() , &retHandle , 0 , FALSE , DUPLICATE_SAME_ACCESS)) { ThrowXMLwithMemMgr(XMLPlatformUtilsException, XMLExcepts::File_CouldNotDupHandle, manager); } return retHandle; }
XERCES_CPP_NAMESPACE_BEGIN LocalFileFormatTarget::LocalFileFormatTarget( const XMLCh* const fileName , MemoryManager* const manager) : fSource(0) , fDataBuf(0) , fIndex(0) , fCapacity(1023) , fMemoryManager(manager) { fSource = XMLPlatformUtils::openFileToWrite(fileName, manager); if (!fSource) ThrowXMLwithMemMgr1(IOException, XMLExcepts::File_CouldNotOpenFile, fileName, fMemoryManager); // Buffer is one larger than capacity, to allow for zero term fDataBuf = (XMLByte*) fMemoryManager->allocate ( (fCapacity+4) * sizeof(XMLByte) );//new XMLByte[fCapacity+4]; // Keep it null terminated fDataBuf[0] = XMLByte(0); }
void ValidationContextImpl::addId(const XMLCh * const content) { if (!fIdRefList || !fToCheckIdRefList) return; XMLRefInfo* idEntry = fIdRefList->get(content); if (idEntry) { if (idEntry->getDeclared()) { ThrowXMLwithMemMgr1(InvalidDatatypeValueException , XMLExcepts::VALUE_ID_Not_Unique , content , fMemoryManager); } } else { idEntry = new (fMemoryManager) XMLRefInfo(content, false, false, fMemoryManager); fIdRefList->put((void*)idEntry->getRefName(), idEntry); } // // Mark it declared // idEntry->setDeclared(true); }
void ListDatatypeValidator::inspectFacetBase(MemoryManager* const manager) { // // we are pretty sure baseValidator is not null // if (getBaseValidator()->getType() == DatatypeValidator::List) { AbstractStringValidator::inspectFacetBase(manager); } else { // the first level ListDTV // check 4.3.5.c0 must: enumeration values from the value space of base if ( ((getFacetsDefined() & DatatypeValidator::FACET_ENUMERATION) != 0) && (getEnumeration() !=0) ) { int i; int enumLength = getEnumeration()->size(); try { for ( i = 0; i < enumLength; i++) { // ask the itemType for a complete check BaseRefVectorOf<XMLCh>* tempList = XMLString::tokenizeString(getEnumeration()->elementAt(i), manager); Janitor<BaseRefVectorOf<XMLCh> > jan(tempList); int tokenNumber = tempList->size(); try { for ( int j = 0; j < tokenNumber; j++) getBaseValidator()->validate(tempList->elementAt(j), (ValidationContext*)0, manager); } catch(const OutOfMemoryException&) { jan.release(); throw; } // enum shall pass this->checkContent() as well. checkContent(getEnumeration()->elementAt(i), (ValidationContext*)0, false, manager); } } catch ( XMLException& ) { ThrowXMLwithMemMgr1(InvalidDatatypeFacetException , XMLExcepts::FACET_enum_base , getEnumeration()->elementAt(i) , manager); } } } }// End of inspectFacetBase()
// --------------------------------------------------------------------------- // RangeTokenMap: Setter methods // --------------------------------------------------------------------------- void RangeTokenMap::setRangeToken(const XMLCh* const keyword, RangeToken* const tok,const bool complement) { if (fTokenRegistry->containsKey(keyword)) { fTokenRegistry->get(keyword)->setRangeToken(tok, complement); } else { ThrowXMLwithMemMgr1(RuntimeException, XMLExcepts::Regex_KeywordNotFound, keyword, fTokenRegistry->getMemoryManager()); } }
void RegularExpression::staticInitialize(MemoryManager* memoryManager) { fWordRange = TokenFactory::staticGetRange(fgUniIsWord, false); if (fWordRange == 0) ThrowXMLwithMemMgr1(RuntimeException, XMLExcepts::Regex_RangeTokenGetError, fgUniIsWord, memoryManager); WordRangeCleanup.registerCleanup(localCleanup); }
void NOTATIONDatatypeValidator::checkContent( const XMLCh* const content , ValidationContext* const context , bool asBase , MemoryManager* const manager ) { //validate against base validator if any NOTATIONDatatypeValidator *pBaseValidator = (NOTATIONDatatypeValidator*) this->getBaseValidator(); if (pBaseValidator) pBaseValidator->checkContent(content, context, true, manager); int thisFacetsDefined = getFacetsDefined(); // we check pattern first if ( (thisFacetsDefined & DatatypeValidator::FACET_PATTERN ) != 0 ) { if (getRegex()->matches(content, manager) ==false) { ThrowXMLwithMemMgr2(InvalidDatatypeValueException , XMLExcepts::VALUE_NotMatch_Pattern , content , getPattern() , manager); } } // if this is a base validator, we only need to check pattern facet // all other facet were inherited by the derived type if (asBase) return; checkValueSpace(content, manager); if ((thisFacetsDefined & DatatypeValidator::FACET_ENUMERATION) != 0 && (getEnumeration() != 0)) { XMLCh* normContent = XMLString::replicate(content, manager); ArrayJanitor<XMLCh> jan(normContent, manager); normalizeContent(normContent, manager); int i=0; int enumLength = getEnumeration()->size(); for ( ; i < enumLength; i++) { if (XMLString::equals(normContent, getEnumeration()->elementAt(i))) break; } if (i == enumLength) ThrowXMLwithMemMgr1(InvalidDatatypeValueException, XMLExcepts::VALUE_NotIn_Enumeration, content, manager); } checkAdditionalFacet(content, manager); }
XMLFormatter::XMLFormatter( const char* const outEncoding , XMLFormatTarget* const target , const EscapeFlags escapeFlags , const UnRepFlags unrepFlags , MemoryManager* const manager) : fEscapeFlags(escapeFlags) , fOutEncoding(0) , fTarget(target) , fUnRepFlags(unrepFlags) , fXCoder(0) , fAposRef(0) , fAposLen(0) , fAmpRef(0) , fAmpLen(0) , fGTRef(0) , fGTLen(0) , fLTRef(0) , fLTLen(0) , fQuoteRef(0) , fQuoteLen(0) , fIsXML11(false) , fMemoryManager(manager) { // this constructor uses "1.0" for the docVersion // Transcode the encoding string fOutEncoding = XMLString::transcode(outEncoding, fMemoryManager); // Try to create a transcoder for this encoding XMLTransService::Codes resCode; fXCoder = XMLPlatformUtils::fgTransService->makeNewTranscoderFor ( fOutEncoding , resCode , kTmpBufSize , fMemoryManager ); if (!fXCoder) { fMemoryManager->deallocate(fOutEncoding); //delete [] fOutEncoding; ThrowXMLwithMemMgr1 ( TranscodingException , XMLExcepts::Trans_CantCreateCvtrFor , outEncoding , fMemoryManager ); } //XMLCh* const tmpDocVer = XMLString::transcode("1.0", fMemoryManager); //ArrayJanitor<XMLCh> jname(tmpDocVer, fMemoryManager); //fIsXML11 = XMLString::equals(tmpDocVer, XMLUni::fgVersion1_1); fIsXML11 = false; // docVersion 1.0 is not 1.1! }
UnionDatatypeValidator::UnionDatatypeValidator( DatatypeValidator* const baseValidator , RefHashTableOf<KVStringPair>* const facets , RefArrayVectorOf<XMLCh>* const enums , const int finalSet , MemoryManager* const manager , RefVectorOf<DatatypeValidator>* const memberTypeValidators , const bool memberTypesInherited ) :DatatypeValidator(baseValidator, facets, finalSet, DatatypeValidator::Union, manager) ,fEnumerationInherited(false) ,fMemberTypesInherited(memberTypesInherited) ,fEnumeration(0) ,fMemberTypeValidators(memberTypeValidators) ,fValidatedDatatype(0) { // // baseValidator another UnionDTV from which, // this UnionDTV is derived by restriction. // it shall be not null // if (!baseValidator) { ThrowXMLwithMemMgr(InvalidDatatypeFacetException , XMLExcepts::FACET_Union_Null_baseValidator, manager); } if (baseValidator->getType() != DatatypeValidator::Union) { XMLCh value1[BUF_LEN+1]; XMLString::binToText(baseValidator->getType(), value1, BUF_LEN, 10, manager); ThrowXMLwithMemMgr1(InvalidDatatypeFacetException , XMLExcepts::FACET_Union_invalid_baseValidatorType , value1 , manager); } CleanupType cleanup(this, &UnionDatatypeValidator::cleanUp); try { init(baseValidator, facets, enums, manager); } catch(const OutOfMemoryException&) { // Don't cleanup when out of memory, since executing the // code can cause problems. cleanup.release(); throw; } cleanup.release(); }
void HexBinaryDatatypeValidator::checkValueSpace(const XMLCh* const content, MemoryManager* const manager) { if (HexBin::getDataLength(content) < 0) { ThrowXMLwithMemMgr1(InvalidDatatypeValueException , XMLExcepts::VALUE_Not_HexBin , content , manager); } }
void StringDatatypeValidator::checkAdditionalFacet(const XMLCh* const content , MemoryManager* const manager) const { // // check WhiteSpace // if ((getFacetsDefined() & DatatypeValidator::FACET_WHITESPACE) != 0 ) { if ( getWSFacet() == DatatypeValidator::REPLACE ) { if (!XMLString::isWSReplaced(content)) ThrowXMLwithMemMgr1(InvalidDatatypeValueException, XMLExcepts::VALUE_WS_replaced, content, manager); } else if ( getWSFacet() == DatatypeValidator::COLLAPSE ) { if (!XMLString::isWSCollapsed(content)) ThrowXMLwithMemMgr1(InvalidDatatypeValueException, XMLExcepts::VALUE_WS_collapsed, content, manager); } } }
unsigned int NameIdPool<TElem>::put(TElem* const elemToAdopt) { // First see if the key exists already. If so, its an error unsigned int hashVal; if (findBucketElem(elemToAdopt->getKey(), hashVal)) { ThrowXMLwithMemMgr1 ( IllegalArgumentException , XMLExcepts::Pool_ElemAlreadyExists , elemToAdopt->getKey() , fMemoryManager ); } // Create a new bucket element and add it to the appropriate list NameIdPoolBucketElem<TElem>* newBucket = new (fMemoryManager) NameIdPoolBucketElem<TElem> ( elemToAdopt , fBucketList[hashVal] ); fBucketList[hashVal] = newBucket; // // Give this new one the next available id and add to the pointer list. // Expand the list if that is now required. // if (fIdCounter + 1 == fIdPtrsCount) { // Create a new count 1.5 times larger and allocate a new array unsigned int newCount = (unsigned int)(fIdPtrsCount * 1.5); TElem** newArray = (TElem**) fMemoryManager->allocate ( newCount * sizeof(TElem*) ); //new TElem*[newCount]; // Copy over the old contents to the new array memcpy(newArray, fIdPtrs, fIdPtrsCount * sizeof(TElem*)); // Ok, toss the old array and store the new data fMemoryManager->deallocate(fIdPtrs); //delete [] fIdPtrs; fIdPtrs = newArray; fIdPtrsCount = newCount; } const unsigned int retId = ++fIdCounter; fIdPtrs[retId] = elemToAdopt; // Set the id on the passed element elemToAdopt->setId(retId); // Return the id that we gave to this element return retId; }
void AnyURIDatatypeValidator::checkValueSpace(const XMLCh* const content , MemoryManager* const manager) { bool validURI = true; // check 3.2.17.c0 must: URI (rfc 2396/2723) try { // Support for relative URLs // According to Java 1.1: URLs may also be specified with a // String and the URL object that it is related to. // XMLSize_t len = XMLString::stringLen(content); if (len) { // Encode special characters using XLink 5.4 algorithm XMLBuffer encoded((len*3)+1, manager); encode(content, len, encoded, manager); validURI = XMLUri::isValidURI(true, encoded.getRawBuffer(), true); } } catch(const OutOfMemoryException&) { throw; } catch (...) { ThrowXMLwithMemMgr1(InvalidDatatypeValueException , XMLExcepts::VALUE_URI_Malformed , content , manager); } if (!validURI) { ThrowXMLwithMemMgr1(InvalidDatatypeValueException , XMLExcepts::VALUE_URI_Malformed , content , manager); } }
void DoubleDatatypeValidator::setEnumeration(MemoryManager* const manager) { // check 4.3.5.c0 must: enumeration values from the value space of base // // 1. shall be from base value space // 2. shall be from current value space as well ( shall go through boundsCheck() ) // if (!fStrEnumeration) return; XMLSize_t i = 0; XMLSize_t enumLength = fStrEnumeration->size(); DoubleDatatypeValidator *numBase = (DoubleDatatypeValidator*) getBaseValidator(); if (numBase) { try { for ( i = 0; i < enumLength; i++) { numBase->checkContent(fStrEnumeration->elementAt(i), (ValidationContext*)0, false, manager); } } catch (XMLException&) { ThrowXMLwithMemMgr1(InvalidDatatypeFacetException , XMLExcepts::FACET_enum_base , fStrEnumeration->elementAt(i) , manager); } } #if 0 // spec says that only base has to checkContent // We put the this->checkContent in a separate loop // to not block original message with in that method. // for ( i = 0; i < enumLength; i++) { checkContent(fStrEnumeration->elementAt(i), (ValidationContext*)0, false, manager); } #endif fEnumeration = new (manager) RefVectorOf<XMLNumber>(enumLength, true, manager); fEnumerationInherited = false; for ( i = 0; i < enumLength; i++) { fEnumeration->insertElementAt(new (manager) XMLDouble(fStrEnumeration->elementAt(i), manager), i); } }
void NOTATIONDatatypeValidator::checkValueSpace(const XMLCh* const content , MemoryManager* const manager) { if (!XMLString::isValidNOTATION(content, manager)) { ThrowXMLwithMemMgr1(InvalidDatatypeValueException , XMLExcepts::VALUE_NOTATION_Invalid , content , manager); } }
XMLFormatter::XMLFormatter( const XMLCh* const outEncoding , const XMLCh* const docVersion , XMLFormatTarget* const target , const EscapeFlags escapeFlags , const UnRepFlags unrepFlags , MemoryManager* const manager) : fEscapeFlags(escapeFlags) , fOutEncoding(0) , fTarget(target) , fUnRepFlags(unrepFlags) , fXCoder(0) , fAposRef(0) , fAposLen(0) , fAmpRef(0) , fAmpLen(0) , fGTRef(0) , fGTLen(0) , fLTRef(0) , fLTLen(0) , fQuoteRef(0) , fQuoteLen(0) , fIsXML11(false) , fMemoryManager(manager) { // Try to create a transcoder for this encoding XMLTransService::Codes resCode; fXCoder = XMLPlatformUtils::fgTransService->makeNewTranscoderFor ( outEncoding , resCode , kTmpBufSize , fMemoryManager ); if (!fXCoder) { ThrowXMLwithMemMgr1 ( TranscodingException , XMLExcepts::Trans_CantCreateCvtrFor , outEncoding , fMemoryManager ); } // Copy the encoding string fOutEncoding = XMLString::replicate(outEncoding, fMemoryManager); fIsXML11 = XMLString::equals(docVersion, XMLUni::fgVersion1_1); }
void QNameDatatypeValidator::checkValueSpace(const XMLCh* const content , MemoryManager* const manager) { // // check 3.2.18.c0 must: QName // if ( !XMLString::isValidQName(content)) { ThrowXMLwithMemMgr1(InvalidDatatypeValueException , XMLExcepts::VALUE_QName_Invalid , content , manager); } }
void Base64BinaryDatatypeValidator::checkValueSpace(const XMLCh* const content , MemoryManager* const manager) { if (!content || !*content) return; if (Base64::getDataLength(content, manager, Base64::Conf_Schema) < 0) { ThrowXMLwithMemMgr1(InvalidDatatypeValueException , XMLExcepts::VALUE_Not_Base64 , content , manager); } }
unsigned short RegularExpression::getCharType(const XMLCh ch) { if (!isSet(fOptions, UNICODE_WORD_BOUNDARY)) { if (isSet(fOptions, USE_UNICODE_CATEGORY)) { if (fWordRange == 0) { fWordRange = fTokenFactory->getRange(fgUniIsWord); if (fWordRange == 0) ThrowXMLwithMemMgr1(RuntimeException, XMLExcepts::Regex_RangeTokenGetError, fgUniIsWord, fMemoryManager); } return fWordRange->match(ch) ? WT_LETTER : WT_OTHER; } return RegxUtil::isWordChar(ch); } switch (XMLUniCharacter::getType(ch)) { case XMLUniCharacter::UPPERCASE_LETTER: case XMLUniCharacter::LOWERCASE_LETTER: case XMLUniCharacter::TITLECASE_LETTER: case XMLUniCharacter::MODIFIER_LETTER: case XMLUniCharacter::OTHER_LETTER: case XMLUniCharacter::LETTER_NUMBER: case XMLUniCharacter::DECIMAL_DIGIT_NUMBER: case XMLUniCharacter::OTHER_NUMBER: case XMLUniCharacter::COMBINING_SPACING_MARK: return WT_LETTER; case XMLUniCharacter::FORMAT: case XMLUniCharacter::NON_SPACING_MARK: case XMLUniCharacter::ENCLOSING_MARK: return WT_IGNORE; case XMLUniCharacter::CONTROL: switch (ch) { case chHTab: case chLF: case chVTab: case chFF: case chCR: return WT_OTHER; default: return WT_IGNORE; } } return WT_OTHER; }
void ENTITYDatatypeValidator::checkValueSpace(const XMLCh* const content , MemoryManager* const manager) { // // 3.3.11 check must: "NCName" // if ( !XMLString::isValidNCName(content)) { ThrowXMLwithMemMgr1(InvalidDatatypeValueException , XMLExcepts::VALUE_Invalid_NCName , content , manager); } }
// ----------------------------------------------------------------------- // Abstract interface from AbstractNumericValidator // ----------------------------------------------------------------------- void FloatDatatypeValidator::checkContent(const XMLCh* const content , ValidationContext* const context , bool asBase , MemoryManager* const manager) { //validate against base validator if any FloatDatatypeValidator *pBase = (FloatDatatypeValidator*) this->getBaseValidator(); if (pBase) pBase->checkContent(content, context, true, manager); // we check pattern first if ( (getFacetsDefined() & DatatypeValidator::FACET_PATTERN ) != 0 ) { if (getRegex()->matches(content, manager) ==false) { ThrowXMLwithMemMgr2(InvalidDatatypeValueException , XMLExcepts::VALUE_NotMatch_Pattern , content , getPattern() , manager); } } // if this is a base validator, we only need to check pattern facet // all other facet were inherited by the derived type if (asBase) return; XMLFloat theValue(content, manager); XMLFloat *theData = &theValue; if (getEnumeration() != 0) { int i=0; int enumLength = getEnumeration()->size(); for ( ; i < enumLength; i++) { if (compareValues(theData, (XMLFloat*) getEnumeration()->elementAt(i))==0) break; } if (i == enumLength) ThrowXMLwithMemMgr1(InvalidDatatypeValueException, XMLExcepts::VALUE_NotIn_Enumeration, content, manager); } boundsCheck(theData, manager); }
LocalFileFormatTarget::LocalFileFormatTarget( const char* const fileName , MemoryManager* const manager) : fSource(0) , fDataBuf(0) , fIndex(0) , fCapacity(1024) , fMemoryManager(manager) { fSource = XMLPlatformUtils::openFileToWrite(fileName, manager); if (fSource == (FileHandle) XERCES_Invalid_File_Handle) ThrowXMLwithMemMgr1(IOException, XMLExcepts::File_CouldNotOpenFile, fileName, fMemoryManager); fDataBuf = (XMLByte*) fMemoryManager->allocate ( fCapacity * sizeof(XMLByte)); }
XMLInt32 ParserForXMLSchema::decodeEscaped() { // XML Schema doesn't support an escaped "$" if (getState() != REGX_T_BACKSOLIDUS) ThrowXMLwithMemMgr(ParseException,XMLExcepts::Parser_Next1, getMemoryManager()); XMLInt32 ch = getCharData(); switch (ch) { case chLatin_n: ch = chLF; break; case chLatin_r: ch = chCR; break; case chLatin_t: ch = chHTab; break; case chBackSlash: case chPipe: case chPeriod: case chCaret: case chDash: case chQuestion: case chAsterisk: case chPlus: case chOpenCurly: case chCloseCurly: case chOpenParen: case chCloseParen: case chOpenSquare: case chCloseSquare: break; default: { XMLCh chString[] = {chBackSlash, (XMLCh)ch, chNull}; ThrowXMLwithMemMgr1(ParseException,XMLExcepts::Parser_Process2, chString, getMemoryManager()); } } return ch; }
XMLInt32 RegxParser::decodeEscaped() { if (fState != REGX_T_BACKSOLIDUS) ThrowXMLwithMemMgr(ParseException,XMLExcepts::Parser_Next1, getMemoryManager()); XMLInt32 ch = fCharData; switch (ch) { case chLatin_n: ch = chLF; break; case chLatin_r: ch = chCR; break; case chLatin_t: ch = chHTab; break; case chBackSlash: case chPipe: case chPeriod: case chCaret: case chDash: case chQuestion: case chAsterisk: case chPlus: case chOpenCurly: case chCloseCurly: case chOpenParen: case chCloseParen: case chOpenSquare: case chCloseSquare: case chDollarSign: break; default: { XMLCh chString[] = {chBackSlash, ch, chNull}; ThrowXMLwithMemMgr1(ParseException,XMLExcepts::Parser_Process2, chString, getMemoryManager()); } } return ch; }
void RangeTokenMap::addKeywordMap(const XMLCh* const keyword, const XMLCh* const categoryName) { unsigned int categId = fCategories->getId(categoryName); if (categId == 0) { ThrowXMLwithMemMgr1(RuntimeException, XMLExcepts::Regex_InvalidCategoryName, categoryName, fTokenRegistry->getMemoryManager()); } if (fTokenRegistry->containsKey(keyword)) { RangeTokenElemMap* elemMap = fTokenRegistry->get(keyword); if (elemMap->getCategoryId() != categId) elemMap->setCategoryId(categId); return; } fTokenRegistry->put((void*) keyword, new RangeTokenElemMap(categId)); }
int RegularExpression::parseOptions(const XMLCh* const options) { if (options == 0) return 0; int opts = 0; int length = XMLString::stringLen(options); for (int i=0; i < length; i++) { int v = getOptionValue(options[i]); if (v == 0) ThrowXMLwithMemMgr1(ParseException, XMLExcepts::Regex_UnknownOption, options, fMemoryManager); opts |= v; } return opts; }