Newer
Older
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
Boris Kolpackov
committed
*
Boris Kolpackov
committed
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <xercesc/internal/ValidationContextImpl.hpp>
#include <xercesc/util/Janitor.hpp>
#include <xercesc/util/Mutexes.hpp>
#include <xercesc/util/RuntimeException.hpp>
#include <xercesc/util/UnexpectedEOFException.hpp>
#include <xercesc/util/XMLMsgLoader.hpp>
#include <xercesc/util/XMLInitializer.hpp>
#include <xercesc/framework/LocalFileInputSource.hpp>
#include <xercesc/framework/URLInputSource.hpp>
#include <xercesc/framework/XMLDocumentHandler.hpp>
#include <xercesc/framework/XMLEntityHandler.hpp>
#include <xercesc/framework/XMLPScanToken.hpp>
#include <xercesc/framework/XMLValidator.hpp>
#include <xercesc/internal/EndOfEntityException.hpp>
#include <xercesc/validators/DTD/DocTypeHandler.hpp>
#include <xercesc/validators/common/GrammarResolver.hpp>
Neil Graham
committed
#include <xercesc/util/OutOfMemoryException.hpp>
#include <xercesc/util/XMLResourceIdentifier.hpp>
// ---------------------------------------------------------------------------
// Local static data
// ---------------------------------------------------------------------------
Boris Kolpackov
committed
static XMLUInt32 gScannerId = 0;
static XMLMutex* sScannerMutex = 0;
static XMLMsgLoader* gMsgLoader = 0;
Boris Kolpackov
committed
void XMLInitializer::initializeXMLScanner()
{
gMsgLoader = XMLPlatformUtils::loadMsgSet(XMLUni::fgXMLErrDomain);
Boris Kolpackov
committed
if (!gMsgLoader)
XMLPlatformUtils::panic(PanicHandler::Panic_CantLoadMsgDomain);
Boris Kolpackov
committed
sScannerMutex = new XMLMutex(XMLPlatformUtils::fgMemoryManager);
Boris Kolpackov
committed
void XMLInitializer::terminateXMLScanner()
Boris Kolpackov
committed
delete gMsgLoader;
gMsgLoader = 0;
delete sScannerMutex;
sScannerMutex = 0;
}
//
//
typedef JanitorMemFunCall<XMLScanner> CleanupType;
typedef JanitorMemFunCall<ReaderMgr> ReaderMgrResetType;
// ---------------------------------------------------------------------------
// XMLScanner: Constructors and Destructor
// ---------------------------------------------------------------------------
XMLScanner::XMLScanner(XMLValidator* const valToAdopt,
GrammarResolver* const grammarResolver,
David Abram Cargill
committed
MemoryManager* const manager)
: fBufferSize(1024 * 1024)
, fStandardUriConformant(false)
David Abram Cargill
committed
, fCalculateSrcOfs(false)
, fExitOnFirstFatal(true)
, fValidationConstraintFatal(false)
, fInException(false)
, fStandalone(false)
, fHasNoDTD(true)
, fValidate(false)
, fValidatorFromUser(false)
, fDoSchema(false)
, fSchemaFullChecking(false)
, fToCacheGrammar(false)
, fUseCachedGrammar(false)
, fLoadSchema(true)
David Abram Cargill
committed
, fGenerateSyntheticAnnotations(false)
, fValidateAnnotations(false)
, fIgnoreCachedDTD(false)
David Abram Cargill
committed
, fIgnoreAnnotations(false)
, fDisableDefaultEntityResolution(false)
, fSkipDTDValidation(false)
David Abram Cargill
committed
, fHandleMultipleImports(false)
David Abram Cargill
committed
, fEntityExpansionLimit(0)
, fEntityExpansionCount(0)
, fEmptyNamespaceId(0)
, fUnknownNamespaceId(0)
, fXMLNamespaceId(0)
, fXMLNSNamespaceId(0)
, fSchemaNamespaceId(0)
David Abram Cargill
committed
, fUIntPool(0)
, fUIntPoolRow(0)
, fUIntPoolCol(0)
, fUIntPoolRowTotal(2)
, fScannerId(0)
, fSequenceId(0)
, fAttrList(0)
, fAttrDupChkRegistry(0)
, fDocHandler(0)
, fDocTypeHandler(0)
, fEntityHandler(0)
, fErrorReporter(0)
, fErrorHandler(0)
David Abram Cargill
committed
, fPSVIHandler(0)
, fValidationContext(0)
, fEntityDeclPoolRetrieved(false)
, fReaderMgr(manager)
, fGrammarResolver(grammarResolver)
, fGrammarPoolMemoryManager(grammarResolver->getGrammarPoolMemoryManager())
, fURIStringPool(0)
, fRootElemName(0)
, fExternalSchemaLocation(0)
Boris Kolpackov
committed
, fExternalNoNamespaceSchemaLocation(0)
, fMemoryManager(manager)
, fBufMgr(manager)
, fAttNameBuf(1023, manager)
, fAttValueBuf(1023, manager)
, fCDataBuf(1023, manager)
, fQNameBuf(1023, manager)
, fPrefixBuf(1023, manager)
, fURIBuf(1023, manager)
Khaled Noaman
committed
, fWSNormalizeBuf(1023, manager)
Boris Kolpackov
committed
, fElemStack(manager)
CleanupType cleanup(this, &XMLScanner::cleanUp);
try
{
commonInit();
}
catch(const OutOfMemoryException&)
{
// Don't cleanup when out of memory, since executing the
// code can cause problems.
cleanup.release();
throw;
}
cleanup.release();
}
XMLScanner::XMLScanner( XMLDocumentHandler* const docHandler
, DocTypeHandler* const docTypeHandler
, XMLEntityHandler* const entityHandler
, XMLErrorReporter* const errHandler
, XMLValidator* const valToAdopt
, GrammarResolver* const grammarResolver
David Abram Cargill
committed
, MemoryManager* const manager)
: fBufferSize(1024 * 1024)
, fStandardUriConformant(false)
David Abram Cargill
committed
, fCalculateSrcOfs(false)
, fExitOnFirstFatal(true)
, fValidationConstraintFatal(false)
, fInException(false)
, fStandalone(false)
, fHasNoDTD(true)
, fValidate(false)
, fValidatorFromUser(false)
, fDoSchema(false)
, fSchemaFullChecking(false)
, fToCacheGrammar(false)
Loading
Loading full blame...