Xerces-C++ 3.1.3

- 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