| 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-2003 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.9  2003/05/15 18:26:07  knoaman
    00060   * Partial implementation of the configurable memory manager.
    00061   *
    00062   * Revision 1.8  2003/03/07 18:08:10  tng
    00063   * Return a reference instead of void for operator=
    00064   *
    00065   * Revision 1.7  2002/11/07 21:59:22  tng
    00066   * Pass elemDecl to XMLValidator::validateAttrValue so that we can include element name in error message.
    00067   *
    00068   * Revision 1.6  2002/11/04 15:00:21  tng
    00069   * C++ Namespace Support.
    00070   *
    00071   * Revision 1.5  2002/09/04 18:17:55  tng
    00072   * Do not set IDREF to used during prevalidation.
    00073   *
    00074   * Revision 1.4  2002/08/20 16:54:11  tng
    00075   * [Bug 6251] Info during compilation.
    00076   *
    00077   * Revision 1.3  2002/07/11 18:55:44  knoaman
    00078   * Add a flag to the preContentValidation method to indicate whether to validate
    00079   * default/fixed attributes or not.
    00080   *
    00081   * Revision 1.2  2002/02/20 18:17:01  tng
    00082   * [Bug 5977] Warnings on generating apiDocs.
    00083   *
    00084   * Revision 1.1.1.1  2002/02/01 22:21:52  peiyongz
    00085   * sane_include
    00086   *
    00087   * Revision 1.17  2001/11/30 22:18:18  peiyongz
    00088   * cleanUp function made member function
    00089   * cleanUp object moved to file scope
    00090   * double mutex lock removed
    00091   *
    00092   * Revision 1.16  2001/11/13 13:24:46  tng
    00093   * Deprecate function XMLValidator::checkRootElement.
    00094   *
    00095   * Revision 1.15  2001/10/24 23:46:52  peiyongz
    00096   * [Bug 4342] fix the leak.
    00097   *
    00098   * Revision 1.14  2001/06/05 16:51:17  knoaman
    00099   * Add 'const' to getGrammar - submitted by Peter A. Volchek.
    00100   *
    00101   * Revision 1.13  2001/05/11 13:25:33  tng
    00102   * Copyright update.
    00103   *
    00104   * Revision 1.12  2001/05/03 20:34:22  tng
    00105   * Schema: SchemaValidator update
    00106   *
    00107   * Revision 1.11  2001/04/19 18:16:53  tng
    00108   * Schema: SchemaValidator update, and use QName in Content Model
    00109   *
    00110   * Revision 1.10  2001/03/21 21:56:03  tng
    00111   * Schema: Add Schema Grammar, Schema Validator, and split the DTDValidator into DTDValidator, DTDScanner, and DTDGrammar.
    00112   *
    00113   * Revision 1.9  2001/02/26 19:21:33  tng
    00114   * Schema: add parameter prefix in findElem and findAttr.
    00115   *
    00116   * Revision 1.8  2000/12/14 18:49:58  tng
    00117   * Fix API document generation warning: "Warning: end of member group without matching begin"
    00118   *
    00119   * Revision 1.7  2000/08/09 22:09:09  jpolast
    00120   * added const XMLCh* getURIText()
    00121   * allows parsers to use const URIs instead of appending
    00122   * to a XMLBuffer.
    00123   *
    00124   * Revision 1.6  2000/03/02 19:54:25  roddey
    00125   * This checkin includes many changes done while waiting for the
    00126   * 1.1.0 code to be finished. I can't list them all here, but a list is
    00127   * available elsewhere.
    00128   *
    00129   * Revision 1.5  2000/02/24 20:00:24  abagchi
    00130   * Swat for removing Log from API docs
    00131   *
    00132   * Revision 1.4  2000/02/15 23:59:07  roddey
    00133   * More updated documentation of Framework classes.
    00134   *
    00135   * Revision 1.3  2000/02/15 01:21:31  roddey
    00136   * Some initial documentation improvements. More to come...
    00137   *
    00138   * Revision 1.2  2000/02/06 07:47:49  rahulj
    00139   * Year 2K copyright swat.
    00140   *
    00141   * Revision 1.1.1.1  1999/11/09 01:08:38  twl
    00142   * Initial checkin
    00143   *
    00144   * Revision 1.4  1999/11/08 20:44:41  rahul
    00145   * Swat for adding in Product name and CVS comment log variable.
    00146   *
    00147   */
    00148
    00149
    00150 #if !defined(XMLVALIDATOR_HPP)
    00151 #define XMLVALIDATOR_HPP
    00152
    00153 #include <xercesc/framework/XMLAttr.hpp>
    00154 #include <xercesc/framework/XMLValidityCodes.hpp>
    00155
    00156 XERCES_CPP_NAMESPACE_BEGIN
    00157
    00158 class ReaderMgr;
    00159 class XMLBufferMgr;
    00160 class XMLElementDecl;
    00161 class XMLScanner;
    00162 class Grammar;
    00163
    00164
    00180 class  XMLValidator : public XMemory
    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     XMLValidator& 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 //  Setter methods
    00506 // -----------------------------------------------------------------------
    00507 inline void
    00508 XMLValidator::setScannerInfo(XMLScanner* const      owningScanner
    00509                             , ReaderMgr* const      readerMgr
    00510                             , XMLBufferMgr* const   bufMgr)
    00511 {
    00512     // We don't own any of these, we just reference them
    00513     fScanner = owningScanner;
    00514     fReaderMgr = readerMgr;
    00515     fBufMgr = bufMgr;
    00516 }
    00517
    00518 inline void
    00519 XMLValidator::setErrorReporter(XMLErrorReporter* const errorReporter)
    00520 {
    00521     fErrorReporter = errorReporter;
    00522 }
    00523
    00524
    00525 // ---------------------------------------------------------------------------
    00526 //  XMLValidator: Protected getter
    00527 // ---------------------------------------------------------------------------
    00528 inline const XMLBufferMgr* XMLValidator::getBufMgr() const
    00529 {
    00530     return fBufMgr;
    00531 }
    00532
    00533 inline XMLBufferMgr* XMLValidator::getBufMgr()
    00534 {
    00535     return fBufMgr;
    00536 }
    00537
    00538 inline const ReaderMgr* XMLValidator::getReaderMgr() const
    00539 {
    00540     return fReaderMgr;
    00541 }
    00542
    00543 inline ReaderMgr* XMLValidator::getReaderMgr()
    00544 {
    00545     return fReaderMgr;
    00546 }
    00547
    00548 inline const XMLScanner* XMLValidator::getScanner() const
    00549 {
    00550     return fScanner;
    00551 }
    00552
    00553 inline XMLScanner* XMLValidator::getScanner()
    00554 {
    00555     return fScanner;
    00556 }
    00557
    00558 XERCES_CPP_NAMESPACE_END
    00559
    00560 #endif

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