| API Docs for SAX and DOM |
| Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members File Members # XMLValidator.hpp Go to the documentation of this file.
    00001 /*
    00002  * Copyright 1999-2004 The Apache Software Foundation.
    00003  *
    00004  * Licensed under the Apache License, Version 2.0 (the "License");
    00005  * you may not use this file except in compliance with the License.
    00006  * You may obtain a copy of the License at
    00007  *
    00008  *      http://www.apache.org/licenses/LICENSE-2.0
    00009  *
    00010  * Unless required by applicable law or agreed to in writing, software
    00011  * distributed under the License is distributed on an "AS IS" BASIS,
    00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    00013  * See the License for the specific language governing permissions and
    00014  * limitations under the License.
    00015  */
    00016
    00017  /*
    00018   * $Log: XMLValidator.hpp,v $
    00019   * Revision 1.10  2004/09/08 13:55:59  peiyongz
    00020   * Apache License Version 2.0
    00021   *
    00022   * Revision 1.9  2003/05/15 18:26:07  knoaman
    00023   * Partial implementation of the configurable memory manager.
    00024   *
    00025   * Revision 1.8  2003/03/07 18:08:10  tng
    00026   * Return a reference instead of void for operator=
    00027   *
    00028   * Revision 1.7  2002/11/07 21:59:22  tng
    00029   * Pass elemDecl to XMLValidator::validateAttrValue so that we can include element name in error message.
    00030   *
    00031   * Revision 1.6  2002/11/04 15:00:21  tng
    00032   * C++ Namespace Support.
    00033   *
    00034   * Revision 1.5  2002/09/04 18:17:55  tng
    00035   * Do not set IDREF to used during prevalidation.
    00036   *
    00037   * Revision 1.4  2002/08/20 16:54:11  tng
    00038   * [Bug 6251] Info during compilation.
    00039   *
    00040   * Revision 1.3  2002/07/11 18:55:44  knoaman
    00041   * Add a flag to the preContentValidation method to indicate whether to validate
    00042   * default/fixed attributes or not.
    00043   *
    00044   * Revision 1.2  2002/02/20 18:17:01  tng
    00045   * [Bug 5977] Warnings on generating apiDocs.
    00046   *
    00047   * Revision 1.1.1.1  2002/02/01 22:21:52  peiyongz
    00048   * sane_include
    00049   *
    00050   * Revision 1.17  2001/11/30 22:18:18  peiyongz
    00051   * cleanUp function made member function
    00052   * cleanUp object moved to file scope
    00053   * double mutex lock removed
    00054   *
    00055   * Revision 1.16  2001/11/13 13:24:46  tng
    00056   * Deprecate function XMLValidator::checkRootElement.
    00057   *
    00058   * Revision 1.15  2001/10/24 23:46:52  peiyongz
    00059   * [Bug 4342] fix the leak.
    00060   *
    00061   * Revision 1.14  2001/06/05 16:51:17  knoaman
    00062   * Add 'const' to getGrammar - submitted by Peter A. Volchek.
    00063   *
    00064   * Revision 1.13  2001/05/11 13:25:33  tng
    00065   * Copyright update.
    00066   *
    00067   * Revision 1.12  2001/05/03 20:34:22  tng
    00068   * Schema: SchemaValidator update
    00069   *
    00070   * Revision 1.11  2001/04/19 18:16:53  tng
    00071   * Schema: SchemaValidator update, and use QName in Content Model
    00072   *
    00073   * Revision 1.10  2001/03/21 21:56:03  tng
    00074   * Schema: Add Schema Grammar, Schema Validator, and split the DTDValidator into DTDValidator, DTDScanner, and DTDGrammar.
    00075   *
    00076   * Revision 1.9  2001/02/26 19:21:33  tng
    00077   * Schema: add parameter prefix in findElem and findAttr.
    00078   *
    00079   * Revision 1.8  2000/12/14 18:49:58  tng
    00080   * Fix API document generation warning: "Warning: end of member group without matching begin"
    00081   *
    00082   * Revision 1.7  2000/08/09 22:09:09  jpolast
    00083   * added const XMLCh* getURIText()
    00084   * allows parsers to use const URIs instead of appending
    00085   * to a XMLBuffer.
    00086   *
    00087   * Revision 1.6  2000/03/02 19:54:25  roddey
    00088   * This checkin includes many changes done while waiting for the
    00089   * 1.1.0 code to be finished. I can't list them all here, but a list is
    00090   * available elsewhere.
    00091   *
    00092   * Revision 1.5  2000/02/24 20:00:24  abagchi
    00093   * Swat for removing Log from API docs
    00094   *
    00095   * Revision 1.4  2000/02/15 23:59:07  roddey
    00096   * More updated documentation of Framework classes.
    00097   *
    00098   * Revision 1.3  2000/02/15 01:21:31  roddey
    00099   * Some initial documentation improvements. More to come...
    00100   *
    00101   * Revision 1.2  2000/02/06 07:47:49  rahulj
    00102   * Year 2K copyright swat.
    00103   *
    00104   * Revision 1.1.1.1  1999/11/09 01:08:38  twl
    00105   * Initial checkin
    00106   *
    00107   * Revision 1.4  1999/11/08 20:44:41  rahul
    00108   * Swat for adding in Product name and CVS comment log variable.
    00109   *
    00110   */
    00111
    00112
    00113 #if !defined(XMLVALIDATOR_HPP)
    00114 #define XMLVALIDATOR_HPP
    00115
    00116 #include <xercesc/framework/XMLAttr.hpp>
    00117 #include <xercesc/framework/XMLValidityCodes.hpp>
    00118
    00119 XERCES_CPP_NAMESPACE_BEGIN
    00120
    00121 class ReaderMgr;
    00122 class XMLBufferMgr;
    00123 class XMLElementDecl;
    00124 class XMLScanner;
    00125 class Grammar;
    00126
    00127
    00143 class  XMLValidator : public XMemory
    00144 {
    00145 public:
    00146     // -----------------------------------------------------------------------
    00147     //  Constructors are hidden, just the virtual destructor is exposed
    00148     // -----------------------------------------------------------------------
    00149
    00152
    00157     virtual ~XMLValidator()
    00158     {
    00159     }
    00161
    00162
    00163     // -----------------------------------------------------------------------
    00164     //  The virtual validator interface
    00165     // -----------------------------------------------------------------------
    00166
    00169
    00189     virtual int checkContent
    00190     (
    00191         XMLElementDecl* const   elemDecl
    00192         , QName** const         children
    00193         , const unsigned int    childCount
    00194     ) = 0;
    00195
    00204     virtual void faultInAttr
    00205     (
    00206                 XMLAttr&    toFill
    00207         , const XMLAttDef&  attDef
    00208     )   const = 0;
    00209
    00213     virtual void preContentValidation(bool reuseGrammar,
    00214                                       bool validateDefAttr = false) = 0;
    00215
    00223     virtual void postParseValidation() = 0;
    00224
    00230     virtual void reset() = 0;
    00231
    00238     virtual bool requiresNamespaces() const = 0;
    00239
    00250     virtual void validateAttrValue
    00251     (
    00252         const   XMLAttDef*                  attDef
    00253         , const XMLCh* const                attrValue
    00254         , bool                              preValidation = false
    00255         , const XMLElementDecl*             elemDecl = 0
    00256     ) = 0;
    00257
    00265     virtual void validateElement
    00266     (
    00267         const   XMLElementDecl*             elemDef
    00268     ) = 0;
    00269
    00273     virtual Grammar* getGrammar() const =0;
    00274
    00278     virtual void setGrammar(Grammar* aGrammar) =0;
    00279
    00280
    00282
    00283     // -----------------------------------------------------------------------
    00284     //  Virtual DTD handler interface.
    00285     // -----------------------------------------------------------------------
    00286
    00289
    00294     virtual bool handlesDTD() const = 0;
    00295
    00296     // -----------------------------------------------------------------------
    00297     //  Virtual Schema handler interface.
    00298     // -----------------------------------------------------------------------
    00299
    00306     virtual bool handlesSchema() const = 0;
    00307
    00309
    00310     // -----------------------------------------------------------------------
    00311     //  Setter methods
    00312     //
    00313     //  setScannerInfo() is called by the scanner to tell the validator
    00314     //  about the stuff it needs to have access to.
    00315     // -----------------------------------------------------------------------
    00316
    00319
    00333     void setScannerInfo
    00334     (
    00335         XMLScanner* const           owningScanner
    00336         , ReaderMgr* const          readerMgr
    00337         , XMLBufferMgr* const       bufMgr
    00338     );
    00339
    00349     void setErrorReporter
    00350     (
    00351         XMLErrorReporter* const errorReporter
    00352     );
    00353
    00355
    00356
    00357     // -----------------------------------------------------------------------
    00358     //  Error emitter methods
    00359     // -----------------------------------------------------------------------
    00360
    00363
    00382     void emitError(const XMLValid::Codes toEmit);
    00383     void emitError
    00384     (
    00385         const   XMLValid::Codes toEmit
    00386         , const XMLCh* const    text1
    00387         , const XMLCh* const    text2 = 0
    00388         , const XMLCh* const    text3 = 0
    00389         , const XMLCh* const    text4 = 0
    00390     );
    00391     void emitError
    00392     (
    00393         const   XMLValid::Codes toEmit
    00394         , const char* const     text1
    00395         , const char* const     text2 = 0
    00396         , const char* const     text3 = 0
    00397         , const char* const     text4 = 0
    00398     );
    00399
    00401
    00402     // -----------------------------------------------------------------------
    00403     //  Deprecated XMLValidator interface
    00404     // -----------------------------------------------------------------------
    00412     bool checkRootElement
    00413     (
    00414         const   unsigned int
    00415     ) { return true;};
    00416
    00417     // -----------------------------------------------------------------------
    00418     //  Notification that lazy data has been deleted
    00419     // -----------------------------------------------------------------------
    00420     static void reinitMsgMutex();
    00421
    00422     static void reinitMsgLoader();
    00423
    00424 protected :
    00425     // -----------------------------------------------------------------------
    00426     //  Hidden constructors
    00427     // -----------------------------------------------------------------------
    00428     XMLValidator
    00429     (
    00430         XMLErrorReporter* const errReporter = 0
    00431     );
    00432
    00433
    00434     // -----------------------------------------------------------------------
    00435     //  Protected getters
    00436     // -----------------------------------------------------------------------
    00437     const XMLBufferMgr* getBufMgr() const;
    00438     XMLBufferMgr* getBufMgr();
    00439     const ReaderMgr* getReaderMgr() const;
    00440     ReaderMgr* getReaderMgr();
    00441     const XMLScanner* getScanner() const;
    00442     XMLScanner* getScanner();
    00443
    00444
    00445 private :
    00446     // -----------------------------------------------------------------------
    00447     //  Unimplemented Constructors and Operators
    00448     // -----------------------------------------------------------------------
    00449     XMLValidator(const XMLValidator&);
    00450     XMLValidator& operator=(const XMLValidator&);
    00451
    00452
    00453     // -----------------------------------------------------------------------
    00454     //  Private data members
    00455     //
    00456     //  fErrorReporter
    00457     //      The error reporter we are to use, if any.
    00458     //
    00459     // -----------------------------------------------------------------------
    00460     XMLBufferMgr*       fBufMgr;
    00461     XMLErrorReporter*   fErrorReporter;
    00462     ReaderMgr*          fReaderMgr;
    00463     XMLScanner*         fScanner;
    00464 };
    00465
    00466
    00467 // -----------------------------------------------------------------------
    00468 //  Setter methods
    00469 // -----------------------------------------------------------------------
    00470 inline void
    00471 XMLValidator::setScannerInfo(XMLScanner* const      owningScanner
    00472                             , ReaderMgr* const      readerMgr
    00473                             , XMLBufferMgr* const   bufMgr)
    00474 {
    00475     // We don't own any of these, we just reference them
    00476     fScanner = owningScanner;
    00477     fReaderMgr = readerMgr;
    00478     fBufMgr = bufMgr;
    00479 }
    00480
    00481 inline void
    00482 XMLValidator::setErrorReporter(XMLErrorReporter* const errorReporter)
    00483 {
    00484     fErrorReporter = errorReporter;
    00485 }
    00486
    00487
    00488 // ---------------------------------------------------------------------------
    00489 //  XMLValidator: Protected getter
    00490 // ---------------------------------------------------------------------------
    00491 inline const XMLBufferMgr* XMLValidator::getBufMgr() const
    00492 {
    00493     return fBufMgr;
    00494 }
    00495
    00496 inline XMLBufferMgr* XMLValidator::getBufMgr()
    00497 {
    00498     return fBufMgr;
    00499 }
    00500
    00501 inline const ReaderMgr* XMLValidator::getReaderMgr() const
    00502 {
    00503     return fReaderMgr;
    00504 }
    00505
    00506 inline ReaderMgr* XMLValidator::getReaderMgr()
    00507 {
    00508     return fReaderMgr;
    00509 }
    00510
    00511 inline const XMLScanner* XMLValidator::getScanner() const
    00512 {
    00513     return fScanner;
    00514 }
    00515
    00516 inline XMLScanner* XMLValidator::getScanner()
    00517 {
    00518     return fScanner;
    00519 }
    00520
    00521 XERCES_CPP_NAMESPACE_END
    00522
    00523 #endif

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