# 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 676911 2008-07-15 13:27:32Z amassari $
    00020  */
    00021
    00022 #if !defined(XERCESC_INCLUDE_GUARD_XMLVALIDATOR_HPP)
    00023 #define XERCESC_INCLUDE_GUARD_XMLVALIDATOR_HPP
    00024
    00025 #include <xercesc/framework/XMLAttr.hpp>
    00026 #include <xercesc/framework/XMLValidityCodes.hpp>
    00027
    00028 XERCES_CPP_NAMESPACE_BEGIN
    00029
    00030 class ReaderMgr;
    00031 class XMLBufferMgr;
    00032 class XMLElementDecl;
    00033 class XMLScanner;
    00034 class Grammar;
    00035
    00036
    00052 class XMLPARSER_EXPORT XMLValidator : public XMemory
    00053 {
    00054 public:
    00055     // -----------------------------------------------------------------------
    00056     //  Constructors are hidden, just the virtual destructor is exposed
    00057     // -----------------------------------------------------------------------
    00058
    00061
    00066     virtual ~XMLValidator()
    00067     {
    00068     }
    00070
    00071
    00072     // -----------------------------------------------------------------------
    00073     //  The virtual validator interface
    00074     // -----------------------------------------------------------------------
    00075
    00078
    00103     virtual bool checkContent
    00104     (
    00105         XMLElementDecl* const   elemDecl
    00106         , QName** const         children
    00107         , XMLSize_t             childCount
    00108         , XMLSize_t*            indexFailingChild
    00109     ) = 0;
    00110
    00119     virtual void faultInAttr
    00120     (
    00121                 XMLAttr&    toFill
    00122         , const XMLAttDef&  attDef
    00123     )   const = 0;
    00124
    00128     virtual void preContentValidation(bool reuseGrammar,
    00129                                       bool validateDefAttr = false) = 0;
    00130
    00138     virtual void postParseValidation() = 0;
    00139
    00145     virtual void reset() = 0;
    00146
    00153     virtual bool requiresNamespaces() const = 0;
    00154
    00165     virtual void validateAttrValue
    00166     (
    00167         const   XMLAttDef*                  attDef
    00168         , const XMLCh* const                attrValue
    00169         , bool                              preValidation = false
    00170         , const XMLElementDecl*             elemDecl = 0
    00171     ) = 0;
    00172
    00180     virtual void validateElement
    00181     (
    00182         const   XMLElementDecl*             elemDef
    00183     ) = 0;
    00184
    00188     virtual Grammar* getGrammar() const =0;
    00189
    00193     virtual void setGrammar(Grammar* aGrammar) =0;
    00194
    00195
    00197
    00198     // -----------------------------------------------------------------------
    00199     //  Virtual DTD handler interface.
    00200     // -----------------------------------------------------------------------
    00201
    00204
    00209     virtual bool handlesDTD() const = 0;
    00210
    00211     // -----------------------------------------------------------------------
    00212     //  Virtual Schema handler interface.
    00213     // -----------------------------------------------------------------------
    00214
    00221     virtual bool handlesSchema() const = 0;
    00222
    00224
    00225     // -----------------------------------------------------------------------
    00226     //  Setter methods
    00227     //
    00228     //  setScannerInfo() is called by the scanner to tell the validator
    00229     //  about the stuff it needs to have access to.
    00230     // -----------------------------------------------------------------------
    00231
    00234
    00248     void setScannerInfo
    00249     (
    00250         XMLScanner* const           owningScanner
    00251         , ReaderMgr* const          readerMgr
    00252         , XMLBufferMgr* const       bufMgr
    00253     );
    00254
    00264     void setErrorReporter
    00265     (
    00266         XMLErrorReporter* const errorReporter
    00267     );
    00268
    00270
    00271
    00272     // -----------------------------------------------------------------------
    00273     //  Error emitter methods
    00274     // -----------------------------------------------------------------------
    00275
    00278
    00297     void emitError(const XMLValid::Codes toEmit);
    00298     void emitError
    00299     (
    00300         const   XMLValid::Codes toEmit
    00301         , const XMLCh* const    text1
    00302         , const XMLCh* const    text2 = 0
    00303         , const XMLCh* const    text3 = 0
    00304         , const XMLCh* const    text4 = 0
    00305     );
    00306     void emitError
    00307     (
    00308         const   XMLValid::Codes toEmit
    00309         , const char* const     text1
    00310         , const char* const     text2 = 0
    00311         , const char* const     text3 = 0
    00312         , const char* const     text4 = 0
    00313     );
    00314     void emitError
    00315     (
    00316         const   XMLValid::Codes toEmit
    00317         , const XMLExcepts::Codes   originalErrorCode
    00318         , const XMLCh* const        text1 = 0
    00319         , const XMLCh* const        text2 = 0
    00320         , const XMLCh* const        text3 = 0
    00321         , const XMLCh* const        text4 = 0
    00322
    00323     );
    00324
    00326
    00327 protected :
    00328     // -----------------------------------------------------------------------
    00329     //  Hidden constructors
    00330     // -----------------------------------------------------------------------
    00331     XMLValidator
    00332     (
    00333         XMLErrorReporter* const errReporter = 0
    00334     );
    00335
    00336
    00337     // -----------------------------------------------------------------------
    00338     //  Protected getters
    00339     // -----------------------------------------------------------------------
    00340     const XMLBufferMgr* getBufMgr() const;
    00341     XMLBufferMgr* getBufMgr();
    00342     const ReaderMgr* getReaderMgr() const;
    00343     ReaderMgr* getReaderMgr();
    00344     const XMLScanner* getScanner() const;
    00345     XMLScanner* getScanner();
    00346
    00347
    00348 private :
    00349     // -----------------------------------------------------------------------
    00350     //  Unimplemented Constructors and Operators
    00351     // -----------------------------------------------------------------------
    00352     XMLValidator(const XMLValidator&);
    00353     XMLValidator& operator=(const XMLValidator&);
    00354
    00355
    00356     // -----------------------------------------------------------------------
    00357     //  Private data members
    00358     //
    00359     //  fErrorReporter
    00360     //      The error reporter we are to use, if any.
    00361     //
    00362     // -----------------------------------------------------------------------
    00363     XMLBufferMgr*       fBufMgr;
    00364     XMLErrorReporter*   fErrorReporter;
    00365     ReaderMgr*          fReaderMgr;
    00366     XMLScanner*         fScanner;
    00367 };
    00368
    00369
    00370 // -----------------------------------------------------------------------
    00371 //  Setter methods
    00372 // -----------------------------------------------------------------------
    00373 inline void
    00374 XMLValidator::setScannerInfo(XMLScanner* const      owningScanner
    00375                             , ReaderMgr* const      readerMgr
    00376                             , XMLBufferMgr* const   bufMgr)
    00377 {
    00378     // We don't own any of these, we just reference them
    00379     fScanner = owningScanner;
    00380     fReaderMgr = readerMgr;
    00381     fBufMgr = bufMgr;
    00382 }
    00383
    00384 inline void
    00385 XMLValidator::setErrorReporter(XMLErrorReporter* const errorReporter)
    00386 {
    00387     fErrorReporter = errorReporter;
    00388 }
    00389
    00390
    00391 // ---------------------------------------------------------------------------
    00392 //  XMLValidator: Protected getter
    00393 // ---------------------------------------------------------------------------
    00394 inline const XMLBufferMgr* XMLValidator::getBufMgr() const
    00395 {
    00396     return fBufMgr;
    00397 }
    00398
    00399 inline XMLBufferMgr* XMLValidator::getBufMgr()
    00400 {
    00401     return fBufMgr;
    00402 }
    00403
    00404 inline const ReaderMgr* XMLValidator::getReaderMgr() const
    00405 {
    00406     return fReaderMgr;
    00407 }
    00408
    00409 inline ReaderMgr* XMLValidator::getReaderMgr()
    00410 {
    00411     return fReaderMgr;
    00412 }
    00413
    00414 inline const XMLScanner* XMLValidator::getScanner() const
    00415 {
    00416     return fScanner;
    00417 }
    00418
    00419 inline XMLScanner* XMLValidator::getScanner()
    00420 {
    00421     return fScanner;
    00422 }
    00423
    00424 XERCES_CPP_NAMESPACE_END
    00425
    00426 #endif