| 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  * The Apache Software License, Version 1.1
    00003  *
    00004  * Copyright (c) 1999-2001 The Apache Software Foundation.  All rights
    00005  * reserved.
    00006  *
    00007  * Redistribution and use in source and binary forms, with or without
    00008  * modification, are permitted provided that the following conditions
    00009  * are met:
    00010  *
    00011  * 1. Redistributions of source code must retain the above copyright
    00012  *    notice, this list of conditions and the following disclaimer.
    00013  *
    00014  * 2. Redistributions in binary form must reproduce the above copyright
    00015  *    notice, this list of conditions and the following disclaimer in
    00016  *    the documentation and/or other materials provided with the
    00017  *    distribution.
    00018  *
    00019  * 3. The end-user documentation included with the redistribution,
    00020  *    if any, must include the following acknowledgment:
    00021  *       "This product includes software developed by the
    00022  *        Apache Software Foundation (http://www.apache.org/)."
    00023  *    Alternately, this acknowledgment may appear in the software itself,
    00024  *    if and wherever such third-party acknowledgments normally appear.
    00025  *
    00026  * 4. The names "Xerces" and "Apache Software Foundation" must
    00027  *    not be used to endorse or promote products derived from this
    00028  *    software without prior written permission. For written
    00029  *    permission, please contact apache\@apache.org.
    00030  *
    00031  * 5. Products derived from this software may not be called "Apache",
    00032  *    nor may "Apache" appear in their name, without prior written
    00033  *    permission of the Apache Software Foundation.
    00034  *
    00035  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
    00036  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
    00037  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
    00038  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
    00039  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    00040  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    00041  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
    00042  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
    00043  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
    00044  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
    00045  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    00046  * SUCH DAMAGE.
    00047  * ====================================================================
    00048  *
    00049  * This software consists of voluntary contributions made by many
    00050  * individuals on behalf of the Apache Software Foundation, and was
    00051  * originally based on software copyright (c) 1999, International
    00052  * Business Machines, Inc., http://www.ibm.com .  For more information
    00053  * on the Apache Software Foundation, please see
    00054  * <http://www.apache.org/>.
    00055  */
    00056
    00057  /*
    00058   * $Log: XMLValidator.hpp,v $
    00059   * Revision 1.7  2002/11/07 21:59:22  tng
    00060   * Pass elemDecl to XMLValidator::validateAttrValue so that we can include element name in error message.
    00061   *
    00062   * Revision 1.6  2002/11/04 15:00:21  tng
    00063   * C++ Namespace Support.
    00064   *
    00065   * Revision 1.5  2002/09/04 18:17:55  tng
    00066   * Do not set IDREF to used during prevalidation.
    00067   *
    00068   * Revision 1.4  2002/08/20 16:54:11  tng
    00069   * [Bug 6251] Info during compilation.
    00070   *
    00071   * Revision 1.3  2002/07/11 18:55:44  knoaman
    00072   * Add a flag to the preContentValidation method to indicate whether to validate
    00073   * default/fixed attributes or not.
    00074   *
    00075   * Revision 1.2  2002/02/20 18:17:01  tng
    00076   * [Bug 5977] Warnings on generating apiDocs.
    00077   *
    00078   * Revision 1.1.1.1  2002/02/01 22:21:52  peiyongz
    00079   * sane_include
    00080   *
    00081   * Revision 1.17  2001/11/30 22:18:18  peiyongz
    00082   * cleanUp function made member function
    00083   * cleanUp object moved to file scope
    00084   * double mutex lock removed
    00085   *
    00086   * Revision 1.16  2001/11/13 13:24:46  tng
    00087   * Deprecate function XMLValidator::checkRootElement.
    00088   *
    00089   * Revision 1.15  2001/10/24 23:46:52  peiyongz
    00090   * [Bug 4342] fix the leak.
    00091   *
    00092   * Revision 1.14  2001/06/05 16:51:17  knoaman
    00093   * Add 'const' to getGrammar - submitted by Peter A. Volchek.
    00094   *
    00095   * Revision 1.13  2001/05/11 13:25:33  tng
    00096   * Copyright update.
    00097   *
    00098   * Revision 1.12  2001/05/03 20:34:22  tng
    00099   * Schema: SchemaValidator update
    00100   *
    00101   * Revision 1.11  2001/04/19 18:16:53  tng
    00102   * Schema: SchemaValidator update, and use QName in Content Model
    00103   *
    00104   * Revision 1.10  2001/03/21 21:56:03  tng
    00105   * Schema: Add Schema Grammar, Schema Validator, and split the DTDValidator into DTDValidator, DTDScanner, and DTDGrammar.
    00106   *
    00107   * Revision 1.9  2001/02/26 19:21:33  tng
    00108   * Schema: add parameter prefix in findElem and findAttr.
    00109   *
    00110   * Revision 1.8  2000/12/14 18:49:58  tng
    00111   * Fix API document generation warning: "Warning: end of member group without matching begin"
    00112   *
    00113   * Revision 1.7  2000/08/09 22:09:09  jpolast
    00114   * added const XMLCh* getURIText()
    00115   * allows parsers to use const URIs instead of appending
    00116   * to a XMLBuffer.
    00117   *
    00118   * Revision 1.6  2000/03/02 19:54:25  roddey
    00119   * This checkin includes many changes done while waiting for the
    00120   * 1.1.0 code to be finished. I can't list them all here, but a list is
    00121   * available elsewhere.
    00122   *
    00123   * Revision 1.5  2000/02/24 20:00:24  abagchi
    00124   * Swat for removing Log from API docs
    00125   *
    00126   * Revision 1.4  2000/02/15 23:59:07  roddey
    00127   * More updated documentation of Framework classes.
    00128   *
    00129   * Revision 1.3  2000/02/15 01:21:31  roddey
    00130   * Some initial documentation improvements. More to come...
    00131   *
    00132   * Revision 1.2  2000/02/06 07:47:49  rahulj
    00133   * Year 2K copyright swat.
    00134   *
    00135   * Revision 1.1.1.1  1999/11/09 01:08:38  twl
    00136   * Initial checkin
    00137   *
    00138   * Revision 1.4  1999/11/08 20:44:41  rahul
    00139   * Swat for adding in Product name and CVS comment log variable.
    00140   *
    00141   */
    00142
    00143
    00144 #if !defined(XMLVALIDATOR_HPP)
    00145 #define XMLVALIDATOR_HPP
    00146
    00147 #include <xercesc/util/XercesDefs.hpp>
    00148 #include <xercesc/framework/XMLAttr.hpp>
    00149 #include <xercesc/framework/XMLValidityCodes.hpp>
    00150 #include <xercesc/framework/XMLRefInfo.hpp>
    00151
    00152 XERCES_CPP_NAMESPACE_BEGIN
    00153
    00154 class ReaderMgr;
    00155 class XMLBuffer;
    00156 class XMLBufferMgr;
    00157 class XMLElementDecl;
    00158 class XMLEntityHandler;
    00159 class XMLErrorReporter;
    00160 class XMLMsgLoader;
    00161 class XMLScanner;
    00162 class Grammar;
    00163
    00164
    00180 class  XMLValidator
    00181 {
    00182 public:
    00183     // -----------------------------------------------------------------------
    00184     //  Constructors are hidden, just the virtual destructor is exposed
    00185     // -----------------------------------------------------------------------
    00186
    00189
    00194     virtual ~XMLValidator()
    00195     {
    00196     }
    00198
    00199
    00200     // -----------------------------------------------------------------------
    00201     //  The virtual validator interface
    00202     // -----------------------------------------------------------------------
    00203
    00206
    00226     virtual int checkContent
    00227     (
    00228         XMLElementDecl* const   elemDecl
    00229         , QName** const         children
    00230         , const unsigned int    childCount
    00231     ) = 0;
    00232
    00241     virtual void faultInAttr
    00242     (
    00243                 XMLAttr&    toFill
    00244         , const XMLAttDef&  attDef
    00245     )   const = 0;
    00246
    00250     virtual void preContentValidation(bool reuseGrammar,
    00251                                       bool validateDefAttr = false) = 0;
    00252
    00260     virtual void postParseValidation() = 0;
    00261
    00267     virtual void reset() = 0;
    00268
    00275     virtual bool requiresNamespaces() const = 0;
    00276
    00287     virtual void validateAttrValue
    00288     (
    00289         const   XMLAttDef*                  attDef
    00290         , const XMLCh* const                attrValue
    00291         , bool                              preValidation = false
    00292         , const XMLElementDecl*             elemDecl = 0
    00293     ) = 0;
    00294
    00302     virtual void validateElement
    00303     (
    00304         const   XMLElementDecl*             elemDef
    00305     ) = 0;
    00306
    00310     virtual Grammar* getGrammar() const =0;
    00311
    00315     virtual void setGrammar(Grammar* aGrammar) =0;
    00316
    00317
    00319
    00320     // -----------------------------------------------------------------------
    00321     //  Virtual DTD handler interface.
    00322     // -----------------------------------------------------------------------
    00323
    00326
    00331     virtual bool handlesDTD() const = 0;
    00332
    00333     // -----------------------------------------------------------------------
    00334     //  Virtual Schema handler interface.
    00335     // -----------------------------------------------------------------------
    00336
    00343     virtual bool handlesSchema() const = 0;
    00344
    00346
    00347     // -----------------------------------------------------------------------
    00348     //  Setter methods
    00349     //
    00350     //  setScannerInfo() is called by the scanner to tell the validator
    00351     //  about the stuff it needs to have access to.
    00352     // -----------------------------------------------------------------------
    00353
    00356
    00370     void setScannerInfo
    00371     (
    00372         XMLScanner* const           owningScanner
    00373         , ReaderMgr* const          readerMgr
    00374         , XMLBufferMgr* const       bufMgr
    00375     );
    00376
    00386     void setErrorReporter
    00387     (
    00388         XMLErrorReporter* const errorReporter
    00389     );
    00390
    00392
    00393
    00394     // -----------------------------------------------------------------------
    00395     //  Error emitter methods
    00396     // -----------------------------------------------------------------------
    00397
    00400
    00419     void emitError(const XMLValid::Codes toEmit);
    00420     void emitError
    00421     (
    00422         const   XMLValid::Codes toEmit
    00423         , const XMLCh* const    text1
    00424         , const XMLCh* const    text2 = 0
    00425         , const XMLCh* const    text3 = 0
    00426         , const XMLCh* const    text4 = 0
    00427     );
    00428     void emitError
    00429     (
    00430         const   XMLValid::Codes toEmit
    00431         , const char* const     text1
    00432         , const char* const     text2 = 0
    00433         , const char* const     text3 = 0
    00434         , const char* const     text4 = 0
    00435     );
    00436
    00438
    00439     // -----------------------------------------------------------------------
    00440     //  Deprecated XMLValidator interface
    00441     // -----------------------------------------------------------------------
    00449     bool checkRootElement
    00450     (
    00451         const   unsigned int
    00452     ) { return true;};
    00453
    00454     // -----------------------------------------------------------------------
    00455     //  Notification that lazy data has been deleted
    00456     // -----------------------------------------------------------------------
    00457     static void reinitMsgMutex();
    00458
    00459     static void reinitMsgLoader();
    00460
    00461 protected :
    00462     // -----------------------------------------------------------------------
    00463     //  Hidden constructors
    00464     // -----------------------------------------------------------------------
    00465     XMLValidator
    00466     (
    00467         XMLErrorReporter* const errReporter = 0
    00468     );
    00469
    00470
    00471     // -----------------------------------------------------------------------
    00472     //  Protected getters
    00473     // -----------------------------------------------------------------------
    00474     const XMLBufferMgr* getBufMgr() const;
    00475     XMLBufferMgr* getBufMgr();
    00476     const ReaderMgr* getReaderMgr() const;
    00477     ReaderMgr* getReaderMgr();
    00478     const XMLScanner* getScanner() const;
    00479     XMLScanner* getScanner();
    00480
    00481
    00482 private :
    00483     // -----------------------------------------------------------------------
    00484     //  Unimplemented Constructors and Operators
    00485     // -----------------------------------------------------------------------
    00486     XMLValidator(const XMLValidator&);
    00487     void operator=(const XMLValidator&);
    00488
    00489
    00490     // -----------------------------------------------------------------------
    00491     //  Private data members
    00492     //
    00493     //  fErrorReporter
    00494     //      The error reporter we are to use, if any.
    00495     //
    00496     // -----------------------------------------------------------------------
    00497     XMLBufferMgr*       fBufMgr;
    00498     XMLErrorReporter*   fErrorReporter;
    00499     ReaderMgr*          fReaderMgr;
    00500     XMLScanner*         fScanner;
    00501
    00502 };
    00503
    00504
    00505 // -----------------------------------------------------------------------
    00506 //  Setter methods
    00507 // -----------------------------------------------------------------------
    00508 inline void
    00509 XMLValidator::setScannerInfo(XMLScanner* const      owningScanner
    00510                             , ReaderMgr* const      readerMgr
    00511                             , XMLBufferMgr* const   bufMgr)
    00512 {
    00513     // We don't own any of these, we just reference them
    00514     fScanner = owningScanner;
    00515     fReaderMgr = readerMgr;
    00516     fBufMgr = bufMgr;
    00517 }
    00518
    00519 inline void
    00520 XMLValidator::setErrorReporter(XMLErrorReporter* const errorReporter)
    00521 {
    00522     fErrorReporter = errorReporter;
    00523 }
    00524
    00525
    00526 // ---------------------------------------------------------------------------
    00527 //  XMLValidator: Protected getter
    00528 // ---------------------------------------------------------------------------
    00529 inline const XMLBufferMgr* XMLValidator::getBufMgr() const
    00530 {
    00531     return fBufMgr;
    00532 }
    00533
    00534 inline XMLBufferMgr* XMLValidator::getBufMgr()
    00535 {
    00536     return fBufMgr;
    00537 }
    00538
    00539 inline const ReaderMgr* XMLValidator::getReaderMgr() const
    00540 {
    00541     return fReaderMgr;
    00542 }
    00543
    00544 inline ReaderMgr* XMLValidator::getReaderMgr()
    00545 {
    00546     return fReaderMgr;
    00547 }
    00548
    00549 inline const XMLScanner* XMLValidator::getScanner() const
    00550 {
    00551     return fScanner;
    00552 }
    00553
    00554 inline XMLScanner* XMLValidator::getScanner()
    00555 {
    00556     return fScanner;
    00557 }
    00558
    00559 XERCES_CPP_NAMESPACE_END
    00560
    00561 #endif

Copyright © 2000 The Apache Software Foundation. All Rights Reserved.