Xerces-C++  3.1.2
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 
27 #include <xercesc/validators/common/Grammar.hpp>
28 
30 
31 
32 class EntityResolver;
33 class ErrorHandler;
34 class XMLEntityResolver;
36 
48 {
49 public :
50  // -----------------------------------------------------------------------
51  // Constructors and Destructor
52  // -----------------------------------------------------------------------
53 
72  (
73  XMLValidator* const valToAdopt = 0
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  // -----------------------------------------------------------------------
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 
644 inline 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
XMLEntityResolver * getXMLEntityResolver()
Get a pointer to the entity resolver.
Definition: XercesDOMParser.hpp:684
XMLUInt64 XMLFilePos
Definition: Xerces_autoconf_config.borland.hpp:111
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.
virtual void resetEntities()=0
This method allows the entity handler to reset itself, so that it can be used again.
static MemoryManager * fgMemoryManager
The configurable memory manager.
Definition: PlatformUtils.hpp:121
virtual void endInputSource(const InputSource &inputSource)=0
This method get called after the scanner has finished reading from the given input source while proce...
ErrorHandler * getErrorHandler()
Get a pointer to the error handler.
Definition: XercesDOMParser.hpp:664
#define PARSERS_EXPORT
Definition: XercesDefs.hpp:168
XMLUInt64 XMLFileLoc
Definition: Xerces_autoconf_config.borland.hpp:116
Definition: XMLGrammarPool.hpp:43
This class implements the Document Object Model (DOM) interface.
Definition: AbstractDOMParser.hpp:54
virtual void resetErrors()=0
Called before a new parse event to allow the handler to reset.
Basic interface for resolving entities.
Definition: EntityResolver.hpp:86
EntityResolver * getEntityResolver()
Get a pointer to the entity resolver.
Definition: XercesDOMParser.hpp:674
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 ...
Basic interface for SAX error handlers.
Definition: ErrorHandler.hpp:60
ErrTypes
Definition: XMLErrorReporter.hpp:48
virtual bool expandSystemId(const XMLCh *const systemId, XMLBuffer &toFill)
Expand a system id.
Definition: XercesDOMParser.hpp:644
virtual void startInputSource(const InputSource &inputSource)
Handle a 'start input source' event.
Definition: XercesDOMParser.hpp:655
Configurable memory manager.
Definition: MemoryManager.hpp:39
virtual void resetEntities()
Reset any entity handler information.
Definition: XercesDOMParser.hpp:650
#define XERCES_CPP_NAMESPACE_BEGIN
Definition: XercesDefs.hpp:112
Definition: XMLResourceIdentifier.hpp:95
virtual void startInputSource(const InputSource &inputSource)=0
This method will be called before the scanner starts reading from an input source while processing ex...
wchar_t XMLCh
Definition: Xerces_autoconf_config.borland.hpp:92
This abstract class provides the interface for all validators.
Definition: XMLValidator.hpp:52
#define XERCES_CPP_NAMESPACE_END
Definition: XercesDefs.hpp:113
This class implements the Document Object Model (DOM) interface.
Definition: XercesDOMParser.hpp:47
virtual void endInputSource(const InputSource &inputSource)
Handle an end of input source event.
Definition: XercesDOMParser.hpp:639
virtual InputSource * resolveEntity(XMLResourceIdentifier *resourceIdentifier)=0
This method allows the entity handler to provide customized application specific entity resolution...
A single input source for an XML entity.
Definition: InputSource.hpp:62
Revised interface for resolving entities.
Definition: XMLEntityResolver.hpp:99