- Main Page
- Related Pages
- Classes
- Files

# 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 932887 2010-04-11 13:04:59Z 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 Destructor
    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
    00541     Grammar* loadGrammar(const InputSource& source,
    00542                          const Grammar::GrammarType grammarType,
    00543                          const bool toCache = false);
    00544
    00569     Grammar* loadGrammar(const XMLCh* const systemId,
    00570                          const Grammar::GrammarType grammarType,
    00571                          const bool toCache = false);
    00572
    00596     Grammar* loadGrammar(const char* const systemId,
    00597                          const Grammar::GrammarType grammarType,
    00598                          const bool toCache = false);
    00599
    00603     void resetCachedGrammarPool();
    00604
    00606
    00607
    00608 private :
    00609     // -----------------------------------------------------------------------
    00610     //  Initialize/Cleanup methods
    00611     // -----------------------------------------------------------------------
    00612     void resetParse();
    00613
    00614     // -----------------------------------------------------------------------
    00615     //  Unimplemented constructors and operators
    00616     // -----------------------------------------------------------------------
    00617     XercesDOMParser(const XercesDOMParser&);
    00618     XercesDOMParser& operator=(const XercesDOMParser&);
    00619
    00620     // -----------------------------------------------------------------------
    00621     //  Private data members
    00622     //
    00623     //  fEntityResolver
    00624     //      The installed SAX entity resolver, if any. Null if none.
    00625     //
    00626     //  fErrorHandler
    00627     //      The installed SAX error handler, if any. Null if none.
    00628     //-----------------------------------------------------------------------
    00629     EntityResolver*          fEntityResolver;
    00630     XMLEntityResolver*       fXMLEntityResolver;
    00631     ErrorHandler*            fErrorHandler;
    00632 };
    00633
    00634
    00635
    00636 // ---------------------------------------------------------------------------
    00637 //  XercesDOMParser: Handlers for the XMLEntityHandler interface
    00638 // ---------------------------------------------------------------------------
    00639 inline void XercesDOMParser::endInputSource(const InputSource&)
    00640 {
    00641     // The DOM entity resolver doesn't handle this
    00642 }
    00643
    00644 inline bool XercesDOMParser::expandSystemId(const XMLCh* const, XMLBuffer&)
    00645 {
    00646     // The DOM entity resolver doesn't handle this
    00647     return false;
    00648 }
    00649
    00650 inline void XercesDOMParser::resetEntities()
    00651 {
    00652     // Nothing to do on this one
    00653 }
    00654
    00655 inline void XercesDOMParser::startInputSource(const InputSource&)
    00656 {
    00657     // The DOM entity resolver doesn't handle this
    00658 }
    00659
    00660
    00661 // ---------------------------------------------------------------------------
    00662 //  XercesDOMParser: Getter methods
    00663 // ---------------------------------------------------------------------------
    00664 inline ErrorHandler* XercesDOMParser::getErrorHandler()
    00665 {
    00666     return fErrorHandler;
    00667 }
    00668
    00669 inline const ErrorHandler* XercesDOMParser::getErrorHandler() const
    00670 {
    00671     return fErrorHandler;
    00672 }
    00673
    00674 inline EntityResolver* XercesDOMParser::getEntityResolver()
    00675 {
    00676     return fEntityResolver;
    00677 }
    00678
    00679 inline const EntityResolver* XercesDOMParser::getEntityResolver() const
    00680 {
    00681     return fEntityResolver;
    00682 }
    00683
    00684 inline XMLEntityResolver* XercesDOMParser::getXMLEntityResolver()
    00685 {
    00686     return fXMLEntityResolver;
    00687 }
    00688
    00689 inline const XMLEntityResolver* XercesDOMParser::getXMLEntityResolver() const
    00690 {
    00691     return fXMLEntityResolver;
    00692 }
    00693
    00694 XERCES_CPP_NAMESPACE_END
    00695
    00696 #endif