Xerces-C++: XercesDOMParser.hpp Source File

Xerces-C++ 3.3.0

XercesDOMParser.hpp
Go to the documentation of this file.
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18/*
19 * $Id$
20 */
21
22#if !defined(XERCESC_INCLUDE_GUARD_XERCESDOMPARSER_HPP)
23#define XERCESC_INCLUDE_GUARD_XERCESDOMPARSER_HPP
24
25
26#include <xercesc/parsers/AbstractDOMParser.hpp>
27#include <xercesc/validators/common/Grammar.hpp>
28
29 XERCES_CPP_NAMESPACE_BEGIN
30
31
32class EntityResolver;
33class ErrorHandler;
34class XMLEntityResolver;
35class XMLResourceIdentifier;
36
47 class PARSERS_EXPORT XercesDOMParser : public AbstractDOMParser
48{
49public :
50 // -----------------------------------------------------------------------
51 // Constructors and Destructor
52 // -----------------------------------------------------------------------
53
71 XercesDOMParser
72 (
73 XMLValidator* const valToAdopt = 0
74 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
75 , XMLGrammarPool* const gramPool = 0
76 );
77
81 virtual ~XercesDOMParser();
82
84
85
86 // -----------------------------------------------------------------------
87 // Getter methods
88 // -----------------------------------------------------------------------
89
92
100 ErrorHandler* getErrorHandler();
101
109 const ErrorHandler* getErrorHandler() const;
110
118 EntityResolver* getEntityResolver();
119
127 const EntityResolver* getEntityResolver() const;
128
137 XMLEntityResolver* getXMLEntityResolver();
138
147 const XMLEntityResolver* getXMLEntityResolver() const;
148
159 bool isCachingGrammarFromParse() const;
160
171 bool isUsingCachedGrammarInParse() const;
172
179 Grammar* getGrammar(const XMLCh* const nameSpaceKey);
180
186 Grammar* getRootGrammar();
187
194 const XMLCh* getURIText(unsigned int uriId) const;
195
202 XMLFilePos getSrcOffset() const;
203
211 bool getIgnoreCachedDTD() const;
212
214
215
216 // -----------------------------------------------------------------------
217 // Setter methods
218 // -----------------------------------------------------------------------
219
222
236 void setErrorHandler(ErrorHandler* const handler);
237
254 void setEntityResolver(EntityResolver* const handler);
255
273 void setXMLEntityResolver(XMLEntityResolver* const handler);
274
292 void cacheGrammarFromParse(const bool newState);
293
312 void useCachedGrammarInParse(const bool newState);
313
328 void setIgnoreCachedDTD(const bool newValue);
329
331
332 // -----------------------------------------------------------------------
333 // Utility methods
334 // -----------------------------------------------------------------------
335
361 void resetDocumentPool();
362
364
365 // -----------------------------------------------------------------------
366 // Implementation of the XMLErrorReporter interface.
367 // -----------------------------------------------------------------------
368
371
396 virtual void error
397 (
398 const unsigned int errCode
399 , const XMLCh* const msgDomain
400 , const XMLErrorReporter::ErrTypes errType
401 , const XMLCh* const errorText
402 , const XMLCh* const systemId
403 , const XMLCh* const publicId
404 , const XMLFileLoc lineNum
405 , const XMLFileLoc colNum
406 );
407
416 virtual void resetErrors();
418
419
420 // -----------------------------------------------------------------------
421 // Implementation of the XMLEntityHandler interface.
422 // -----------------------------------------------------------------------
423
426
439 virtual void endInputSource(const InputSource& inputSource);
440
456 virtual bool expandSystemId
457 (
458 const XMLCh* const systemId
459 , XMLBuffer& toFill
460 );
461
470 virtual void resetEntities();
471
488 virtual InputSource* resolveEntity
489 (
490 XMLResourceIdentifier* resourceIdentifier
491 );
492
505 virtual void startInputSource(const InputSource& inputSource);
506
508
509 // -----------------------------------------------------------------------
510 // Grammar preparsing interface
511 // -----------------------------------------------------------------------
512
541 Grammar* loadGrammar(const InputSource& source,
542 const Grammar::GrammarType grammarType,
543 const bool toCache = false);
544
569 Grammar* loadGrammar(const XMLCh* const systemId,
570 const Grammar::GrammarType grammarType,
571 const bool toCache = false);
572
596 Grammar* loadGrammar(const char* const systemId,
597 const Grammar::GrammarType grammarType,
598 const bool toCache = false);
599
603 void resetCachedGrammarPool();
604
606
607
608private :
609 // -----------------------------------------------------------------------
610 // Initialize/Cleanup methods
611 // -----------------------------------------------------------------------
612 void resetParse();
613
614 // -----------------------------------------------------------------------
615 // Unimplemented constructors and operators
616 // -----------------------------------------------------------------------
617 XercesDOMParser(const XercesDOMParser&);
618 XercesDOMParser& operator=(const XercesDOMParser&);
619
620 // -----------------------------------------------------------------------
621 // Private data members
622 //
623 // fEntityResolver
624 // The installed SAX entity resolver, if any. Null if none.
625 //
626 // fErrorHandler
627 // The installed SAX error handler, if any. Null if none.
628 //-----------------------------------------------------------------------
629 EntityResolver* fEntityResolver;
630 XMLEntityResolver* fXMLEntityResolver;
631 ErrorHandler* fErrorHandler;
632};
633
634
635
636// ---------------------------------------------------------------------------
637// XercesDOMParser: Handlers for the XMLEntityHandler interface
638// ---------------------------------------------------------------------------
639 inline void XercesDOMParser::endInputSource(const InputSource&)
640{
641 // The DOM entity resolver doesn't handle this
642}
643
644 inline bool XercesDOMParser::expandSystemId(const XMLCh* const, XMLBuffer&)
645{
646 // The DOM entity resolver doesn't handle this
647 return false;
648}
649
650 inline void XercesDOMParser::resetEntities()
651{
652 // Nothing to do on this one
653}
654
655 inline void XercesDOMParser::startInputSource(const InputSource&)
656{
657 // The DOM entity resolver doesn't handle this
658}
659
660
661// ---------------------------------------------------------------------------
662// XercesDOMParser: Getter methods
663// ---------------------------------------------------------------------------
664 inline ErrorHandler* XercesDOMParser::getErrorHandler()
665{
666 return fErrorHandler;
667}
668
669 inline const ErrorHandler* XercesDOMParser::getErrorHandler() const
670{
671 return fErrorHandler;
672}
673
674 inline EntityResolver* XercesDOMParser::getEntityResolver()
675{
676 return fEntityResolver;
677}
678
679 inline const EntityResolver* XercesDOMParser::getEntityResolver() const
680{
681 return fEntityResolver;
682}
683
684 inline XMLEntityResolver* XercesDOMParser::getXMLEntityResolver()
685{
686 return fXMLEntityResolver;
687}
688
689 inline const XMLEntityResolver* XercesDOMParser::getXMLEntityResolver() const
690{
691 return fXMLEntityResolver;
692}
693
694 XERCES_CPP_NAMESPACE_END
695
696#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.