http://xml.apache.org/http://www.apache.org/http://www.w3.org/

Home

Readme
Download
Installation
Build

API Docs
Samples
Schema

FAQs
Programming
Migration

Releases
Bug-Reporting
Feedback

Y2K Compliance
PDF Document

CVS Repository
Mail Archive

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.17  2001/11/30 22:18:18  peiyongz
00060   * cleanUp function made member function
00061   * cleanUp object moved to file scope
00062   * double mutex lock removed
00063   *
00064   * Revision 1.16  2001/11/13 13:24:46  tng
00065   * Deprecate function XMLValidator::checkRootElement.
00066   *
00067   * Revision 1.15  2001/10/24 23:46:52  peiyongz
00068   * [Bug 4342] fix the leak.
00069   *
00070   * Revision 1.14  2001/06/05 16:51:17  knoaman
00071   * Add 'const' to getGrammar - submitted by Peter A. Volchek.
00072   *
00073   * Revision 1.13  2001/05/11 13:25:33  tng
00074   * Copyright update.
00075   *
00076   * Revision 1.12  2001/05/03 20:34:22  tng
00077   * Schema: SchemaValidator update
00078   *
00079   * Revision 1.11  2001/04/19 18:16:53  tng
00080   * Schema: SchemaValidator update, and use QName in Content Model
00081   *
00082   * Revision 1.10  2001/03/21 21:56:03  tng
00083   * Schema: Add Schema Grammar, Schema Validator, and split the DTDValidator into DTDValidator, DTDScanner, and DTDGrammar.
00084   *
00085   * Revision 1.9  2001/02/26 19:21:33  tng
00086   * Schema: add parameter prefix in findElem and findAttr.
00087   *
00088   * Revision 1.8  2000/12/14 18:49:58  tng
00089   * Fix API document generation warning: "Warning: end of member group without matching begin"
00090   *
00091   * Revision 1.7  2000/08/09 22:09:09  jpolast
00092   * added const XMLCh* getURIText()
00093   * allows parsers to use const URIs instead of appending
00094   * to a XMLBuffer.
00095   *
00096   * Revision 1.6  2000/03/02 19:54:25  roddey
00097   * This checkin includes many changes done while waiting for the
00098   * 1.1.0 code to be finished. I can't list them all here, but a list is
00099   * available elsewhere.
00100   *
00101   * Revision 1.5  2000/02/24 20:00:24  abagchi
00102   * Swat for removing Log from API docs
00103   *
00104   * Revision 1.4  2000/02/15 23:59:07  roddey
00105   * More updated documentation of Framework classes.
00106   *
00107   * Revision 1.3  2000/02/15 01:21:31  roddey
00108   * Some initial documentation improvements. More to come...
00109   *
00110   * Revision 1.2  2000/02/06 07:47:49  rahulj
00111   * Year 2K copyright swat.
00112   *
00113   * Revision 1.1.1.1  1999/11/09 01:08:38  twl
00114   * Initial checkin
00115   *
00116   * Revision 1.4  1999/11/08 20:44:41  rahul
00117   * Swat for adding in Product name and CVS comment log variable.
00118   *
00119   */
00120 
00121 
00122 #if !defined(XMLVALIDATOR_HPP)
00123 #define XMLVALIDATOR_HPP
00124 
00125 #include <util/XercesDefs.hpp>
00126 #include <framework/XMLAttr.hpp>
00127 #include <framework/XMLValidityCodes.hpp>
00128 #include <framework/XMLRefInfo.hpp>
00129 
00130 class ReaderMgr;
00131 class XMLBuffer;
00132 class XMLBufferMgr;
00133 class XMLElementDecl;
00134 class XMLEntityHandler;
00135 class XMLErrorReporter;
00136 class XMLMsgLoader;
00137 class XMLScanner;
00138 class Grammar;
00139 
00140 
00156 class  XMLValidator
00157 {
00158 public:
00159     // -----------------------------------------------------------------------
00160     //  Constructors are hidden, just the virtual destructor is exposed
00161     // -----------------------------------------------------------------------
00162 
00165 
00170     virtual ~XMLValidator()
00171     {
00172     }
00174 
00175 
00176     // -----------------------------------------------------------------------
00177     //  The virtual validator interface
00178     // -----------------------------------------------------------------------
00179 
00182 
00203     virtual int checkContent
00204     (
00205         XMLElementDecl* const   elemDecl
00206         , QName** const         children
00207         , const unsigned int    childCount
00208     ) = 0;
00209 
00218     virtual void faultInAttr
00219     (
00220                 XMLAttr&    toFill
00221         , const XMLAttDef&  attDef
00222     )   const = 0;
00223 
00227     virtual void preContentValidation(bool reuseGrammar) = 0;
00228 
00236     virtual void postParseValidation() = 0;
00237 
00243     virtual void reset() = 0;
00244 
00251     virtual bool requiresNamespaces() const = 0;
00252 
00263     virtual void validateAttrValue
00264     (
00265         const   XMLAttDef*                  attDef
00266         , const XMLCh* const                attrValue
00267     ) = 0;
00268 
00276     virtual void validateElement
00277     (
00278         const   XMLElementDecl*             elemDef
00279     ) = 0;
00280 
00284     virtual Grammar* getGrammar() const =0;
00285 
00289     virtual void setGrammar(Grammar* aGrammar) =0;
00290 
00291 
00293 
00294     // -----------------------------------------------------------------------
00295     //  Virtual DTD handler interface.
00296     // -----------------------------------------------------------------------
00297 
00300 
00305     virtual bool handlesDTD() const = 0;
00306 
00307     // -----------------------------------------------------------------------
00308     //  Virtual Schema handler interface.
00309     // -----------------------------------------------------------------------
00310 
00312 
00317     virtual bool handlesSchema() const = 0;
00318 
00320 
00321     // -----------------------------------------------------------------------
00322     //  Setter methods
00323     //
00324     //  setScannerInfo() is called by the scanner to tell the validator
00325     //  about the stuff it needs to have access to.
00326     // -----------------------------------------------------------------------
00327 
00330 
00344     void setScannerInfo
00345     (
00346         XMLScanner* const           owningScanner
00347         , ReaderMgr* const          readerMgr
00348         , XMLBufferMgr* const       bufMgr
00349     );
00350 
00360     void setErrorReporter
00361     (
00362         XMLErrorReporter* const errorReporter
00363     );
00364 
00366 
00367 
00368     // -----------------------------------------------------------------------
00369     //  Error emitter methods
00370     // -----------------------------------------------------------------------
00371 
00374 
00392     void emitError(const XMLValid::Codes toEmit);
00393     void emitError
00394     (
00395         const   XMLValid::Codes toEmit
00396         , const XMLCh* const    text1
00397         , const XMLCh* const    text2 = 0
00398         , const XMLCh* const    text3 = 0
00399         , const XMLCh* const    text4 = 0
00400     );
00401     void emitError
00402     (
00403         const   XMLValid::Codes toEmit
00404         , const char* const     text1
00405         , const char* const     text2 = 0
00406         , const char* const     text3 = 0
00407         , const char* const     text4 = 0
00408     );
00409 
00411 
00412     // -----------------------------------------------------------------------
00413     //  Deprecated XMLValidator interface
00414     // -----------------------------------------------------------------------
00422     bool checkRootElement
00423     (
00424         const   unsigned int    elemId
00425     ) { return true;};
00426 
00427     // -----------------------------------------------------------------------
00428     //  Notification that lazy data has been deleted
00429     // -----------------------------------------------------------------------
00430     static void reinitMsgMutex();
00431 
00432     static void reinitMsgLoader();
00433 
00434 protected :
00435     // -----------------------------------------------------------------------
00436     //  Hidden constructors
00437     // -----------------------------------------------------------------------
00438     XMLValidator
00439     (
00440         XMLErrorReporter* const errReporter = 0
00441     );
00442 
00443 
00444     // -----------------------------------------------------------------------
00445     //  Protected getters
00446     // -----------------------------------------------------------------------
00447     const XMLBufferMgr* getBufMgr() const;
00448     XMLBufferMgr* getBufMgr();
00449     const ReaderMgr* getReaderMgr() const;
00450     ReaderMgr* getReaderMgr();
00451     const XMLScanner* getScanner() const;
00452     XMLScanner* getScanner();
00453 
00454 
00455 private :
00456     // -----------------------------------------------------------------------
00457     //  Unimplemented Constructors and Operators
00458     // -----------------------------------------------------------------------
00459     XMLValidator(const XMLValidator&);
00460     void operator=(const XMLValidator&);
00461 
00462 
00463     // -----------------------------------------------------------------------
00464     //  Private data members
00465     //
00466     //  fErrorReporter
00467     //      The error reporter we are to use, if any.
00468     //
00469     // -----------------------------------------------------------------------
00470     XMLBufferMgr*       fBufMgr;
00471     XMLErrorReporter*   fErrorReporter;
00472     ReaderMgr*          fReaderMgr;
00473     XMLScanner*         fScanner;
00474 
00475 };
00476 
00477 
00478 // -----------------------------------------------------------------------
00479 //  Setter methods
00480 // -----------------------------------------------------------------------
00481 inline void
00482 XMLValidator::setScannerInfo(XMLScanner* const      owningScanner
00483                             , ReaderMgr* const      readerMgr
00484                             , XMLBufferMgr* const   bufMgr)
00485 {
00486     // We don't own any of these, we just reference them
00487     fScanner = owningScanner;
00488     fReaderMgr = readerMgr;
00489     fBufMgr = bufMgr;
00490 }
00491 
00492 inline void
00493 XMLValidator::setErrorReporter(XMLErrorReporter* const errorReporter)
00494 {
00495     fErrorReporter = errorReporter;
00496 }
00497 
00498 
00499 // ---------------------------------------------------------------------------
00500 //  XMLValidator: Protected getter
00501 // ---------------------------------------------------------------------------
00502 inline const XMLBufferMgr* XMLValidator::getBufMgr() const
00503 {
00504     return fBufMgr;
00505 }
00506 
00507 inline XMLBufferMgr* XMLValidator::getBufMgr()
00508 {
00509     return fBufMgr;
00510 }
00511 
00512 inline const ReaderMgr* XMLValidator::getReaderMgr() const
00513 {
00514     return fReaderMgr;
00515 }
00516 
00517 inline ReaderMgr* XMLValidator::getReaderMgr()
00518 {
00519     return fReaderMgr;
00520 }
00521 
00522 inline const XMLScanner* XMLValidator::getScanner() const
00523 {
00524     return fScanner;
00525 }
00526 
00527 inline XMLScanner* XMLValidator::getScanner()
00528 {
00529     return fScanner;
00530 }
00531 
00532 
00533 #endif


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