Xerces-C++: XercesDOMParser.hpp Source File

- Main Page
- Classes
- Files
- Related Pages

# XercesDOMParser.hpp

Go to the documentation of this file.

    00001 /*
    00002  * Licensed to the Apache Software Foundation (ASF) under one or more
    00003  * contributor license agreements.  See the NOTICE file distributed with
    00004  * this work for additional information regarding copyright ownership.
    00005  * The ASF licenses this file to You under the Apache License, Version 2.0
    00006  * (the "License"); you may not use this file except in compliance with
    00007  * the License.  You may obtain a copy of the License at
    00008  *
    00009  *      http://www.apache.org/licenses/LICENSE-2.0
    00010  *
    00011  * Unless required by applicable law or agreed to in writing, software
    00012  * distributed under the License is distributed on an "AS IS" BASIS,
    00013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    00014  * See the License for the specific language governing permissions and
    00015  * limitations under the License.
    00016  */
    00017
    00018 /*
    00019  * $Id: XercesDOMParser.hpp 673944 2008-07-04 07:53:16Z borisk $
    00020  */
    00021
    00022 #if !defined(XERCESC_INCLUDE_GUARD_XERCESDOMPARSER_HPP)
    00023 #define XERCESC_INCLUDE_GUARD_XERCESDOMPARSER_HPP
    00024
    00025
    00026 #include <xercesc/parsers/AbstractDOMParser.hpp>
    00027 #include <xercesc/validators/common/Grammar.hpp>
    00028
    00029 XERCES_CPP_NAMESPACE_BEGIN
    00030
    00031
    00032 class EntityResolver;
    00033 class ErrorHandler;
    00034 class XMLEntityResolver;
    00035 class XMLResourceIdentifier;
    00036
    00047 class PARSERS_EXPORT XercesDOMParser : public AbstractDOMParser
    00048 {
    00049 public :
    00050     // -----------------------------------------------------------------------
    00051     //  Constructors and Detructor
    00052     // -----------------------------------------------------------------------
    00053
    00071     XercesDOMParser
    00072     (
    00073           XMLValidator* const   valToAdopt = 0
    00074         , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
    00075         , XMLGrammarPool* const gramPool = 0
    00076     );
    00077
    00081     virtual ~XercesDOMParser();
    00082
    00084
    00085
    00086     // -----------------------------------------------------------------------
    00087     //  Getter methods
    00088     // -----------------------------------------------------------------------
    00089
    00092
    00100     ErrorHandler* getErrorHandler();
    00101
    00109     const ErrorHandler* getErrorHandler() const;
    00110
    00118     EntityResolver* getEntityResolver();
    00119
    00127     const EntityResolver* getEntityResolver() const;
    00128
    00137     XMLEntityResolver* getXMLEntityResolver();
    00138
    00147     const XMLEntityResolver* getXMLEntityResolver() const;
    00148
    00159     bool isCachingGrammarFromParse() const;
    00160
    00171     bool isUsingCachedGrammarInParse() const;
    00172
    00179     Grammar* getGrammar(const XMLCh* const nameSpaceKey);
    00180
    00186     Grammar* getRootGrammar();
    00187
    00194     const XMLCh* getURIText(unsigned int uriId) const;
    00195
    00202     XMLFilePos getSrcOffset() const;
    00203
    00211     bool getIgnoreCachedDTD() const;
    00212
    00214
    00215
    00216     // -----------------------------------------------------------------------
    00217     //  Setter methods
    00218     // -----------------------------------------------------------------------
    00219
    00222
    00236     void setErrorHandler(ErrorHandler* const handler);
    00237
    00254     void setEntityResolver(EntityResolver* const handler);
    00255
    00273     void setXMLEntityResolver(XMLEntityResolver* const handler);
    00274
    00292     void cacheGrammarFromParse(const bool newState);
    00293
    00312     void useCachedGrammarInParse(const bool newState);
    00313
    00328     void setIgnoreCachedDTD(const bool newValue);
    00329
    00331
    00332     // -----------------------------------------------------------------------
    00333     //  Utility methods
    00334     // -----------------------------------------------------------------------
    00335
    00361     void resetDocumentPool();
    00362
    00364
    00365     // -----------------------------------------------------------------------
    00366     //  Implementation of the XMLErrorReporter interface.
    00367     // -----------------------------------------------------------------------
    00368
    00371
    00396     virtual void error
    00397     (
    00398         const   unsigned int                errCode
    00399         , const XMLCh* const                msgDomain
    00400         , const XMLErrorReporter::ErrTypes  errType
    00401         , const XMLCh* const                errorText
    00402         , const XMLCh* const                systemId
    00403         , const XMLCh* const                publicId
    00404         , const XMLFileLoc                  lineNum
    00405         , const XMLFileLoc                  colNum
    00406     );
    00407
    00416     virtual void resetErrors();
    00418
    00419
    00420     // -----------------------------------------------------------------------
    00421     //  Implementation of the XMLEntityHandler interface.
    00422     // -----------------------------------------------------------------------
    00423
    00426
    00439     virtual void endInputSource(const InputSource& inputSource);
    00440
    00456     virtual bool expandSystemId
    00457     (
    00458         const   XMLCh* const    systemId
    00459         ,       XMLBuffer&      toFill
    00460     );
    00461
    00470     virtual void resetEntities();
    00471
    00488     virtual InputSource* resolveEntity
    00489     (
    00490         XMLResourceIdentifier* resourceIdentifier
    00491     );
    00492
    00505     virtual void startInputSource(const InputSource& inputSource);
    00506
    00508
    00509     // -----------------------------------------------------------------------
    00510     //  Grammar preparsing interface
    00511     // -----------------------------------------------------------------------
    00512
    00542     Grammar* loadGrammar(const InputSource& source,
    00543                          const Grammar::GrammarType grammarType,
    00544                          const bool toCache = false);
    00545
    00571     Grammar* loadGrammar(const XMLCh* const systemId,
    00572                          const Grammar::GrammarType grammarType,
    00573                          const bool toCache = false);
    00574
    00599     Grammar* loadGrammar(const char* const systemId,
    00600                          const Grammar::GrammarType grammarType,
    00601                          const bool toCache = false);
    00602
    00606     void resetCachedGrammarPool();
    00607
    00609
    00610
    00611 private :
    00612     // -----------------------------------------------------------------------
    00613     //  Initialize/Cleanup methods
    00614     // -----------------------------------------------------------------------
    00615     void resetParse();
    00616
    00617     // -----------------------------------------------------------------------
    00618     //  Unimplemented constructors and operators
    00619     // -----------------------------------------------------------------------
    00620     XercesDOMParser(const XercesDOMParser&);
    00621     XercesDOMParser& operator=(const XercesDOMParser&);
    00622
    00623     // -----------------------------------------------------------------------
    00624     //  Private data members
    00625     //
    00626     //  fEntityResolver
    00627     //      The installed SAX entity resolver, if any. Null if none.
    00628     //
    00629     //  fErrorHandler
    00630     //      The installed SAX error handler, if any. Null if none.
    00631     //-----------------------------------------------------------------------
    00632     EntityResolver*          fEntityResolver;
    00633     XMLEntityResolver*       fXMLEntityResolver;
    00634     ErrorHandler*            fErrorHandler;
    00635 };
    00636
    00637
    00638
    00639 // ---------------------------------------------------------------------------
    00640 //  XercesDOMParser: Handlers for the XMLEntityHandler interface
    00641 // ---------------------------------------------------------------------------
    00642 inline void XercesDOMParser::endInputSource(const InputSource&)
    00643 {
    00644     // The DOM entity resolver doesn't handle this
    00645 }
    00646
    00647 inline bool XercesDOMParser::expandSystemId(const XMLCh* const, XMLBuffer&)
    00648 {
    00649     // The DOM entity resolver doesn't handle this
    00650     return false;
    00651 }
    00652
    00653 inline void XercesDOMParser::resetEntities()
    00654 {
    00655     // Nothing to do on this one
    00656 }
    00657
    00658 inline void XercesDOMParser::startInputSource(const InputSource&)
    00659 {
    00660     // The DOM entity resolver doesn't handle this
    00661 }
    00662
    00663
    00664 // ---------------------------------------------------------------------------
    00665 //  XercesDOMParser: Getter methods
    00666 // ---------------------------------------------------------------------------
    00667 inline ErrorHandler* XercesDOMParser::getErrorHandler()
    00668 {
    00669     return fErrorHandler;
    00670 }
    00671
    00672 inline const ErrorHandler* XercesDOMParser::getErrorHandler() const
    00673 {
    00674     return fErrorHandler;
    00675 }
    00676
    00677 inline EntityResolver* XercesDOMParser::getEntityResolver()
    00678 {
    00679     return fEntityResolver;
    00680 }
    00681
    00682 inline const EntityResolver* XercesDOMParser::getEntityResolver() const
    00683 {
    00684     return fEntityResolver;
    00685 }
    00686
    00687 inline XMLEntityResolver* XercesDOMParser::getXMLEntityResolver()
    00688 {
    00689     return fXMLEntityResolver;
    00690 }
    00691
    00692 inline const XMLEntityResolver* XercesDOMParser::getXMLEntityResolver() const
    00693 {
    00694     return fXMLEntityResolver;
    00695 }
    00696
    00697 XERCES_CPP_NAMESPACE_END
    00698
    00699 #endif