Xerces-C++ 3.1.2

- Main Page
- Related Pages
- Classes
- Files

- File List
- File Members

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: XercesDOMParser.hpp 932887 2010-04-11 13:04:59Z borisk $
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
32 class EntityResolver;
33 class ErrorHandler;
34 class XMLEntityResolver;
35 class XMLResourceIdentifier;
36
47 class PARSERS_EXPORT XercesDOMParser : public AbstractDOMParser
48 {
49 public :
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
608 private :
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
XercesDOMParser::getXMLEntityResolver
XMLEntityResolver * getXMLEntityResolver()
Get a pointer to the entity resolver.
Definition: XercesDOMParser.hpp:684
XMLFilePos
XMLUInt64 XMLFilePos
Definition: Xerces_autoconf_config.borland.hpp:111
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.
XMLEntityHandler::resetEntities
virtual void resetEntities()=0
This method allows the entity handler to reset itself, so that it can be used again.
XMLPlatformUtils::fgMemoryManager
static MemoryManager * fgMemoryManager
The configurable memory manager.
Definition: PlatformUtils.hpp:121
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...
XercesDOMParser::getErrorHandler
ErrorHandler * getErrorHandler()
Get a pointer to the error handler.
Definition: XercesDOMParser.hpp:664
PARSERS_EXPORT
#define PARSERS_EXPORT
Definition: XercesDefs.hpp:168
XMLFileLoc
XMLUInt64 XMLFileLoc
Definition: Xerces_autoconf_config.borland.hpp:116
XMLGrammarPool
Definition: XMLGrammarPool.hpp:43
AbstractDOMParser
This class implements the Document Object Model (DOM) interface.
Definition: AbstractDOMParser.hpp:54
XMLErrorReporter::resetErrors
virtual void resetErrors()=0
Called before a new parse event to allow the handler to reset.
EntityResolver
Basic interface for resolving entities.
Definition: EntityResolver.hpp:86
AbstractDOMParser.hpp
XercesDOMParser::getEntityResolver
EntityResolver * getEntityResolver()
Get a pointer to the entity resolver.
Definition: XercesDOMParser.hpp:674
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 ...
ErrorHandler
Basic interface for SAX error handlers.
Definition: ErrorHandler.hpp:60
XMLErrorReporter::ErrTypes
ErrTypes
Definition: XMLErrorReporter.hpp:48
XercesDOMParser::expandSystemId
virtual bool expandSystemId(const XMLCh *const systemId, XMLBuffer &toFill)
Expand a system id.
Definition: XercesDOMParser.hpp:644
XercesDOMParser::startInputSource
virtual void startInputSource(const InputSource &inputSource)
Handle a 'start input source' event.
Definition: XercesDOMParser.hpp:655
MemoryManager
Configurable memory manager.
Definition: MemoryManager.hpp:39
XercesDOMParser::resetEntities
virtual void resetEntities()
Reset any entity handler information.
Definition: XercesDOMParser.hpp:650
XERCES_CPP_NAMESPACE_BEGIN
#define XERCES_CPP_NAMESPACE_BEGIN
Definition: XercesDefs.hpp:112
XMLResourceIdentifier
Definition: XMLResourceIdentifier.hpp:95
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...
XMLCh
wchar_t XMLCh
Definition: Xerces_autoconf_config.borland.hpp:92
XMLValidator
This abstract class provides the interface for all validators.
Definition: XMLValidator.hpp:52
XERCES_CPP_NAMESPACE_END
#define XERCES_CPP_NAMESPACE_END
Definition: XercesDefs.hpp:113
XercesDOMParser
This class implements the Document Object Model (DOM) interface.
Definition: XercesDOMParser.hpp:47
XercesDOMParser::endInputSource
virtual void endInputSource(const InputSource &inputSource)
Handle an end of input source event.
Definition: XercesDOMParser.hpp:639
XMLEntityHandler::resolveEntity
virtual InputSource * resolveEntity(XMLResourceIdentifier *resourceIdentifier)=0
This method allows the entity handler to provide customized application specific entity resolution...
InputSource
A single input source for an XML entity.
Definition: InputSource.hpp:62
XMLEntityResolver
Revised interface for resolving entities.
Definition: XMLEntityResolver.hpp:99