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
AbstractDOMParser.hpp
PARSERS_EXPORT
#define PARSERS_EXPORT
Definition XercesDefs.hpp:168
XERCES_CPP_NAMESPACE_BEGIN
#define XERCES_CPP_NAMESPACE_BEGIN
Definition XercesDefs.hpp:112
XERCES_CPP_NAMESPACE_END
#define XERCES_CPP_NAMESPACE_END
Definition XercesDefs.hpp:113
XMLCh
char16_t XMLCh
Definition Xerces_autoconf_config.hpp:120
XMLFilePos
XMLUInt64 XMLFilePos
Definition Xerces_autoconf_config.hpp:139
XMLFileLoc
XMLUInt64 XMLFileLoc
Definition Xerces_autoconf_config.hpp:144
AbstractDOMParser
This class implements the Document Object Model (DOM) interface.
Definition AbstractDOMParser.hpp:62
EntityResolver
Basic interface for resolving entities.
Definition EntityResolver.hpp:87
ErrorHandler
Basic interface for SAX error handlers.
Definition ErrorHandler.hpp:61
InputSource
A single input source for an XML entity.
Definition InputSource.hpp:63
MemoryManager
Configurable memory manager.
Definition MemoryManager.hpp:40
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...
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 ...
XMLEntityHandler::resetEntities
virtual void resetEntities()=0
This method allows the entity handler to reset itself, so that it can be used again.
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...
XMLEntityResolver
Revised interface for resolving entities.
Definition XMLEntityResolver.hpp:100
XMLErrorReporter::ErrTypes
ErrTypes
Definition XMLErrorReporter.hpp:49
XMLGrammarPool
Definition XMLGrammarPool.hpp:44
XMLPlatformUtils::fgMemoryManager
static MemoryManager * fgMemoryManager
The configurable memory manager.
Definition PlatformUtils.hpp:121
XMLResourceIdentifier
Definition XMLResourceIdentifier.hpp:96
XMLValidator
This abstract class provides the interface for all validators.
Definition XMLValidator.hpp:53
XercesDOMParser
This class implements the Document Object Model (DOM) interface.
Definition XercesDOMParser.hpp:48
XercesDOMParser::startInputSource
virtual void startInputSource(const InputSource &inputSource)
Handle a 'start input source' event.
Definition XercesDOMParser.hpp:655
XercesDOMParser::loadGrammar
Grammar * loadGrammar(const char *const systemId, const Grammar::GrammarType grammarType, const bool toCache=false)
Preparse schema grammar (XML Schema, DTD, etc.) via a file path or URL.
XercesDOMParser::getRootGrammar
Grammar * getRootGrammar()
Retrieve the grammar where the root element is declared.
XercesDOMParser::loadGrammar
Grammar * loadGrammar(const InputSource &source, const Grammar::GrammarType grammarType, const bool toCache=false)
Preparse schema grammar (XML Schema, DTD, etc.) via an input source object.
XercesDOMParser::resolveEntity
virtual InputSource * resolveEntity(XMLResourceIdentifier *resourceIdentifier)
Resolve a public/system id.
XercesDOMParser::cacheGrammarFromParse
void cacheGrammarFromParse(const bool newState)
Set the 'Grammar caching' flag.
XercesDOMParser::getXMLEntityResolver
XMLEntityResolver * getXMLEntityResolver()
Get a pointer to the entity resolver.
Definition XercesDOMParser.hpp:684
XercesDOMParser::resetCachedGrammarPool
void resetCachedGrammarPool()
This method allows the user to reset the pool of cached grammars.
XercesDOMParser::getIgnoreCachedDTD
bool getIgnoreCachedDTD() const
Get the 'ignore cached DTD grammar' flag.
XercesDOMParser::resetErrors
virtual void resetErrors()
Reset any error data before a new parse.
XercesDOMParser::loadGrammar
Grammar * loadGrammar(const XMLCh *const systemId, const Grammar::GrammarType grammarType, const bool toCache=false)
Preparse schema grammar (XML Schema, DTD, etc.) via a file path or URL.
XercesDOMParser::setErrorHandler
void setErrorHandler(ErrorHandler *const handler)
Set the error handler.
XercesDOMParser::XercesDOMParser
XercesDOMParser(XMLValidator *const valToAdopt=0, MemoryManager *const manager=XMLPlatformUtils::fgMemoryManager, XMLGrammarPool *const gramPool=0)
Construct a XercesDOMParser, with an optional validator.
XercesDOMParser::setIgnoreCachedDTD
void setIgnoreCachedDTD(const bool newValue)
Set the 'ignore cached DTD grammar' flag.
XercesDOMParser::resetDocumentPool
void resetDocumentPool()
Reset the documents vector pool and release all the associated memory back to the system.
XercesDOMParser::isUsingCachedGrammarInParse
bool isUsingCachedGrammarInParse() const
Get the 'Use cached grammar' flag.
XercesDOMParser::setEntityResolver
void setEntityResolver(EntityResolver *const handler)
Set the entity resolver.
XercesDOMParser::getGrammar
Grammar * getGrammar(const XMLCh *const nameSpaceKey)
Retrieve the grammar that is associated with the specified namespace key.
XercesDOMParser::getURIText
const XMLCh * getURIText(unsigned int uriId) const
Returns the string corresponding to a URI id from the URI string pool.
XercesDOMParser::resetEntities
virtual void resetEntities()
Reset any entity handler information.
Definition XercesDOMParser.hpp:650
XercesDOMParser::~XercesDOMParser
virtual ~XercesDOMParser()
Destructor.
XercesDOMParser::expandSystemId
virtual bool expandSystemId(const XMLCh *const systemId, XMLBuffer &toFill)
Expand a system id.
Definition XercesDOMParser.hpp:644
XercesDOMParser::getSrcOffset
XMLFilePos getSrcOffset() const
Returns the current src offset within the input source.
XercesDOMParser::setXMLEntityResolver
void setXMLEntityResolver(XMLEntityResolver *const handler)
Set the entity resolver.
XercesDOMParser::getErrorHandler
ErrorHandler * getErrorHandler()
Get a pointer to the error handler.
Definition XercesDOMParser.hpp:664
XercesDOMParser::useCachedGrammarInParse
void useCachedGrammarInParse(const bool newState)
Set the 'Use cached grammar' flag.
XercesDOMParser::getEntityResolver
EntityResolver * getEntityResolver()
Get a pointer to the entity resolver.
Definition XercesDOMParser.hpp:674
XercesDOMParser::error
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)
Handle errors reported from the parser.
XercesDOMParser::endInputSource
virtual void endInputSource(const InputSource &inputSource)
Handle an end of input source event.
Definition XercesDOMParser.hpp:639
XercesDOMParser::isCachingGrammarFromParse
bool isCachingGrammarFromParse() const
Get the 'Grammar caching' flag.