source: NonGTP/Xerces/xercesc/validators/DTD/DTDValidator.hpp @ 188

Revision 188, 9.7 KB checked in by mattausch, 19 years ago (diff)

added xercesc to support

Line 
1/*
2 * The Apache Software License, Version 1.1
3 *
4 * Copyright (c) 1999-2001 The Apache Software Foundation.  All rights
5 * reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * 1. Redistributions of source code must retain the above copyright
12 *    notice, this list of conditions and the following disclaimer.
13 *
14 * 2. Redistributions in binary form must reproduce the above copyright
15 *    notice, this list of conditions and the following disclaimer in
16 *    the documentation and/or other materials provided with the
17 *    distribution.
18 *
19 * 3. The end-user documentation included with the redistribution,
20 *    if any, must include the following acknowledgment:
21 *       "This product includes software developed by the
22 *        Apache Software Foundation (http://www.apache.org/)."
23 *    Alternately, this acknowledgment may appear in the software itself,
24 *    if and wherever such third-party acknowledgments normally appear.
25 *
26 * 4. The names "Xerces" and "Apache Software Foundation" must
27 *    not be used to endorse or promote products derived from this
28 *    software without prior written permission. For written
29 *    permission, please contact apache\@apache.org.
30 *
31 * 5. Products derived from this software may not be called "Apache",
32 *    nor may "Apache" appear in their name, without prior written
33 *    permission of the Apache Software Foundation.
34 *
35 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
36 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
37 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
38 * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
39 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
40 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
41 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
42 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
43 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
44 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
45 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
46 * SUCH DAMAGE.
47 * ====================================================================
48 *
49 * This software consists of voluntary contributions made by many
50 * individuals on behalf of the Apache Software Foundation, and was
51 * originally based on software copyright (c) 1999, International
52 * Business Machines, Inc., http://www.ibm.com .  For more information
53 * on the Apache Software Foundation, please see
54 * <http://www.apache.org/>.
55 */
56
57/*
58 * $Log: DTDValidator.hpp,v $
59 * Revision 1.7  2004/01/29 11:52:30  cargilld
60 * Code cleanup changes to get rid of various compiler diagnostic messages.
61 *
62 * Revision 1.6  2002/11/07 21:58:56  tng
63 * Pass elemDecl to XMLValidator::validateAttrValue so that we can include element name in error message.
64 *
65 * Revision 1.5  2002/11/04 14:50:40  tng
66 * C++ Namespace Support.
67 *
68 * Revision 1.4  2002/09/04 18:17:49  tng
69 * Do not set IDREF to used during prevalidation.
70 *
71 * Revision 1.3  2002/08/22 15:05:40  tng
72 * Remove unused parameter variables in inline functions.
73 *
74 * Revision 1.2  2002/07/11 18:55:44  knoaman
75 * Add a flag to the preContentValidation method to indicate whether to validate
76 * default/fixed attributes or not.
77 *
78 * Revision 1.1.1.1  2002/02/01 22:22:45  peiyongz
79 * sane_include
80 *
81 * Revision 1.13  2001/11/13 13:25:28  tng
82 * Deprecate function XMLValidator::checkRootElement.
83 *
84 * Revision 1.12  2001/06/05 16:51:20  knoaman
85 * Add 'const' to getGrammar - submitted by Peter A. Volchek.
86 *
87 * Revision 1.11  2001/05/11 13:27:11  tng
88 * Copyright update.
89 *
90 * Revision 1.10  2001/05/03 20:34:37  tng
91 * Schema: SchemaValidator update
92 *
93 * Revision 1.9  2001/04/19 18:17:23  tng
94 * Schema: SchemaValidator update, and use QName in Content Model
95 *
96 * Revision 1.8  2001/03/21 21:56:21  tng
97 * Schema: Add Schema Grammar, Schema Validator, and split the DTDValidator into DTDValidator, DTDScanner, and DTDGrammar.
98 *
99 * Revision 1.7  2001/02/26 19:22:08  tng
100 * Schema: add parameter prefix in findElem and findAttr.
101 *
102 * Revision 1.6  2000/08/09 22:08:48  jpolast
103 * added const XMLCh* getURIText() as per XMLValidator.
104 * allows parsers to use const URIs instead of appending
105 * to a XMLBuffer.
106 *
107 * Revision 1.5  2000/04/06 19:00:07  roddey
108 * Added a getter for the doc type handler.
109 *
110 * Revision 1.4  2000/02/24 20:16:49  abagchi
111 * Swat for removing Log from API docs
112 *
113 * Revision 1.3  2000/02/09 21:42:38  abagchi
114 * Copyright swat
115 *
116 * Revision 1.2  2000/01/12 23:52:48  roddey
117 * These are trivial changes required to get the C++ and Java versions
118 * of error messages more into sync. Mostly it was where the Java version
119 * was passing out one or more parameter than the C++ version was. In
120 * some cases the change just required an extra parameter to get the
121 * needed info to the place where the error was issued.
122 *
123 * Revision 1.1.1.1  1999/11/09 01:03:36  twl
124 * Initial checkin
125 *
126 * Revision 1.5  1999/11/08 20:45:41  rahul
127 * Swat for adding in Product name and CVS comment log variable.
128 *
129 */
130
131
132
133#if !defined(DTDVALIDATOR_HPP)
134#define DTDVALIDATOR_HPP
135
136#include <xercesc/util/NameIdPool.hpp>
137#include <xercesc/framework/XMLValidator.hpp>
138#include <xercesc/validators/DTD/DTDGrammar.hpp>
139
140XERCES_CPP_NAMESPACE_BEGIN
141
142class XMLMsgLoader;
143
144
145//
146//  This is a derivative of the abstract validator interface. This class
147//  implements a validator that supports standard XML 1.0 DTD semantics.
148//  This class handles scanning the internal and external subsets of the
149//  DTD, and provides the standard validation services against the DTD info
150//  it found.
151//
152class VALIDATORS_EXPORT DTDValidator : public XMLValidator
153{
154public:
155    // -----------------------------------------------------------------------
156    //  Constructors and Destructor
157    // -----------------------------------------------------------------------
158    DTDValidator(XMLErrorReporter* const errReporter = 0);
159    virtual ~DTDValidator();
160
161    // -----------------------------------------------------------------------
162    //  Implementation of the XMLValidator interface
163    // -----------------------------------------------------------------------
164    virtual int checkContent
165    (
166        XMLElementDecl* const   elemDecl
167        , QName** const         children
168        , const unsigned int    childCount
169    );
170
171    virtual void faultInAttr
172    (
173                XMLAttr&    toFill
174        , const XMLAttDef&  attDef
175    )   const;
176
177    virtual void preContentValidation(bool reuseGrammar,
178                                      bool validateDefAttr = false);
179
180    virtual void postParseValidation();
181
182    virtual void reset();
183
184    virtual bool requiresNamespaces() const;
185
186    virtual void validateAttrValue
187    (
188        const   XMLAttDef*                  attDef
189        , const XMLCh* const                attrValue
190        , bool                              preValidation = false
191        , const XMLElementDecl*             elemDecl = 0
192    );
193    virtual void validateElement
194    (
195        const   XMLElementDecl*             elemDef
196    );
197    virtual Grammar* getGrammar() const;
198    virtual void setGrammar(Grammar* aGrammar);
199
200    // -----------------------------------------------------------------------
201    //  Virtual DTD handler interface.
202    // -----------------------------------------------------------------------
203    virtual bool handlesDTD() const;
204
205    // -----------------------------------------------------------------------
206    //  Virtual Schema handler interface. handlesSchema() always return false.
207    // -----------------------------------------------------------------------
208    virtual bool handlesSchema() const;
209
210private:
211    // -----------------------------------------------------------------------
212    // Unimplemented constructors and operators
213    // -----------------------------------------------------------------------
214    DTDValidator(const DTDValidator &);
215    DTDValidator& operator = (const  DTDValidator&);
216
217    // -----------------------------------------------------------------------
218    //  Private data members
219    //
220    //  fDTDGrammar
221    //      The DTD information stored.
222    //
223    // -----------------------------------------------------------------------
224    DTDGrammar*                     fDTDGrammar;
225};
226
227// ---------------------------------------------------------------------------
228//  Virtual interface
229// ---------------------------------------------------------------------------
230inline Grammar* DTDValidator::getGrammar() const {
231    return fDTDGrammar;
232}
233
234inline void DTDValidator::setGrammar(Grammar* aGrammar) {
235    fDTDGrammar = (DTDGrammar*) aGrammar;
236}
237
238inline void DTDValidator::validateElement (const   XMLElementDecl*) {
239    // no special DTD Element validation
240}
241
242// ---------------------------------------------------------------------------
243//  DTDValidator: DTD handler interface
244// ---------------------------------------------------------------------------
245inline bool DTDValidator::handlesDTD() const
246{
247    // We definitely want to handle DTD scanning
248    return true;
249}
250
251// ---------------------------------------------------------------------------
252//  DTDValidator: Schema handler interface
253// ---------------------------------------------------------------------------
254inline bool DTDValidator::handlesSchema() const
255{
256    // No Schema scanning
257    return false;
258}
259
260XERCES_CPP_NAMESPACE_END
261
262#endif
Note: See TracBrowser for help on using the repository browser.