Xerces-C++: XMLValidator.hpp Source File

Xerces-C++ 3.3.0

XMLValidator.hpp
Go to the documentation of this file.
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18 /*
19 * $Id$
20 */
21
22#if !defined(XERCESC_INCLUDE_GUARD_XMLVALIDATOR_HPP)
23#define XERCESC_INCLUDE_GUARD_XMLVALIDATOR_HPP
24
25#include <xercesc/framework/XMLAttr.hpp>
26#include <xercesc/framework/XMLValidityCodes.hpp>
27
28 XERCES_CPP_NAMESPACE_BEGIN
29
30class ReaderMgr;
31class XMLBufferMgr;
32class XMLElementDecl;
33class XMLScanner;
34class Grammar;
35
36
52 class XMLPARSER_EXPORT XMLValidator : public XMemory
53{
54public:
55 // -----------------------------------------------------------------------
56 // Constructors are hidden, just the virtual destructor is exposed
57 // -----------------------------------------------------------------------
58
61
66 virtual ~XMLValidator()
67 {
68 }
70
71
72 // -----------------------------------------------------------------------
73 // The virtual validator interface
74 // -----------------------------------------------------------------------
75
78
103 virtual bool checkContent
104 (
105 XMLElementDecl* const elemDecl
106 , QName** const children
107 , XMLSize_t childCount
108 , XMLSize_t* indexFailingChild
109 ) = 0;
110
119 virtual void faultInAttr
120 (
121 XMLAttr& toFill
122 , const XMLAttDef& attDef
123 ) const = 0;
124
128 virtual void preContentValidation(bool reuseGrammar,
129 bool validateDefAttr = false) = 0;
130
138 virtual void postParseValidation() = 0;
139
145 virtual void reset() = 0;
146
153 virtual bool requiresNamespaces() const = 0;
154
165 virtual void validateAttrValue
166 (
167 const XMLAttDef* attDef
168 , const XMLCh* const attrValue
169 , bool preValidation = false
170 , const XMLElementDecl* elemDecl = 0
171 ) = 0;
172
180 virtual void validateElement
181 (
182 const XMLElementDecl* elemDef
183 ) = 0;
184
188 virtual Grammar* getGrammar() const =0;
189
193 virtual void setGrammar(Grammar* aGrammar) =0;
194
195
197
198 // -----------------------------------------------------------------------
199 // Virtual DTD handler interface.
200 // -----------------------------------------------------------------------
201
204
209 virtual bool handlesDTD() const = 0;
210
211 // -----------------------------------------------------------------------
212 // Virtual Schema handler interface.
213 // -----------------------------------------------------------------------
214
221 virtual bool handlesSchema() const = 0;
222
224
225 // -----------------------------------------------------------------------
226 // Setter methods
227 //
228 // setScannerInfo() is called by the scanner to tell the validator
229 // about the stuff it needs to have access to.
230 // -----------------------------------------------------------------------
231
234
248 void setScannerInfo
249 (
250 XMLScanner* const owningScanner
251 , ReaderMgr* const readerMgr
252 , XMLBufferMgr* const bufMgr
253 );
254
264 void setErrorReporter
265 (
266 XMLErrorReporter* const errorReporter
267 );
268
270
271
272 // -----------------------------------------------------------------------
273 // Error emitter methods
274 // -----------------------------------------------------------------------
275
278
297 void emitError(const XMLValid::Codes toEmit);
298 void emitError
299 (
300 const XMLValid::Codes toEmit
301 , const XMLCh* const text1
302 , const XMLCh* const text2 = 0
303 , const XMLCh* const text3 = 0
304 , const XMLCh* const text4 = 0
305 );
306 void emitError
307 (
308 const XMLValid::Codes toEmit
309 , const char* const text1
310 , const char* const text2 = 0
311 , const char* const text3 = 0
312 , const char* const text4 = 0
313 );
314 void emitError
315 (
316 const XMLValid::Codes toEmit
317 , const XMLExcepts::Codes originalErrorCode
318 , const XMLCh* const text1 = 0
319 , const XMLCh* const text2 = 0
320 , const XMLCh* const text3 = 0
321 , const XMLCh* const text4 = 0
322
323 );
324
326
327protected :
328 // -----------------------------------------------------------------------
329 // Hidden constructors
330 // -----------------------------------------------------------------------
331 XMLValidator
332 (
333 XMLErrorReporter* const errReporter = 0
334 );
335
336
337 // -----------------------------------------------------------------------
338 // Protected getters
339 // -----------------------------------------------------------------------
340 const XMLBufferMgr* getBufMgr() const;
341 XMLBufferMgr* getBufMgr();
342 const ReaderMgr* getReaderMgr() const;
343 ReaderMgr* getReaderMgr();
344 const XMLScanner* getScanner() const;
345 XMLScanner* getScanner();
346
347
348private :
349 // -----------------------------------------------------------------------
350 // Unimplemented Constructors and Operators
351 // -----------------------------------------------------------------------
352 XMLValidator(const XMLValidator&);
353 XMLValidator& operator=(const XMLValidator&);
354
355
356 // -----------------------------------------------------------------------
357 // Private data members
358 //
359 // fErrorReporter
360 // The error reporter we are to use, if any.
361 //
362 // -----------------------------------------------------------------------
363 XMLBufferMgr* fBufMgr;
364 XMLErrorReporter* fErrorReporter;
365 ReaderMgr* fReaderMgr;
366 XMLScanner* fScanner;
367};
368
369
370// -----------------------------------------------------------------------
371// Setter methods
372// -----------------------------------------------------------------------
373inline void
374XMLValidator::setScannerInfo(XMLScanner* const owningScanner
375 , ReaderMgr* const readerMgr
376 , XMLBufferMgr* const bufMgr)
377{
378 // We don't own any of these, we just reference them
379 fScanner = owningScanner;
380 fReaderMgr = readerMgr;
381 fBufMgr = bufMgr;
382}
383
384inline void
385XMLValidator::setErrorReporter(XMLErrorReporter* const errorReporter)
386{
387 fErrorReporter = errorReporter;
388}
389
390
391// ---------------------------------------------------------------------------
392// XMLValidator: Protected getter
393// ---------------------------------------------------------------------------
394 inline const XMLBufferMgr* XMLValidator::getBufMgr() const
395{
396 return fBufMgr;
397}
398
399 inline XMLBufferMgr* XMLValidator::getBufMgr()
400{
401 return fBufMgr;
402}
403
404 inline const ReaderMgr* XMLValidator::getReaderMgr() const
405{
406 return fReaderMgr;
407}
408
409 inline ReaderMgr* XMLValidator::getReaderMgr()
410{
411 return fReaderMgr;
412}
413
414 inline const XMLScanner* XMLValidator::getScanner() const
415{
416 return fScanner;
417}
418
419 inline XMLScanner* XMLValidator::getScanner()
420{
421 return fScanner;
422}
423
424 XERCES_CPP_NAMESPACE_END
425
426#endif
XMLAttr.hpp
XMLValidityCodes.hpp
XMLPARSER_EXPORT
#define XMLPARSER_EXPORT
Definition XercesDefs.hpp:163
XERCES_CPP_NAMESPACE_BEGIN
#define XERCES_CPP_NAMESPACE_BEGIN
Definition XercesDefs.hpp:112
XERCES_CPP_NAMESPACE_END
#define XERCES_CPP_NAMESPACE_END
Definition XercesDefs.hpp:113
XMLSize_t
size_t XMLSize_t
Definition Xerces_autoconf_config.hpp:112
XMLCh
char16_t XMLCh
Definition Xerces_autoconf_config.hpp:120
QName
Definition QName.hpp:35
XMLAttDef
Represents the core information of an attribute definition.
Definition XMLAttDef.hpp:53
XMLAttr
This class defines the information about an attribute that will come out of the scanner during parsin...
Definition XMLAttr.hpp:54
XMLElementDecl
This class defines the core information of an element declaration.
Definition XMLElementDecl.hpp:52
XMLErrorReporter
This abstract class defines a callback mechanism for the scanner.
Definition XMLErrorReporter.hpp:43
XMLValid::Codes
Codes
Definition XMLValidityCodes.hpp:22
XMLValidator
This abstract class provides the interface for all validators.
Definition XMLValidator.hpp:53
XMLValidator::emitError
void emitError(const XMLValid::Codes toEmit, const char *const text1, const char *const text2=0, const char *const text3=0, const char *const text4=0)
XMLValidator::getGrammar
virtual Grammar * getGrammar() const =0
Retrieve the Grammar used.
XMLValidator::setGrammar
virtual void setGrammar(Grammar *aGrammar)=0
Set the Grammar.
XMLValidator::setErrorReporter
void setErrorReporter(XMLErrorReporter *const errorReporter)
This method is called to set an error reporter on the validator via which it will report any errors i...
Definition XMLValidator.hpp:385
XMLValidator::preContentValidation
virtual void preContentValidation(bool reuseGrammar, bool validateDefAttr=false)=0
This method is called by the scanner after a Grammar is scanned.
XMLValidator::handlesSchema
virtual bool handlesSchema() const =0
This method allows the scanner to ask the validator if it handles Schema or not.
XMLValidator::setScannerInfo
void setScannerInfo(XMLScanner *const owningScanner, ReaderMgr *const readerMgr, XMLBufferMgr *const bufMgr)
Definition XMLValidator.hpp:374
XMLValidator::checkContent
virtual bool checkContent(XMLElementDecl *const elemDecl, QName **const children, XMLSize_t childCount, XMLSize_t *indexFailingChild)=0
The derived class should look up its declaration of the passed element from its element pool.
XMLValidator::getScanner
const XMLScanner * getScanner() const
Definition XMLValidator.hpp:414
XMLValidator::XMLValidator
XMLValidator(XMLErrorReporter *const errReporter=0)
XMLValidator::validateElement
virtual void validateElement(const XMLElementDecl *elemDef)=0
The derived class should apply any rules to the passed element decl that are above and beyond those d...
XMLValidator::emitError
void emitError(const XMLValid::Codes toEmit, const XMLCh *const text1, const XMLCh *const text2=0, const XMLCh *const text3=0, const XMLCh *const text4=0)
XMLValidator::faultInAttr
virtual void faultInAttr(XMLAttr &toFill, const XMLAttDef &attDef) const =0
The derived class should fault in the passed XMLAttr value.
XMLValidator::getReaderMgr
const ReaderMgr * getReaderMgr() const
Definition XMLValidator.hpp:404
XMLValidator::validateAttrValue
virtual void validateAttrValue(const XMLAttDef *attDef, const XMLCh *const attrValue, bool preValidation=false, const XMLElementDecl *elemDecl=0)=0
The derived class should apply any rules to the passed attribute value that are above and beyond thos...
XMLValidator::requiresNamespaces
virtual bool requiresNamespaces() const =0
The derived class should return a boolean that indicates whether it requires namespace processing or ...
XMLValidator::getBufMgr
const XMLBufferMgr * getBufMgr() const
Definition XMLValidator.hpp:394
XMLValidator::~XMLValidator
virtual ~XMLValidator()
The derived class should clean up its allocated data, then this class will do the same for data alloc...
Definition XMLValidator.hpp:66
XMLValidator::postParseValidation
virtual void postParseValidation()=0
This method is called by the scanner after the parse has completed.
XMLValidator::emitError
void emitError(const XMLValid::Codes toEmit)
This call is a convenience by which validators can emit errors.
XMLValidator::reset
virtual void reset()=0
This method is called by the scanner before a new document is about to start.
XMLValidator::handlesDTD
virtual bool handlesDTD() const =0
This method allows the scanner to ask the validator if it handles DTDs or not.
XMLValidator::emitError
void emitError(const XMLValid::Codes toEmit, const XMLExcepts::Codes originalErrorCode, const XMLCh *const text1=0, const XMLCh *const text2=0, const XMLCh *const text3=0, const XMLCh *const text4=0)
XMemory
This class makes it possible to override the C++ memory management by adding new/delete operators to ...
Definition XMemory.hpp:41