| API Docs for SAX and DOM |

- 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 568078 2007-08-21 11:43:25Z amassari $
    00020  *
    00021  */
    00022
    00023 #if !defined(XercesDOMParser_HPP)
    00024 #define XercesDOMParser_HPP
    00025
    00026
    00027 #include <xercesc/parsers/AbstractDOMParser.hpp>
    00028
    00029 XERCES_CPP_NAMESPACE_BEGIN
    00030
    00031
    00032 class EntityResolver;
    00033 class ErrorHandler;
    00034 class Grammar;
    00035 class XMLEntityResolver;
    00036 class XMLResourceIdentifier;
    00037
    00048 class  XercesDOMParser : public AbstractDOMParser
    00049 {
    00050 public :
    00051     // -----------------------------------------------------------------------
    00052     //  Constructors and Detructor
    00053     // -----------------------------------------------------------------------
    00054
    00072     XercesDOMParser
    00073     (
    00074           XMLValidator* const   valToAdopt = 0
    00075         , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
    00076         , XMLGrammarPool* const gramPool = 0
    00077     );
    00078
    00082     virtual ~XercesDOMParser();
    00083
    00085
    00086
    00087     // -----------------------------------------------------------------------
    00088     //  Getter methods
    00089     // -----------------------------------------------------------------------
    00090
    00093
    00101     ErrorHandler* getErrorHandler();
    00102
    00110     const ErrorHandler* getErrorHandler() const;
    00111
    00119     EntityResolver* getEntityResolver();
    00120
    00128     const EntityResolver* getEntityResolver() const;
    00129
    00138     XMLEntityResolver* getXMLEntityResolver();
    00139
    00148     const XMLEntityResolver* getXMLEntityResolver() const;
    00149
    00160     bool isCachingGrammarFromParse() const;
    00161
    00172     bool isUsingCachedGrammarInParse() const;
    00173
    00180     Grammar* getGrammar(const XMLCh* const nameSpaceKey);
    00181
    00187     Grammar* getRootGrammar();
    00188
    00195     const XMLCh* getURIText(unsigned int uriId) const;
    00196
    00203     unsigned int getSrcOffset() const;
    00204
    00212     bool getIgnoreCachedDTD() const;
    00213
    00215
    00216
    00217     // -----------------------------------------------------------------------
    00218     //  Setter methods
    00219     // -----------------------------------------------------------------------
    00220
    00223
    00237     void setErrorHandler(ErrorHandler* const handler);
    00238
    00255     void setEntityResolver(EntityResolver* const handler);
    00256
    00274     void setXMLEntityResolver(XMLEntityResolver* const handler);
    00275
    00293     void cacheGrammarFromParse(const bool newState);
    00294
    00313     void useCachedGrammarInParse(const bool newState);
    00314
    00329     void setIgnoreCachedDTD(const bool newValue);
    00330
    00332
    00333     // -----------------------------------------------------------------------
    00334     //  Utility methods
    00335     // -----------------------------------------------------------------------
    00336
    00362     void resetDocumentPool();
    00363
    00365
    00366     // -----------------------------------------------------------------------
    00367     //  Implementation of the XMLErrorReporter interface.
    00368     // -----------------------------------------------------------------------
    00369
    00372
    00397     virtual void error
    00398     (
    00399         const   unsigned int                errCode
    00400         , const XMLCh* const                msgDomain
    00401         , const XMLErrorReporter::ErrTypes  errType
    00402         , const XMLCh* const                errorText
    00403         , const XMLCh* const                systemId
    00404         , const XMLCh* const                publicId
    00405         , const XMLSSize_t                  lineNum
    00406         , const XMLSSize_t                  colNum
    00407     );
    00408
    00417     virtual void resetErrors();
    00419
    00420
    00421     // -----------------------------------------------------------------------
    00422     //  Implementation of the XMLEntityHandler interface.
    00423     // -----------------------------------------------------------------------
    00424
    00427
    00440     virtual void endInputSource(const InputSource& inputSource);
    00441
    00457     virtual bool expandSystemId
    00458     (
    00459         const   XMLCh* const    systemId
    00460         ,       XMLBuffer&      toFill
    00461     );
    00462
    00471     virtual void resetEntities();
    00472
    00496     virtual InputSource* resolveEntity
    00497     (
    00498         const   XMLCh* const    publicId
    00499         , const XMLCh* const    systemId
    00500         , const XMLCh* const    baseURI = 0
    00501     );
    00502
    00519     virtual InputSource* resolveEntity
    00520     (
    00521         XMLResourceIdentifier* resourceIdentifier
    00522     );
    00523
    00536     virtual void startInputSource(const InputSource& inputSource);
    00537
    00539
    00540     // -----------------------------------------------------------------------
    00541     //  Grammar preparsing interface
    00542     // -----------------------------------------------------------------------
    00543
    00573     Grammar* loadGrammar(const InputSource& source,
    00574                          const short grammarType,
    00575                          const bool toCache = false);
    00576
    00602     Grammar* loadGrammar(const XMLCh* const systemId,
    00603                          const short grammarType,
    00604                          const bool toCache = false);
    00605
    00630     Grammar* loadGrammar(const char* const systemId,
    00631                          const short grammarType,
    00632                          const bool toCache = false);
    00633
    00637     void resetCachedGrammarPool();
    00638
    00640
    00641
    00642 private :
    00643     // -----------------------------------------------------------------------
    00644     //  Initialize/Cleanup methods
    00645     // -----------------------------------------------------------------------
    00646     void resetParse();
    00647
    00648     // -----------------------------------------------------------------------
    00649     //  Unimplemented constructors and operators
    00650     // -----------------------------------------------------------------------
    00651     XercesDOMParser(const XercesDOMParser&);
    00652     XercesDOMParser& operator=(const XercesDOMParser&);
    00653
    00654     // -----------------------------------------------------------------------
    00655     //  Private data members
    00656     //
    00657     //  fEntityResolver
    00658     //      The installed SAX entity resolver, if any. Null if none.
    00659     //
    00660     //  fErrorHandler
    00661     //      The installed SAX error handler, if any. Null if none.
    00662     //-----------------------------------------------------------------------
    00663     EntityResolver*          fEntityResolver;
    00664     XMLEntityResolver*       fXMLEntityResolver;
    00665     ErrorHandler*            fErrorHandler;
    00666 };
    00667
    00668
    00669
    00670 // ---------------------------------------------------------------------------
    00671 //  XercesDOMParser: Handlers for the XMLEntityHandler interface
    00672 // ---------------------------------------------------------------------------
    00673 inline void XercesDOMParser::endInputSource(const InputSource&)
    00674 {
    00675     // The DOM entity resolver doesn't handle this
    00676 }
    00677
    00678 inline bool XercesDOMParser::expandSystemId(const XMLCh* const, XMLBuffer&)
    00679 {
    00680     // The DOM entity resolver doesn't handle this
    00681     return false;
    00682 }
    00683
    00684 inline void XercesDOMParser::resetEntities()
    00685 {
    00686     // Nothing to do on this one
    00687 }
    00688
    00689 inline void XercesDOMParser::startInputSource(const InputSource&)
    00690 {
    00691     // The DOM entity resolver doesn't handle this
    00692 }
    00693
    00694
    00695 // ---------------------------------------------------------------------------
    00696 //  XercesDOMParser: Getter methods
    00697 // ---------------------------------------------------------------------------
    00698 inline ErrorHandler* XercesDOMParser::getErrorHandler()
    00699 {
    00700     return fErrorHandler;
    00701 }
    00702
    00703 inline const ErrorHandler* XercesDOMParser::getErrorHandler() const
    00704 {
    00705     return fErrorHandler;
    00706 }
    00707
    00708 inline EntityResolver* XercesDOMParser::getEntityResolver()
    00709 {
    00710     return fEntityResolver;
    00711 }
    00712
    00713 inline const EntityResolver* XercesDOMParser::getEntityResolver() const
    00714 {
    00715     return fEntityResolver;
    00716 }
    00717
    00718 inline XMLEntityResolver* XercesDOMParser::getXMLEntityResolver()
    00719 {
    00720     return fXMLEntityResolver;
    00721 }
    00722
    00723 inline const XMLEntityResolver* XercesDOMParser::getXMLEntityResolver() const
    00724 {
    00725     return fXMLEntityResolver;
    00726 }
    00727
    00728 XERCES_CPP_NAMESPACE_END
    00729
    00730 #endif

Copyright © 1994-2004 The Apache Software Foundation. All Rights Reserved.