secureswitools/swisistools/source/xmlparser/xerces/include/xercesc/internal/DGXMLScanner.hpp
changeset 4 3eebb1e54d3a
parent 3 127731b7107d
child 5 aba6b8104af3
equal deleted inserted replaced
3:127731b7107d 4:3eebb1e54d3a
     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: DGXMLScanner.hpp 568078 2007-08-21 11:43:25Z amassari $
       
    20  */
       
    21 
       
    22 
       
    23 #if !defined(DGXMLSCANNER_HPP)
       
    24 #define DGXMLSCANNER_HPP
       
    25 
       
    26 #include <xercesc/internal/XMLScanner.hpp>
       
    27 #include <xercesc/util/ValueVectorOf.hpp>
       
    28 #include <xercesc/util/NameIdPool.hpp>
       
    29 #include <xercesc/validators/common/Grammar.hpp>
       
    30 
       
    31 XERCES_CPP_NAMESPACE_BEGIN
       
    32 
       
    33 class DTDElementDecl;
       
    34 class DTDGrammar;
       
    35 class DTDValidator;
       
    36 
       
    37 //  This is an integrated scanner class, which does DTD/XML Schema grammar
       
    38 //  processing.
       
    39 class XMLPARSER_EXPORT DGXMLScanner : public XMLScanner
       
    40 {
       
    41 public :
       
    42     // -----------------------------------------------------------------------
       
    43     //  Constructors and Destructor
       
    44     // -----------------------------------------------------------------------
       
    45     DGXMLScanner
       
    46     (
       
    47           XMLValidator* const  valToAdopt
       
    48         , GrammarResolver* const grammarResolver
       
    49         , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
       
    50     );
       
    51     DGXMLScanner
       
    52     (
       
    53           XMLDocumentHandler* const docHandler
       
    54         , DocTypeHandler* const     docTypeHandler
       
    55         , XMLEntityHandler* const   entityHandler
       
    56         , XMLErrorReporter* const   errReporter
       
    57         , XMLValidator* const       valToAdopt
       
    58         , GrammarResolver* const    grammarResolver
       
    59         , MemoryManager* const      manager = XMLPlatformUtils::fgMemoryManager
       
    60     );
       
    61     virtual ~DGXMLScanner();
       
    62 
       
    63     // -----------------------------------------------------------------------
       
    64     //  XMLScanner public virtual methods
       
    65     // -----------------------------------------------------------------------
       
    66     virtual const XMLCh* getName() const;
       
    67     virtual NameIdPool<DTDEntityDecl>* getEntityDeclPool();
       
    68     virtual const NameIdPool<DTDEntityDecl>* getEntityDeclPool() const;
       
    69     virtual unsigned int resolveQName
       
    70     (
       
    71         const   XMLCh* const        qName
       
    72         ,       XMLBuffer&          prefixBufToFill
       
    73         , const short               mode
       
    74         ,       int&                prefixColonPos
       
    75     );
       
    76     virtual void scanDocument
       
    77     (
       
    78         const   InputSource&    src
       
    79     );
       
    80     virtual bool scanNext(XMLPScanToken& toFill);
       
    81     virtual Grammar* loadGrammar
       
    82     (
       
    83         const   InputSource&    src
       
    84         , const short           grammarType
       
    85         , const bool            toCache = false
       
    86     );
       
    87 
       
    88     virtual Grammar::GrammarType getCurrentGrammarType() const;
       
    89 
       
    90 private :
       
    91     // -----------------------------------------------------------------------
       
    92     //  Unimplemented constructors and operators
       
    93     // -----------------------------------------------------------------------
       
    94     DGXMLScanner();
       
    95     DGXMLScanner(const DGXMLScanner&);
       
    96     DGXMLScanner& operator=(const DGXMLScanner&);
       
    97 
       
    98     // -----------------------------------------------------------------------
       
    99     //  XMLScanner virtual methods
       
   100     // -----------------------------------------------------------------------
       
   101     virtual void scanCDSection();
       
   102     virtual void scanCharData(XMLBuffer& toToUse);
       
   103     virtual EntityExpRes scanEntityRef
       
   104     (
       
   105         const   bool    inAttVal
       
   106         ,       XMLCh&  firstCh
       
   107         ,       XMLCh&  secondCh
       
   108         ,       bool&   escaped
       
   109     );
       
   110     virtual void scanDocTypeDecl();
       
   111     virtual void scanReset(const InputSource& src);
       
   112     virtual void sendCharData(XMLBuffer& toSend);
       
   113     virtual InputSource* resolveSystemId(const XMLCh* const sysId
       
   114                                         ,const XMLCh* const pubId); 
       
   115 
       
   116     // -----------------------------------------------------------------------
       
   117     //  Private helper methods
       
   118     // -----------------------------------------------------------------------
       
   119     void commonInit();
       
   120     void cleanUp();
       
   121 
       
   122     unsigned int buildAttList
       
   123     (
       
   124         const unsigned int                attCount
       
   125         ,       XMLElementDecl*             elemDecl
       
   126         ,       RefVectorOf<XMLAttr>&       toFill
       
   127     );
       
   128     unsigned int resolvePrefix
       
   129     (
       
   130         const   XMLCh* const        prefix
       
   131         , const ElemStack::MapModes mode
       
   132     );
       
   133     void updateNSMap
       
   134     (
       
   135         const   XMLCh* const attrPrefix
       
   136         , const XMLCh* const attrLocalName
       
   137         , const XMLCh* const attrValue
       
   138     );
       
   139     void scanAttrListforNameSpaces(RefVectorOf<XMLAttr>* theAttrList, int attCount, XMLElementDecl* elemDecl);
       
   140 
       
   141     // -----------------------------------------------------------------------
       
   142     //  Private scanning methods
       
   143     // -----------------------------------------------------------------------
       
   144     bool scanAttValue
       
   145     (
       
   146         const   XMLAttDef* const    attDef
       
   147         , const XMLCh *const        attrName
       
   148         ,       XMLBuffer&          toFill
       
   149     );
       
   150     bool scanContent();
       
   151     void scanEndTag(bool& gotData);
       
   152     bool scanStartTag(bool& gotData);
       
   153     bool scanStartTagNS(bool& gotData);
       
   154 
       
   155     // -----------------------------------------------------------------------
       
   156     //  Grammar preparsing methods
       
   157     // -----------------------------------------------------------------------
       
   158     Grammar* loadDTDGrammar(const InputSource& src, const bool toCache = false);
       
   159 
       
   160     // -----------------------------------------------------------------------
       
   161     //  Data members
       
   162     //
       
   163     //  fRawAttrList
       
   164     //      During the initial scan of the attributes we can only do a raw
       
   165     //      scan for key/value pairs. So this vector is used to store them
       
   166     //      until they can be processed (and put into fAttrList.)
       
   167     //
       
   168     //  fDTDValidator
       
   169     //      The DTD validator instance.
       
   170     //
       
   171     //  fElemState
       
   172     //  fElemStateSize
       
   173     //      Stores an element next state from DFA content model - used for
       
   174     //      wildcard validation
       
   175     //
       
   176     // fDTDElemNonDeclPool
       
   177     //     registry of "faulted-in" DTD element decls
       
   178     // fElemCount
       
   179     //      count of the number of start tags seen so far (starts at 1).
       
   180     //      Used for duplicate attribute detection/processing of required/defaulted attributes
       
   181     // fAttDefRegistry
       
   182     //      mapping from XMLAttDef instances to the count of the last
       
   183     //      start tag where they were utilized.
       
   184     // fUndeclaredAttrRegistry
       
   185     //      mapping of attr QNames to the count of the last start tag in which they occurred
       
   186     //
       
   187     // -----------------------------------------------------------------------
       
   188     ValueVectorOf<XMLAttr*>*    fAttrNSList;
       
   189     DTDValidator*               fDTDValidator;
       
   190     DTDGrammar*                 fDTDGrammar;
       
   191     NameIdPool<DTDElementDecl>* fDTDElemNonDeclPool;
       
   192     unsigned int                fElemCount;
       
   193     RefHashTableOf<unsigned int>* fAttDefRegistry;
       
   194     RefHashTableOf<unsigned int>* fUndeclaredAttrRegistry;
       
   195 };
       
   196 
       
   197 inline const XMLCh* DGXMLScanner::getName() const
       
   198 {
       
   199     return XMLUni::fgDGXMLScanner;
       
   200 }
       
   201 
       
   202 inline Grammar::GrammarType DGXMLScanner::getCurrentGrammarType() const
       
   203 {
       
   204     return Grammar::DTDGrammarType;
       
   205 }
       
   206 
       
   207 XERCES_CPP_NAMESPACE_END
       
   208 
       
   209 #endif