1 | /*
|
---|
2 | * The Apache Software License, Version 1.1
|
---|
3 | *
|
---|
4 | * Copyright (c) 2001-2003 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) 2001, 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: SchemaValidator.hpp,v $
|
---|
59 | * Revision 1.25 2004/01/29 11:52:31 cargilld
|
---|
60 | * Code cleanup changes to get rid of various compiler diagnostic messages.
|
---|
61 | *
|
---|
62 | * Revision 1.24 2003/12/03 20:00:27 neilg
|
---|
63 | * PSVI fix: cannot allow validator to reset its element content buffer before exposing it to the application
|
---|
64 | *
|
---|
65 | * Revision 1.23 2003/11/28 21:18:32 knoaman
|
---|
66 | * Make use of canonical representation in PSVIElement
|
---|
67 | *
|
---|
68 | * Revision 1.22 2003/11/27 22:52:37 knoaman
|
---|
69 | * PSVIElement implementation
|
---|
70 | *
|
---|
71 | * Revision 1.21 2003/11/27 06:10:31 neilg
|
---|
72 | * PSVIAttribute implementation
|
---|
73 | *
|
---|
74 | * Revision 1.20 2003/11/24 05:13:20 neilg
|
---|
75 | * expose validator that actually validated attribute. Clean up union handling
|
---|
76 | *
|
---|
77 | * Revision 1.19 2003/10/05 02:09:37 neilg
|
---|
78 | * the validator now keeps track of the current complex and simple type (including if this is an xsi:type). This allows both the validator and the scanner to know what the current type is, without the need to modify the element declaration each time an xsi:type is seen
|
---|
79 | *
|
---|
80 | * Revision 1.18 2003/08/14 03:01:04 knoaman
|
---|
81 | * Code refactoring to improve performance of validation.
|
---|
82 | *
|
---|
83 | * Revision 1.17 2003/05/18 14:02:08 knoaman
|
---|
84 | * Memory manager implementation: pass per instance manager.
|
---|
85 | *
|
---|
86 | * Revision 1.16 2003/05/16 21:43:21 knoaman
|
---|
87 | * Memory manager implementation: Modify constructors to pass in the memory manager.
|
---|
88 | *
|
---|
89 | * Revision 1.15 2003/05/16 03:15:51 knoaman
|
---|
90 | * Partial implementation of the configurable memory manager.
|
---|
91 | *
|
---|
92 | * Revision 1.14 2003/05/15 18:57:27 knoaman
|
---|
93 | * Partial implementation of the configurable memory manager.
|
---|
94 | *
|
---|
95 | * Revision 1.13 2003/01/20 19:04:48 knoaman
|
---|
96 | * Fix for particle derivation checking.
|
---|
97 | *
|
---|
98 | * Revision 1.12 2003/01/13 20:16:51 knoaman
|
---|
99 | * [Bug 16024] SchemaSymbols.hpp conflicts C++ Builder 6 dir.h
|
---|
100 | *
|
---|
101 | * Revision 1.11 2003/01/09 22:34:54 tng
|
---|
102 | * [Bug 14955] error validating parser.
|
---|
103 | *
|
---|
104 | * Revision 1.10 2002/11/07 21:57:37 tng
|
---|
105 | * Fix the following Schema Test Failures:
|
---|
106 | * 1. Typo when comparing miscFlags with FIXED
|
---|
107 | * 2. If xsi:type is specified, need to validate using that xsitype validator even if the type was any
|
---|
108 | * 3. Need to check ID/IDREFs for element value
|
---|
109 | * 4. Need to duplicate attribute id for wildcard scenario.
|
---|
110 | *
|
---|
111 | * Revision 1.9 2002/11/04 14:49:42 tng
|
---|
112 | * C++ Namespace Support.
|
---|
113 | *
|
---|
114 | * Revision 1.8 2002/09/04 18:17:41 tng
|
---|
115 | * Do not set IDREF to used during prevalidation.
|
---|
116 | *
|
---|
117 | * Revision 1.7 2002/07/11 18:55:45 knoaman
|
---|
118 | * Add a flag to the preContentValidation method to indicate whether to validate
|
---|
119 | * default/fixed attributes or not.
|
---|
120 | *
|
---|
121 | * Revision 1.6 2002/06/17 18:09:29 tng
|
---|
122 | * DOM L3: support "datatype-normalization"
|
---|
123 | *
|
---|
124 | * Revision 1.5 2002/05/22 20:54:14 knoaman
|
---|
125 | * Prepare for DOM L3 :
|
---|
126 | * - Make use of the XMLEntityHandler/XMLErrorReporter interfaces, instead of using
|
---|
127 | * EntityHandler/ErrorHandler directly.
|
---|
128 | * - Add 'AbstractDOMParser' class to provide common functionality for XercesDOMParser
|
---|
129 | * and DOMBuilder.
|
---|
130 | *
|
---|
131 | * Revision 1.4 2002/04/19 13:33:23 knoaman
|
---|
132 | * Fix for bug 8236.
|
---|
133 | *
|
---|
134 | * Revision 1.3 2002/04/01 15:47:06 knoaman
|
---|
135 | * Move Element Consistency checking (ref to global declarations) to SchemaValidator.
|
---|
136 | *
|
---|
137 | * Revision 1.2 2002/03/25 20:25:32 knoaman
|
---|
138 | * Move particle derivation checking from TraverseSchema to SchemaValidator.
|
---|
139 | *
|
---|
140 | * Revision 1.1.1.1 2002/02/01 22:22:47 peiyongz
|
---|
141 | * sane_include
|
---|
142 | *
|
---|
143 | * Revision 1.8 2001/11/13 13:25:08 tng
|
---|
144 | * Deprecate function XMLValidator::checkRootElement.
|
---|
145 | *
|
---|
146 | * Revision 1.7 2001/06/05 16:51:21 knoaman
|
---|
147 | * Add 'const' to getGrammar - submitted by Peter A. Volchek.
|
---|
148 | *
|
---|
149 | * Revision 1.6 2001/05/11 15:17:48 tng
|
---|
150 | * Schema: Nillable fixes.
|
---|
151 | *
|
---|
152 | * Revision 1.5 2001/05/11 13:27:37 tng
|
---|
153 | * Copyright update.
|
---|
154 | *
|
---|
155 | * Revision 1.4 2001/05/03 20:34:45 tng
|
---|
156 | * Schema: SchemaValidator update
|
---|
157 | *
|
---|
158 | * Revision 1.3 2001/04/19 18:17:40 tng
|
---|
159 | * Schema: SchemaValidator update, and use QName in Content Model
|
---|
160 | *
|
---|
161 | * Revision 1.2 2001/03/30 16:35:20 tng
|
---|
162 | * Schema: Whitespace normalization.
|
---|
163 | *
|
---|
164 | * Revision 1.1 2001/03/21 21:56:33 tng
|
---|
165 | * Schema: Add Schema Grammar, Schema Validator, and split the DTDValidator into DTDValidator, DTDScanner, and DTDGrammar.
|
---|
166 | *
|
---|
167 | */
|
---|
168 |
|
---|
169 |
|
---|
170 |
|
---|
171 | #if !defined(SCHEMAVALIDATOR_HPP)
|
---|
172 | #define SCHEMAVALIDATOR_HPP
|
---|
173 |
|
---|
174 | #include <xercesc/framework/XMLValidator.hpp>
|
---|
175 | #include <xercesc/framework/XMLBuffer.hpp>
|
---|
176 | #include <xercesc/util/ValueStackOf.hpp>
|
---|
177 | #include <xercesc/validators/common/ContentSpecNode.hpp>
|
---|
178 | #include <xercesc/validators/schema/SchemaGrammar.hpp>
|
---|
179 | #include <xercesc/validators/schema/XSDErrorReporter.hpp>
|
---|
180 |
|
---|
181 | XERCES_CPP_NAMESPACE_BEGIN
|
---|
182 |
|
---|
183 | class GrammarResolver;
|
---|
184 | class DatatypeValidator;
|
---|
185 | class SchemaElementDecl;
|
---|
186 |
|
---|
187 | //
|
---|
188 | // This is a derivative of the abstract validator interface. This class
|
---|
189 | // implements a validator that supports standard XML Schema semantics.
|
---|
190 | // This class handles scanning the of the schema, and provides
|
---|
191 | // the standard validation services against the Schema info it found.
|
---|
192 | //
|
---|
193 | class VALIDATORS_EXPORT SchemaValidator : public XMLValidator
|
---|
194 | {
|
---|
195 | public:
|
---|
196 | // -----------------------------------------------------------------------
|
---|
197 | // Constructors and Destructor
|
---|
198 | // -----------------------------------------------------------------------
|
---|
199 | SchemaValidator
|
---|
200 | (
|
---|
201 | XMLErrorReporter* const errReporter = 0
|
---|
202 | , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
|
---|
203 | );
|
---|
204 | virtual ~SchemaValidator();
|
---|
205 |
|
---|
206 | // -----------------------------------------------------------------------
|
---|
207 | // Implementation of the XMLValidator interface
|
---|
208 | // -----------------------------------------------------------------------
|
---|
209 | virtual int checkContent
|
---|
210 | (
|
---|
211 | XMLElementDecl* const elemDecl
|
---|
212 | , QName** const children
|
---|
213 | , const unsigned int childCount
|
---|
214 | );
|
---|
215 |
|
---|
216 | virtual void faultInAttr
|
---|
217 | (
|
---|
218 | XMLAttr& toFill
|
---|
219 | , const XMLAttDef& attDef
|
---|
220 | ) const;
|
---|
221 |
|
---|
222 | virtual void preContentValidation(bool reuseGrammar,
|
---|
223 | bool validateDefAttr = false);
|
---|
224 |
|
---|
225 | virtual void postParseValidation();
|
---|
226 |
|
---|
227 | virtual void reset();
|
---|
228 |
|
---|
229 | virtual bool requiresNamespaces() const;
|
---|
230 |
|
---|
231 | virtual void validateAttrValue
|
---|
232 | (
|
---|
233 | const XMLAttDef* attDef
|
---|
234 | , const XMLCh* const attrValue
|
---|
235 | , bool preValidation = false
|
---|
236 | , const XMLElementDecl* elemDecl = 0
|
---|
237 | );
|
---|
238 |
|
---|
239 | virtual void validateElement
|
---|
240 | (
|
---|
241 | const XMLElementDecl* elemDef
|
---|
242 | );
|
---|
243 |
|
---|
244 | virtual Grammar* getGrammar() const;
|
---|
245 | virtual void setGrammar(Grammar* aGrammar);
|
---|
246 |
|
---|
247 | // -----------------------------------------------------------------------
|
---|
248 | // Virtual DTD handler interface.
|
---|
249 | // -----------------------------------------------------------------------
|
---|
250 | virtual bool handlesDTD() const;
|
---|
251 |
|
---|
252 | // -----------------------------------------------------------------------
|
---|
253 | // Virtual Schema handler interface. handlesSchema() always return false.
|
---|
254 | // -----------------------------------------------------------------------
|
---|
255 | virtual bool handlesSchema() const;
|
---|
256 |
|
---|
257 | // -----------------------------------------------------------------------
|
---|
258 | // Schema Validator methods
|
---|
259 | // -----------------------------------------------------------------------
|
---|
260 | void normalizeWhiteSpace(DatatypeValidator* dV, const XMLCh* const value, XMLBuffer& toFill);
|
---|
261 |
|
---|
262 | // -----------------------------------------------------------------------
|
---|
263 | // Setter methods
|
---|
264 | // -----------------------------------------------------------------------
|
---|
265 | void setGrammarResolver(GrammarResolver* grammarResolver);
|
---|
266 |
|
---|
267 | void setXsiType(const XMLCh* const prefix
|
---|
268 | , const XMLCh* const localPart
|
---|
269 | , const unsigned int uriId);
|
---|
270 |
|
---|
271 | void setNillable(bool isNil);
|
---|
272 | void setErrorReporter(XMLErrorReporter* const errorReporter);
|
---|
273 | void setExitOnFirstFatal(const bool newValue);
|
---|
274 | void setDatatypeBuffer(const XMLCh* const value);
|
---|
275 | void clearDatatypeBuffer();
|
---|
276 |
|
---|
277 | // -----------------------------------------------------------------------
|
---|
278 | // Getter methods
|
---|
279 | // -----------------------------------------------------------------------
|
---|
280 | ComplexTypeInfo* getCurrentTypeInfo() const;
|
---|
281 | DatatypeValidator *getCurrentDatatypeValidator() const;
|
---|
282 | DatatypeValidator *getMostRecentAttrValidator() const;
|
---|
283 | bool getErrorOccurred() const;
|
---|
284 | bool getIsElemSpecified() const;
|
---|
285 | const XMLCh* getNormalizedValue() const;
|
---|
286 |
|
---|
287 | private:
|
---|
288 | // -----------------------------------------------------------------------
|
---|
289 | // Unimplemented constructors and operators
|
---|
290 | // -----------------------------------------------------------------------
|
---|
291 | SchemaValidator(const SchemaValidator&);
|
---|
292 | SchemaValidator& operator=(const SchemaValidator&);
|
---|
293 |
|
---|
294 | // -----------------------------------------------------------------------
|
---|
295 | // Element Consitency Checking methods
|
---|
296 | // -----------------------------------------------------------------------
|
---|
297 | void checkRefElementConsistency(SchemaGrammar* const currentGrammar,
|
---|
298 | const ComplexTypeInfo* const curTypeInfo,
|
---|
299 | const XercesGroupInfo* const curGroup = 0);
|
---|
300 |
|
---|
301 | // -----------------------------------------------------------------------
|
---|
302 | // Particle Derivation Checking methods
|
---|
303 | // -----------------------------------------------------------------------
|
---|
304 | void checkParticleDerivation(SchemaGrammar* const currentGrammar,
|
---|
305 | const ComplexTypeInfo* const typeInfo);
|
---|
306 | void checkParticleDerivationOk(SchemaGrammar* const currentGrammar,
|
---|
307 | ContentSpecNode* const curNode,
|
---|
308 | const int derivedScope,
|
---|
309 | ContentSpecNode* const baseNode,
|
---|
310 | const int baseScope,
|
---|
311 | const ComplexTypeInfo* const baseInfo = 0,
|
---|
312 | const bool toCheckOccurrence = true);
|
---|
313 | ContentSpecNode* checkForPointlessOccurrences(ContentSpecNode* const specNode,
|
---|
314 | const ContentSpecNode::NodeTypes nodeType,
|
---|
315 | ValueVectorOf<ContentSpecNode*>* const nodes);
|
---|
316 | void gatherChildren(const ContentSpecNode::NodeTypes parentNodeType,
|
---|
317 | ContentSpecNode* const specNode,
|
---|
318 | ValueVectorOf<ContentSpecNode*>* const nodes);
|
---|
319 | bool isOccurrenceRangeOK(const int min1, const int max1, const int min2, const int max2);
|
---|
320 | void checkNSCompat(const ContentSpecNode* const derivedSpecNode,
|
---|
321 | const ContentSpecNode* const baseSpecNode,
|
---|
322 | const bool toCheckOccurence);
|
---|
323 | bool wildcardEltAllowsNamespace(const ContentSpecNode* const baseSpecNode,
|
---|
324 | const unsigned int derivedURI);
|
---|
325 | void checkNameAndTypeOK(SchemaGrammar* const currentGrammar,
|
---|
326 | const ContentSpecNode* const derivedSpecNode,
|
---|
327 | const int derivedScope,
|
---|
328 | const ContentSpecNode* const baseSpecNode,
|
---|
329 | const int baseScope,
|
---|
330 | const ComplexTypeInfo* const baseInfo = 0);
|
---|
331 | SchemaElementDecl* findElement(const int scope,
|
---|
332 | const unsigned int uriIndex,
|
---|
333 | const XMLCh* const name,
|
---|
334 | SchemaGrammar* const grammar,
|
---|
335 | const ComplexTypeInfo* const typeInfo = 0);
|
---|
336 | void checkICRestriction(const SchemaElementDecl* const derivedElemDecl,
|
---|
337 | const SchemaElementDecl* const baseElemDecl,
|
---|
338 | const XMLCh* const derivedElemName,
|
---|
339 | const XMLCh* const baseElemName);
|
---|
340 | void checkTypesOK(const SchemaElementDecl* const derivedElemDecl,
|
---|
341 | const SchemaElementDecl* const baseElemDecl,
|
---|
342 | const XMLCh* const derivedElemName);
|
---|
343 | void checkRecurseAsIfGroup(SchemaGrammar* const currentGrammar,
|
---|
344 | ContentSpecNode* const derivedSpecNode,
|
---|
345 | const int derivedScope,
|
---|
346 | const ContentSpecNode* const baseSpecNode,
|
---|
347 | const int baseScope,
|
---|
348 | ValueVectorOf<ContentSpecNode*>* const nodes,
|
---|
349 | const ComplexTypeInfo* const baseInfo);
|
---|
350 | void checkRecurse(SchemaGrammar* const currentGrammar,
|
---|
351 | const ContentSpecNode* const derivedSpecNode,
|
---|
352 | const int derivedScope,
|
---|
353 | ValueVectorOf<ContentSpecNode*>* const derivedNodes,
|
---|
354 | const ContentSpecNode* const baseSpecNode,
|
---|
355 | const int baseScope,
|
---|
356 | ValueVectorOf<ContentSpecNode*>* const baseNodes,
|
---|
357 | const ComplexTypeInfo* const baseInfo,
|
---|
358 | const bool toLax = false);
|
---|
359 | void checkNSSubset(const ContentSpecNode* const derivedSpecNode,
|
---|
360 | const ContentSpecNode* const baseSpecNode);
|
---|
361 | bool isWildCardEltSubset(const ContentSpecNode* const derivedSpecNode,
|
---|
362 | const ContentSpecNode* const baseSpecNode);
|
---|
363 | void checkNSRecurseCheckCardinality(SchemaGrammar* const currentGrammar,
|
---|
364 | const ContentSpecNode* const derivedSpecNode,
|
---|
365 | ValueVectorOf<ContentSpecNode*>* const derivedNodes,
|
---|
366 | const int derivedScope,
|
---|
367 | ContentSpecNode* const baseSpecNode,
|
---|
368 | const bool toCheckOccurence);
|
---|
369 | void checkRecurseUnordered(SchemaGrammar* const currentGrammar,
|
---|
370 | const ContentSpecNode* const derivedSpecNode,
|
---|
371 | ValueVectorOf<ContentSpecNode*>* const derivedNodes,
|
---|
372 | const int derivedScope,
|
---|
373 | ContentSpecNode* const baseSpecNode,
|
---|
374 | ValueVectorOf<ContentSpecNode*>* const baseNodes,
|
---|
375 | const int baseScope,
|
---|
376 | const ComplexTypeInfo* const baseInfo);
|
---|
377 | void checkMapAndSum(SchemaGrammar* const currentGrammar,
|
---|
378 | const ContentSpecNode* const derivedSpecNode,
|
---|
379 | ValueVectorOf<ContentSpecNode*>* const derivedNodes,
|
---|
380 | const int derivedScope,
|
---|
381 | ContentSpecNode* const baseSpecNode,
|
---|
382 | ValueVectorOf<ContentSpecNode*>* const baseNodes,
|
---|
383 | const int baseScope,
|
---|
384 | const ComplexTypeInfo* const baseInfo);
|
---|
385 |
|
---|
386 | // -----------------------------------------------------------------------
|
---|
387 | // Private data members
|
---|
388 | //
|
---|
389 | // -----------------------------------------------------------------------
|
---|
390 | // The following comes from or set by the Scanner
|
---|
391 | // fSchemaGrammar
|
---|
392 | // The current schema grammar used by the validator
|
---|
393 | //
|
---|
394 | // fGrammarResolver
|
---|
395 | // All the schema grammar stored
|
---|
396 | //
|
---|
397 | // fXsiType
|
---|
398 | // Store the Schema Type Attribute Value if schema type is specified
|
---|
399 | //
|
---|
400 | // fNil
|
---|
401 | // Indicates if Nillable has been set
|
---|
402 | // -----------------------------------------------------------------------
|
---|
403 | // The following used internally in the validator
|
---|
404 | //
|
---|
405 | // fCurrentDatatypeValidator
|
---|
406 | // The validator used for validating the content of elements
|
---|
407 | // with simple types
|
---|
408 | //
|
---|
409 | // fDatatypeBuffer
|
---|
410 | // Buffer for simple type element string content
|
---|
411 | //
|
---|
412 | // fTrailing
|
---|
413 | // Previous chunk had a trailing space
|
---|
414 | //
|
---|
415 | // fSeenId
|
---|
416 | // Indicate if an attribute of ID type has been seen already, reset per element.
|
---|
417 | //
|
---|
418 | // fSchemaErrorReporter
|
---|
419 | // Report schema process errors
|
---|
420 | //
|
---|
421 | // fTypeStack
|
---|
422 | // Stack of complex type declarations.
|
---|
423 | //
|
---|
424 | // fMostRecentAttrValidator
|
---|
425 | // DatatypeValidator that validated attribute most recently processed
|
---|
426 | //
|
---|
427 | // fErrorOccurred
|
---|
428 | // whether an error occurred in the most recent operation
|
---|
429 | // -----------------------------------------------------------------------
|
---|
430 | MemoryManager* fMemoryManager;
|
---|
431 | SchemaGrammar* fSchemaGrammar;
|
---|
432 | GrammarResolver* fGrammarResolver;
|
---|
433 | QName* fXsiType;
|
---|
434 | bool fNil;
|
---|
435 | DatatypeValidator* fCurrentDatatypeValidator;
|
---|
436 | XMLBuffer* fNotationBuf;
|
---|
437 | XMLBuffer fDatatypeBuffer;
|
---|
438 | bool fTrailing;
|
---|
439 | bool fSeenId;
|
---|
440 | XSDErrorReporter fSchemaErrorReporter;
|
---|
441 | ValueStackOf<ComplexTypeInfo*>* fTypeStack;
|
---|
442 | DatatypeValidator * fMostRecentAttrValidator;
|
---|
443 | bool fErrorOccurred;
|
---|
444 | bool fElemIsSpecified;
|
---|
445 | };
|
---|
446 |
|
---|
447 |
|
---|
448 | // ---------------------------------------------------------------------------
|
---|
449 | // SchemaValidator: Setter methods
|
---|
450 | // ---------------------------------------------------------------------------
|
---|
451 | inline void SchemaValidator::setGrammarResolver(GrammarResolver* grammarResolver) {
|
---|
452 | fGrammarResolver = grammarResolver;
|
---|
453 | }
|
---|
454 |
|
---|
455 | inline void SchemaValidator::setXsiType(const XMLCh* const prefix
|
---|
456 | , const XMLCh* const localPart
|
---|
457 | , const unsigned int uriId)
|
---|
458 | {
|
---|
459 | delete fXsiType;
|
---|
460 | fXsiType = new (fMemoryManager) QName(prefix, localPart, uriId, fMemoryManager);
|
---|
461 | }
|
---|
462 |
|
---|
463 | inline void SchemaValidator::setNillable(bool isNil) {
|
---|
464 | fNil = isNil;
|
---|
465 | }
|
---|
466 |
|
---|
467 | inline void SchemaValidator::setExitOnFirstFatal(const bool newValue) {
|
---|
468 |
|
---|
469 | fSchemaErrorReporter.setExitOnFirstFatal(newValue);
|
---|
470 | }
|
---|
471 |
|
---|
472 | inline void SchemaValidator::setDatatypeBuffer(const XMLCh* const value)
|
---|
473 | {
|
---|
474 | fDatatypeBuffer.append(value);
|
---|
475 | }
|
---|
476 |
|
---|
477 | inline void SchemaValidator::clearDatatypeBuffer()
|
---|
478 | {
|
---|
479 | fDatatypeBuffer.reset();
|
---|
480 | }
|
---|
481 |
|
---|
482 | // ---------------------------------------------------------------------------
|
---|
483 | // SchemaValidator: Getter methods
|
---|
484 | // ---------------------------------------------------------------------------
|
---|
485 | inline ComplexTypeInfo* SchemaValidator::getCurrentTypeInfo() const {
|
---|
486 | if (fTypeStack->empty())
|
---|
487 | return 0;
|
---|
488 | return fTypeStack->peek();
|
---|
489 | }
|
---|
490 |
|
---|
491 | inline DatatypeValidator * SchemaValidator::getCurrentDatatypeValidator() const
|
---|
492 | {
|
---|
493 | return fCurrentDatatypeValidator;
|
---|
494 | }
|
---|
495 | inline DatatypeValidator *SchemaValidator::getMostRecentAttrValidator() const
|
---|
496 | {
|
---|
497 | return fMostRecentAttrValidator;
|
---|
498 | }
|
---|
499 |
|
---|
500 | // ---------------------------------------------------------------------------
|
---|
501 | // Virtual interface
|
---|
502 | // ---------------------------------------------------------------------------
|
---|
503 | inline Grammar* SchemaValidator::getGrammar() const {
|
---|
504 | return fSchemaGrammar;
|
---|
505 | }
|
---|
506 |
|
---|
507 | inline void SchemaValidator::setGrammar(Grammar* aGrammar) {
|
---|
508 | fSchemaGrammar = (SchemaGrammar*) aGrammar;
|
---|
509 | }
|
---|
510 |
|
---|
511 | inline void SchemaValidator::setErrorReporter(XMLErrorReporter* const errorReporter) {
|
---|
512 |
|
---|
513 | XMLValidator::setErrorReporter(errorReporter);
|
---|
514 | fSchemaErrorReporter.setErrorReporter(errorReporter);
|
---|
515 | }
|
---|
516 |
|
---|
517 | // ---------------------------------------------------------------------------
|
---|
518 | // SchemaValidator: DTD handler interface
|
---|
519 | // ---------------------------------------------------------------------------
|
---|
520 | inline bool SchemaValidator::handlesDTD() const
|
---|
521 | {
|
---|
522 | // No DTD scanning
|
---|
523 | return false;
|
---|
524 | }
|
---|
525 |
|
---|
526 | // ---------------------------------------------------------------------------
|
---|
527 | // SchemaValidator: Schema handler interface
|
---|
528 | // ---------------------------------------------------------------------------
|
---|
529 | inline bool SchemaValidator::handlesSchema() const
|
---|
530 | {
|
---|
531 | return true;
|
---|
532 | }
|
---|
533 |
|
---|
534 | // ---------------------------------------------------------------------------
|
---|
535 | // SchemaValidator: Particle derivation checking
|
---|
536 | // ---------------------------------------------------------------------------
|
---|
537 | inline bool
|
---|
538 | SchemaValidator::isOccurrenceRangeOK(const int min1, const int max1,
|
---|
539 | const int min2, const int max2) {
|
---|
540 |
|
---|
541 | if (min1 >= min2 &&
|
---|
542 | (max2 == SchemaSymbols::XSD_UNBOUNDED ||
|
---|
543 | (max1 != SchemaSymbols::XSD_UNBOUNDED && max1 <= max2))) {
|
---|
544 | return true;
|
---|
545 | }
|
---|
546 | return false;
|
---|
547 | }
|
---|
548 |
|
---|
549 | inline bool SchemaValidator::getErrorOccurred() const
|
---|
550 | {
|
---|
551 | return fErrorOccurred;
|
---|
552 | }
|
---|
553 |
|
---|
554 | inline bool SchemaValidator::getIsElemSpecified() const
|
---|
555 | {
|
---|
556 | return fElemIsSpecified;
|
---|
557 | }
|
---|
558 |
|
---|
559 | inline const XMLCh* SchemaValidator::getNormalizedValue() const
|
---|
560 | {
|
---|
561 | return fDatatypeBuffer.getRawBuffer();
|
---|
562 | }
|
---|
563 |
|
---|
564 | XERCES_CPP_NAMESPACE_END
|
---|
565 |
|
---|
566 | #endif
|
---|