XMLValidator.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: XMLValidator.hpp 568078 2007-08-21 11:43:25Z amassari $
00020  */
00021 
00022 
00023 #if !defined(XMLVALIDATOR_HPP)
00024 #define XMLVALIDATOR_HPP
00025 
00026 #include <xercesc/framework/XMLAttr.hpp>
00027 #include <xercesc/framework/XMLValidityCodes.hpp>
00028 
00029 XERCES_CPP_NAMESPACE_BEGIN
00030 
00031 class ReaderMgr;
00032 class XMLBufferMgr;
00033 class XMLElementDecl;
00034 class XMLScanner;
00035 class Grammar;
00036 
00037 
00053 class XMLPARSER_EXPORT XMLValidator : public XMemory
00054 {
00055 public:
00056     // -----------------------------------------------------------------------
00057     //  Constructors are hidden, just the virtual destructor is exposed
00058     // -----------------------------------------------------------------------
00059 
00062 
00067     virtual ~XMLValidator()
00068     {
00069     }
00071 
00072 
00073     // -----------------------------------------------------------------------
00074     //  The virtual validator interface
00075     // -----------------------------------------------------------------------
00076 
00079 
00099     virtual int checkContent
00100     (
00101         XMLElementDecl* const   elemDecl
00102         , QName** const         children
00103         , const unsigned int    childCount
00104     ) = 0;
00105 
00114     virtual void faultInAttr
00115     (
00116                 XMLAttr&    toFill
00117         , const XMLAttDef&  attDef
00118     )   const = 0;
00119 
00123     virtual void preContentValidation(bool reuseGrammar,
00124                                       bool validateDefAttr = false) = 0;
00125 
00133     virtual void postParseValidation() = 0;
00134 
00140     virtual void reset() = 0;
00141 
00148     virtual bool requiresNamespaces() const = 0;
00149 
00160     virtual void validateAttrValue
00161     (
00162         const   XMLAttDef*                  attDef
00163         , const XMLCh* const                attrValue
00164         , bool                              preValidation = false
00165         , const XMLElementDecl*             elemDecl = 0
00166     ) = 0;
00167 
00175     virtual void validateElement
00176     (
00177         const   XMLElementDecl*             elemDef
00178     ) = 0;
00179 
00183     virtual Grammar* getGrammar() const =0;
00184 
00188     virtual void setGrammar(Grammar* aGrammar) =0;
00189 
00190 
00192 
00193     // -----------------------------------------------------------------------
00194     //  Virtual DTD handler interface.
00195     // -----------------------------------------------------------------------
00196 
00199 
00204     virtual bool handlesDTD() const = 0;
00205 
00206     // -----------------------------------------------------------------------
00207     //  Virtual Schema handler interface.
00208     // -----------------------------------------------------------------------
00209 
00216     virtual bool handlesSchema() const = 0;
00217 
00219 
00220     // -----------------------------------------------------------------------
00221     //  Setter methods
00222     //
00223     //  setScannerInfo() is called by the scanner to tell the validator
00224     //  about the stuff it needs to have access to.
00225     // -----------------------------------------------------------------------
00226 
00229 
00243     void setScannerInfo
00244     (
00245         XMLScanner* const           owningScanner
00246         , ReaderMgr* const          readerMgr
00247         , XMLBufferMgr* const       bufMgr
00248     );
00249 
00259     void setErrorReporter
00260     (
00261         XMLErrorReporter* const errorReporter
00262     );
00263 
00265 
00266 
00267     // -----------------------------------------------------------------------
00268     //  Error emitter methods
00269     // -----------------------------------------------------------------------
00270 
00273 
00292     void emitError(const XMLValid::Codes toEmit);
00293     void emitError
00294     (
00295         const   XMLValid::Codes toEmit
00296         , const XMLCh* const    text1
00297         , const XMLCh* const    text2 = 0
00298         , const XMLCh* const    text3 = 0
00299         , const XMLCh* const    text4 = 0
00300     );
00301     void emitError
00302     (
00303         const   XMLValid::Codes toEmit
00304         , const char* const     text1
00305         , const char* const     text2 = 0
00306         , const char* const     text3 = 0
00307         , const char* const     text4 = 0
00308     );    
00309     void emitError
00310     (
00311         const   XMLValid::Codes toEmit
00312         , const XMLExcepts::Codes   originalErrorCode
00313         , const XMLCh* const        text1 = 0
00314         , const XMLCh* const        text2 = 0
00315         , const XMLCh* const        text3 = 0
00316         , const XMLCh* const        text4 = 0
00317         
00318     );
00319 
00321 
00322     // -----------------------------------------------------------------------
00323     //  Deprecated XMLValidator interface
00324     // -----------------------------------------------------------------------
00332     bool checkRootElement
00333     (
00334         const   unsigned int
00335     ) { return true;};
00336 
00337     // -----------------------------------------------------------------------
00338     //  Notification that lazy data has been deleted
00339     // -----------------------------------------------------------------------
00340     static void reinitMsgMutex();
00341 
00342     static void reinitMsgLoader();
00343 
00344 protected :
00345     // -----------------------------------------------------------------------
00346     //  Hidden constructors
00347     // -----------------------------------------------------------------------
00348     XMLValidator
00349     (
00350         XMLErrorReporter* const errReporter = 0
00351     );
00352 
00353 
00354     // -----------------------------------------------------------------------
00355     //  Protected getters
00356     // -----------------------------------------------------------------------
00357     const XMLBufferMgr* getBufMgr() const;
00358     XMLBufferMgr* getBufMgr();
00359     const ReaderMgr* getReaderMgr() const;
00360     ReaderMgr* getReaderMgr();
00361     const XMLScanner* getScanner() const;
00362     XMLScanner* getScanner();
00363 
00364 
00365 private :
00366     // -----------------------------------------------------------------------
00367     //  Unimplemented Constructors and Operators
00368     // -----------------------------------------------------------------------
00369     XMLValidator(const XMLValidator&);
00370     XMLValidator& operator=(const XMLValidator&);
00371 
00372 
00373     // -----------------------------------------------------------------------
00374     //  Private data members
00375     //
00376     //  fErrorReporter
00377     //      The error reporter we are to use, if any.
00378     //
00379     // -----------------------------------------------------------------------
00380     XMLBufferMgr*       fBufMgr;
00381     XMLErrorReporter*   fErrorReporter;
00382     ReaderMgr*          fReaderMgr;
00383     XMLScanner*         fScanner;
00384 };
00385 
00386 
00387 // -----------------------------------------------------------------------
00388 //  Setter methods
00389 // -----------------------------------------------------------------------
00390 inline void
00391 XMLValidator::setScannerInfo(XMLScanner* const      owningScanner
00392                             , ReaderMgr* const      readerMgr
00393                             , XMLBufferMgr* const   bufMgr)
00394 {
00395     // We don't own any of these, we just reference them
00396     fScanner = owningScanner;
00397     fReaderMgr = readerMgr;
00398     fBufMgr = bufMgr;
00399 }
00400 
00401 inline void
00402 XMLValidator::setErrorReporter(XMLErrorReporter* const errorReporter)
00403 {
00404     fErrorReporter = errorReporter;
00405 }
00406 
00407 
00408 // ---------------------------------------------------------------------------
00409 //  XMLValidator: Protected getter
00410 // ---------------------------------------------------------------------------
00411 inline const XMLBufferMgr* XMLValidator::getBufMgr() const
00412 {
00413     return fBufMgr;
00414 }
00415 
00416 inline XMLBufferMgr* XMLValidator::getBufMgr()
00417 {
00418     return fBufMgr;
00419 }
00420 
00421 inline const ReaderMgr* XMLValidator::getReaderMgr() const
00422 {
00423     return fReaderMgr;
00424 }
00425 
00426 inline ReaderMgr* XMLValidator::getReaderMgr()
00427 {
00428     return fReaderMgr;
00429 }
00430 
00431 inline const XMLScanner* XMLValidator::getScanner() const
00432 {
00433     return fScanner;
00434 }
00435 
00436 inline XMLScanner* XMLValidator::getScanner()
00437 {
00438     return fScanner;
00439 }
00440 
00441 XERCES_CPP_NAMESPACE_END
00442 
00443 #endif

Generated on Thu Feb 19 11:35:44 2009 for Xerces-C++ by  doxygen 1.5.4