XercesDOMParser.hpp
Go to the documentation of this file.
/*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*/
/*
* $Id$
*/
#if !defined(XERCESC_INCLUDE_GUARD_XERCESDOMPARSER_HPP)
#define XERCESC_INCLUDE_GUARD_XERCESDOMPARSER_HPP
#include <xercesc/parsers/AbstractDOMParser.hpp>
#include <xercesc/validators/common/Grammar.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class EntityResolver;
class ErrorHandler;
class XMLEntityResolver;
class XMLResourceIdentifier;
class PARSERS_EXPORT XercesDOMParser : public AbstractDOMParser
{
public :
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
XercesDOMParser
(
XMLValidator* const valToAdopt = 0
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
, XMLGrammarPool* const gramPool = 0
);
virtual ~XercesDOMParser();
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
ErrorHandler* getErrorHandler();
const ErrorHandler* getErrorHandler() const;
EntityResolver* getEntityResolver();
const EntityResolver* getEntityResolver() const;
XMLEntityResolver* getXMLEntityResolver();
const XMLEntityResolver* getXMLEntityResolver() const;
bool isCachingGrammarFromParse() const;
bool isUsingCachedGrammarInParse() const;
Grammar* getGrammar(const XMLCh* const nameSpaceKey);
Grammar* getRootGrammar();
const XMLCh* getURIText(unsigned int uriId) const;
XMLFilePos getSrcOffset() const;
bool getIgnoreCachedDTD() const;
// -----------------------------------------------------------------------
// Setter methods
// -----------------------------------------------------------------------
void setErrorHandler(ErrorHandler* const handler);
void setEntityResolver(EntityResolver* const handler);
void setXMLEntityResolver(XMLEntityResolver* const handler);
void cacheGrammarFromParse(const bool newState);
void useCachedGrammarInParse(const bool newState);
void setIgnoreCachedDTD(const bool newValue);
// -----------------------------------------------------------------------
// Utility methods
// -----------------------------------------------------------------------
void resetDocumentPool();
// -----------------------------------------------------------------------
// Implementation of the XMLErrorReporter interface.
// -----------------------------------------------------------------------
virtual void error
(
const unsigned int errCode
, const XMLCh* const msgDomain
, const XMLErrorReporter::ErrTypes errType
, const XMLCh* const errorText
, const XMLCh* const systemId
, const XMLCh* const publicId
, const XMLFileLoc lineNum
, const XMLFileLoc colNum
);
virtual void resetErrors();
// -----------------------------------------------------------------------
// Implementation of the XMLEntityHandler interface.
// -----------------------------------------------------------------------
virtual void endInputSource(const InputSource& inputSource);
virtual bool expandSystemId
(
const XMLCh* const systemId
, XMLBuffer& toFill
);
virtual void resetEntities();
virtual InputSource* resolveEntity
(
XMLResourceIdentifier* resourceIdentifier
);
virtual void startInputSource(const InputSource& inputSource);
// -----------------------------------------------------------------------
// Grammar preparsing interface
// -----------------------------------------------------------------------
Grammar* loadGrammar(const InputSource& source,
const Grammar::GrammarType grammarType,
const bool toCache = false);
Grammar* loadGrammar(const XMLCh* const systemId,
const Grammar::GrammarType grammarType,
const bool toCache = false);
Grammar* loadGrammar(const char* const systemId,
const Grammar::GrammarType grammarType,
const bool toCache = false);
void resetCachedGrammarPool();
private :
// -----------------------------------------------------------------------
// Initialize/Cleanup methods
// -----------------------------------------------------------------------
void resetParse();
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
XercesDOMParser(const XercesDOMParser&);
XercesDOMParser& operator=(const XercesDOMParser&);
// -----------------------------------------------------------------------
// Private data members
//
// fEntityResolver
// The installed SAX entity resolver, if any. Null if none.
//
// fErrorHandler
// The installed SAX error handler, if any. Null if none.
//-----------------------------------------------------------------------
EntityResolver* fEntityResolver;
XMLEntityResolver* fXMLEntityResolver;
ErrorHandler* fErrorHandler;
};
// ---------------------------------------------------------------------------
// XercesDOMParser: Handlers for the XMLEntityHandler interface
// ---------------------------------------------------------------------------
inline void XercesDOMParser::endInputSource(const InputSource&)
{
// The DOM entity resolver doesn't handle this
}
inline bool XercesDOMParser::expandSystemId(const XMLCh* const, XMLBuffer&)
{
// The DOM entity resolver doesn't handle this
return false;
}
inline void XercesDOMParser::resetEntities()
{
// Nothing to do on this one
}
inline void XercesDOMParser::startInputSource(const InputSource&)
{
// The DOM entity resolver doesn't handle this
}
// ---------------------------------------------------------------------------
// XercesDOMParser: Getter methods
// ---------------------------------------------------------------------------
inline ErrorHandler* XercesDOMParser::getErrorHandler()
{
return fErrorHandler;
}
inline const ErrorHandler* XercesDOMParser::getErrorHandler() const
{
return fErrorHandler;
}
inline EntityResolver* XercesDOMParser::getEntityResolver()
{
return fEntityResolver;
}
inline const EntityResolver* XercesDOMParser::getEntityResolver() const
{
return fEntityResolver;
}
inline XMLEntityResolver* XercesDOMParser::getXMLEntityResolver()
{
return fXMLEntityResolver;
}
inline const XMLEntityResolver* XercesDOMParser::getXMLEntityResolver() const
{
return fXMLEntityResolver;
}
XERCES_CPP_NAMESPACE_END
#endif
XERCES_CPP_NAMESPACE_BEGIN
#define XERCES_CPP_NAMESPACE_BEGIN
Definition: XercesDefs.hpp:112
XMLErrorReporter::ErrTypes
ErrTypes
Definition: XMLErrorReporter.hpp:48
XercesDOMParser::getXMLEntityResolver
XMLEntityResolver * getXMLEntityResolver()
Get a pointer to the entity resolver.
Definition: XercesDOMParser.hpp:684
XERCES_CPP_NAMESPACE_END
#define XERCES_CPP_NAMESPACE_END
Definition: XercesDefs.hpp:113
XMLEntityHandler::resolveEntity
virtual InputSource * resolveEntity(XMLResourceIdentifier *resourceIdentifier)=0
This method allows the entity handler to provide customized application specific entity resolution.
XercesDOMParser::getErrorHandler
ErrorHandler * getErrorHandler()
Get a pointer to the error handler.
Definition: XercesDOMParser.hpp:664
XMLFileLoc
XMLUInt64 XMLFileLoc
Definition: Xerces_autoconf_config.hpp:144
XMLResourceIdentifier
Definition: XMLResourceIdentifier.hpp:95
XMLCh
uint16_t XMLCh
Definition: Xerces_autoconf_config.hpp:120
XercesDOMParser::startInputSource
virtual void startInputSource(const InputSource &inputSource)
Handle a 'start input source' event.
Definition: XercesDOMParser.hpp:655
XMLGrammarPool
Definition: XMLGrammarPool.hpp:43
XMLErrorReporter::error
virtual void error(const unsigned int errCode, const XMLCh *const errDomain, const ErrTypes type, const XMLCh *const errorText, const XMLCh *const systemId, const XMLCh *const publicId, const XMLFileLoc lineNum, const XMLFileLoc colNum)=0
Called to report errors from the scanner or validator.
XMLPlatformUtils::fgMemoryManager
static MemoryManager * fgMemoryManager
The configurable memory manager.
Definition: PlatformUtils.hpp:121
XMLEntityHandler::expandSystemId
virtual bool expandSystemId(const XMLCh *const systemId, XMLBuffer &toFill)=0
This method allows the passes the scanned systemId to the entity handler, thereby giving it a chance ...
XMLFilePos
XMLUInt64 XMLFilePos
Definition: Xerces_autoconf_config.hpp:139
XercesDOMParser::resetEntities
virtual void resetEntities()
Reset any entity handler information.
Definition: XercesDOMParser.hpp:650
AbstractDOMParser.hpp
EntityResolver
Basic interface for resolving entities.
Definition: EntityResolver.hpp:86
XercesDOMParser::expandSystemId
virtual bool expandSystemId(const XMLCh *const systemId, XMLBuffer &toFill)
Expand a system id.
Definition: XercesDOMParser.hpp:644
AbstractDOMParser
This class implements the Document Object Model (DOM) interface.
Definition: AbstractDOMParser.hpp:54
PARSERS_EXPORT
#define PARSERS_EXPORT
Definition: XercesDefs.hpp:168
XMLEntityResolver
Revised interface for resolving entities.
Definition: XMLEntityResolver.hpp:99
XMLEntityHandler::endInputSource
virtual void endInputSource(const InputSource &inputSource)=0
This method get called after the scanner has finished reading from the given input source while proce...
MemoryManager
Configurable memory manager.
Definition: MemoryManager.hpp:39
XercesDOMParser
This class implements the Document Object Model (DOM) interface.
Definition: XercesDOMParser.hpp:47
InputSource
A single input source for an XML entity.
Definition: InputSource.hpp:62
XMLValidator
This abstract class provides the interface for all validators.
Definition: XMLValidator.hpp:52
XercesDOMParser::getEntityResolver
EntityResolver * getEntityResolver()
Get a pointer to the entity resolver.
Definition: XercesDOMParser.hpp:674
XercesDOMParser::endInputSource
virtual void endInputSource(const InputSource &inputSource)
Handle an end of input source event.
Definition: XercesDOMParser.hpp:639
XMLEntityHandler::resetEntities
virtual void resetEntities()=0
This method allows the entity handler to reset itself, so that it can be used again.
XMLEntityHandler::startInputSource
virtual void startInputSource(const InputSource &inputSource)=0
This method will be called before the scanner starts reading from an input source while processing ex...
XMLErrorReporter::resetErrors
virtual void resetErrors()=0
Called before a new parse event to allow the handler to reset.
ErrorHandler
Basic interface for SAX error handlers.
Definition: ErrorHandler.hpp:60