Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:14:54

0001 /*
0002  * Licensed to the Apache Software Foundation (ASF) under one or more
0003  * contributor license agreements.  See the NOTICE file distributed with
0004  * this work for additional information regarding copyright ownership.
0005  * The ASF licenses this file to You under the Apache License, Version 2.0
0006  * (the "License"); you may not use this file except in compliance with
0007  * the License.  You may obtain a copy of the License at
0008  *
0009  *      http://www.apache.org/licenses/LICENSE-2.0
0010  *
0011  * Unless required by applicable law or agreed to in writing, software
0012  * distributed under the License is distributed on an "AS IS" BASIS,
0013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0014  * See the License for the specific language governing permissions and
0015  * limitations under the License.
0016  */
0017 
0018 /*
0019  * $Id$
0020  */
0021 
0022 #if !defined(XERCESC_INCLUDE_GUARD_DGXMLSCANNER_HPP)
0023 #define XERCESC_INCLUDE_GUARD_DGXMLSCANNER_HPP
0024 
0025 #include <xercesc/internal/XMLScanner.hpp>
0026 #include <xercesc/util/ValueVectorOf.hpp>
0027 #include <xercesc/util/NameIdPool.hpp>
0028 #include <xercesc/util/Hash2KeysSetOf.hpp>
0029 #include <xercesc/validators/common/Grammar.hpp>
0030 
0031 XERCES_CPP_NAMESPACE_BEGIN
0032 
0033 class DTDElementDecl;
0034 class DTDGrammar;
0035 class DTDValidator;
0036 
0037 //  This is an integrated scanner class, which does DTD/XML Schema grammar
0038 //  processing.
0039 class XMLPARSER_EXPORT DGXMLScanner : public XMLScanner
0040 {
0041 public :
0042     // -----------------------------------------------------------------------
0043     //  Constructors and Destructor
0044     // -----------------------------------------------------------------------
0045     DGXMLScanner
0046     (
0047           XMLValidator* const  valToAdopt
0048         , GrammarResolver* const grammarResolver
0049         , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
0050     );
0051     DGXMLScanner
0052     (
0053           XMLDocumentHandler* const docHandler
0054         , DocTypeHandler* const     docTypeHandler
0055         , XMLEntityHandler* const   entityHandler
0056         , XMLErrorReporter* const   errReporter
0057         , XMLValidator* const       valToAdopt
0058         , GrammarResolver* const    grammarResolver
0059         , MemoryManager* const      manager = XMLPlatformUtils::fgMemoryManager
0060     );
0061     virtual ~DGXMLScanner();
0062 
0063     // -----------------------------------------------------------------------
0064     //  XMLScanner public virtual methods
0065     // -----------------------------------------------------------------------
0066     virtual const XMLCh* getName() const;
0067     virtual NameIdPool<DTDEntityDecl>* getEntityDeclPool();
0068     virtual const NameIdPool<DTDEntityDecl>* getEntityDeclPool() const;
0069     virtual void scanDocument
0070     (
0071         const   InputSource&    src
0072     );
0073     virtual bool scanNext(XMLPScanToken& toFill);
0074     virtual Grammar* loadGrammar
0075     (
0076         const   InputSource&    src
0077         , const short           grammarType
0078         , const bool            toCache = false
0079     );
0080 
0081     virtual Grammar::GrammarType getCurrentGrammarType() const;
0082 
0083 private :
0084     // -----------------------------------------------------------------------
0085     //  Unimplemented constructors and operators
0086     // -----------------------------------------------------------------------
0087     DGXMLScanner();
0088     DGXMLScanner(const DGXMLScanner&);
0089     DGXMLScanner& operator=(const DGXMLScanner&);
0090 
0091     // -----------------------------------------------------------------------
0092     //  XMLScanner virtual methods
0093     // -----------------------------------------------------------------------
0094     virtual void scanCDSection();
0095     virtual void scanCharData(XMLBuffer& toToUse);
0096     virtual EntityExpRes scanEntityRef
0097     (
0098         const   bool    inAttVal
0099         ,       XMLCh&  firstCh
0100         ,       XMLCh&  secondCh
0101         ,       bool&   escaped
0102     );
0103     virtual void scanDocTypeDecl();
0104     virtual void scanReset(const InputSource& src);
0105     virtual void sendCharData(XMLBuffer& toSend);
0106     virtual InputSource* resolveSystemId(const XMLCh* const sysId
0107                                         ,const XMLCh* const pubId);
0108 
0109     // -----------------------------------------------------------------------
0110     //  Private helper methods
0111     // -----------------------------------------------------------------------
0112     void commonInit();
0113     void cleanUp();
0114 
0115     XMLSize_t buildAttList
0116     (
0117         const XMLSize_t                     attCount
0118         ,       XMLElementDecl*             elemDecl
0119         ,       RefVectorOf<XMLAttr>&       toFill
0120     );
0121     void updateNSMap
0122     (
0123         const   XMLCh* const attrPrefix
0124         , const XMLCh* const attrLocalName
0125         , const XMLCh* const attrValue
0126     );
0127     void scanAttrListforNameSpaces(RefVectorOf<XMLAttr>* theAttrList, XMLSize_t attCount, XMLElementDecl* elemDecl);
0128 
0129     // -----------------------------------------------------------------------
0130     //  Private scanning methods
0131     // -----------------------------------------------------------------------
0132     bool scanAttValue
0133     (
0134         const   XMLAttDef* const    attDef
0135         , const XMLCh *const        attrName
0136         ,       XMLBuffer&          toFill
0137     );
0138     bool scanContent();
0139     void scanEndTag(bool& gotData);
0140     bool scanStartTag(bool& gotData);
0141     bool scanStartTagNS(bool& gotData);
0142 
0143     // -----------------------------------------------------------------------
0144     //  Grammar preparsing methods
0145     // -----------------------------------------------------------------------
0146     Grammar* loadDTDGrammar(const InputSource& src, const bool toCache = false);
0147 
0148     // -----------------------------------------------------------------------
0149     //  Data members
0150     //
0151     //  fRawAttrList
0152     //      During the initial scan of the attributes we can only do a raw
0153     //      scan for key/value pairs. So this vector is used to store them
0154     //      until they can be processed (and put into fAttrList.)
0155     //
0156     //  fDTDValidator
0157     //      The DTD validator instance.
0158     //
0159     // fDTDElemNonDeclPool
0160     //     registry of "faulted-in" DTD element decls
0161     // fElemCount
0162     //      count of the number of start tags seen so far (starts at 1).
0163     //      Used for duplicate attribute detection/processing of required/defaulted attributes
0164     // fAttDefRegistry
0165     //      mapping from XMLAttDef instances to the count of the last
0166     //      start tag where they were utilized.
0167     // fUndeclaredAttrRegistry
0168     //      mapping of attr QNames to detect duplicates
0169     //
0170     // -----------------------------------------------------------------------
0171     ValueVectorOf<XMLAttr*>*    fAttrNSList;
0172     DTDValidator*               fDTDValidator;
0173     DTDGrammar*                 fDTDGrammar;
0174     NameIdPool<DTDElementDecl>* fDTDElemNonDeclPool;
0175     unsigned int                fElemCount;
0176     RefHashTableOf<unsigned int, PtrHasher>* fAttDefRegistry;
0177     Hash2KeysSetOf<StringHasher>*            fUndeclaredAttrRegistry;
0178 };
0179 
0180 inline const XMLCh* DGXMLScanner::getName() const
0181 {
0182     return XMLUni::fgDGXMLScanner;
0183 }
0184 
0185 inline Grammar::GrammarType DGXMLScanner::getCurrentGrammarType() const
0186 {
0187     return Grammar::DTDGrammarType;
0188 }
0189 
0190 XERCES_CPP_NAMESPACE_END
0191 
0192 #endif