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
27#include <xercesc/validators/common/Grammar.hpp>
28
30
31
32class EntityResolver;
33class ErrorHandler;
36
48{
49public :
50 // -----------------------------------------------------------------------
51 // Constructors and Destructor
52 // -----------------------------------------------------------------------
53
72 (
73 XMLValidator* const valToAdopt = 0
75 , XMLGrammarPool* const gramPool = 0
76 );
77
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
160
172
179 Grammar* getGrammar(const XMLCh* const nameSpaceKey);
180
186 Grammar* getRootGrammar();
187
194 const XMLCh* getURIText(unsigned int uriId) const;
195
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
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
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
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
604
606
607
608private :
609 // -----------------------------------------------------------------------
610 // Initialize/Cleanup methods
611 // -----------------------------------------------------------------------
612 void resetParse();
613
614 // -----------------------------------------------------------------------
615 // Unimplemented constructors and operators
616 // -----------------------------------------------------------------------
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// ---------------------------------------------------------------------------
640{
641 // The DOM entity resolver doesn't handle this
642}
643
644inline bool XercesDOMParser::expandSystemId(const XMLCh* const, XMLBuffer&)
645{
646 // The DOM entity resolver doesn't handle this
647 return false;
648}
649
651{
652 // Nothing to do on this one
653}
654
656{
657 // The DOM entity resolver doesn't handle this
658}
659
660
661// ---------------------------------------------------------------------------
662// XercesDOMParser: Getter methods
663// ---------------------------------------------------------------------------
665{
666 return fErrorHandler;
667}
668
670{
671 return fErrorHandler;
672}
673
675{
676 return fEntityResolver;
677}
678
680{
681 return fEntityResolver;
682}
683
685{
686 return fXMLEntityResolver;
687}
688
690{
691 return fXMLEntityResolver;
692}
693
695
696#endif
#define PARSERS_EXPORT
Definition XercesDefs.hpp:168
#define XERCES_CPP_NAMESPACE_BEGIN
Definition XercesDefs.hpp:112
#define XERCES_CPP_NAMESPACE_END
Definition XercesDefs.hpp:113
char16_t XMLCh
Definition Xerces_autoconf_config.hpp:120
XMLUInt64 XMLFilePos
Definition Xerces_autoconf_config.hpp:139
XMLUInt64 XMLFileLoc
Definition Xerces_autoconf_config.hpp:144
This class implements the Document Object Model (DOM) interface.
Definition AbstractDOMParser.hpp:62
Basic interface for resolving entities.
Definition EntityResolver.hpp:87
Basic interface for SAX error handlers.
Definition ErrorHandler.hpp:61
A single input source for an XML entity.
Definition InputSource.hpp:63
Configurable memory manager.
Definition MemoryManager.hpp:40
virtual void startInputSource(const InputSource &inputSource)=0
This method will be called before the scanner starts reading from an input source while processing ex...
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 ...
virtual void resetEntities()=0
This method allows the entity handler to reset itself, so that it can be used again.
virtual void endInputSource(const InputSource &inputSource)=0
This method get called after the scanner has finished reading from the given input source while proce...
Revised interface for resolving entities.
Definition XMLEntityResolver.hpp:100
ErrTypes
Definition XMLErrorReporter.hpp:49
Definition XMLGrammarPool.hpp:44
static MemoryManager * fgMemoryManager
The configurable memory manager.
Definition PlatformUtils.hpp:121
Definition XMLResourceIdentifier.hpp:96
This abstract class provides the interface for all validators.
Definition XMLValidator.hpp:53
This class implements the Document Object Model (DOM) interface.
Definition XercesDOMParser.hpp:48
virtual void startInputSource(const InputSource &inputSource)
Handle a 'start input source' event.
Definition XercesDOMParser.hpp:655
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.
Grammar * getRootGrammar()
Retrieve the grammar where the root element is declared.
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.
virtual InputSource * resolveEntity(XMLResourceIdentifier *resourceIdentifier)
Resolve a public/system id.
void cacheGrammarFromParse(const bool newState)
Set the 'Grammar caching' flag.
XMLEntityResolver * getXMLEntityResolver()
Get a pointer to the entity resolver.
Definition XercesDOMParser.hpp:684
void resetCachedGrammarPool()
This method allows the user to reset the pool of cached grammars.
bool getIgnoreCachedDTD() const
Get the 'ignore cached DTD grammar' flag.
virtual void resetErrors()
Reset any error data before a new parse.
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.
void setErrorHandler(ErrorHandler *const handler)
Set the error handler.
XercesDOMParser(XMLValidator *const valToAdopt=0, MemoryManager *const manager=XMLPlatformUtils::fgMemoryManager, XMLGrammarPool *const gramPool=0)
Construct a XercesDOMParser, with an optional validator.
void setIgnoreCachedDTD(const bool newValue)
Set the 'ignore cached DTD grammar' flag.
void resetDocumentPool()
Reset the documents vector pool and release all the associated memory back to the system.
bool isUsingCachedGrammarInParse() const
Get the 'Use cached grammar' flag.
void setEntityResolver(EntityResolver *const handler)
Set the entity resolver.
Grammar * getGrammar(const XMLCh *const nameSpaceKey)
Retrieve the grammar that is associated with the specified namespace key.
const XMLCh * getURIText(unsigned int uriId) const
Returns the string corresponding to a URI id from the URI string pool.
virtual void resetEntities()
Reset any entity handler information.
Definition XercesDOMParser.hpp:650
virtual ~XercesDOMParser()
Destructor.
virtual bool expandSystemId(const XMLCh *const systemId, XMLBuffer &toFill)
Expand a system id.
Definition XercesDOMParser.hpp:644
XMLFilePos getSrcOffset() const
Returns the current src offset within the input source.
void setXMLEntityResolver(XMLEntityResolver *const handler)
Set the entity resolver.
ErrorHandler * getErrorHandler()
Get a pointer to the error handler.
Definition XercesDOMParser.hpp:664
void useCachedGrammarInParse(const bool newState)
Set the 'Use cached grammar' flag.
EntityResolver * getEntityResolver()
Get a pointer to the entity resolver.
Definition XercesDOMParser.hpp:674
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.
virtual void endInputSource(const InputSource &inputSource)
Handle an end of input source event.
Definition XercesDOMParser.hpp:639
bool isCachingGrammarFromParse() const
Get the 'Grammar caching' flag.