1 | /*
|
---|
2 | * The Apache Software License, Version 1.1
|
---|
3 | *
|
---|
4 | * Copyright (c) 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) 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: SchemaGrammar.hpp,v $
|
---|
59 | * Revision 1.15 2004/01/29 11:52:31 cargilld
|
---|
60 | * Code cleanup changes to get rid of various compiler diagnostic messages.
|
---|
61 | *
|
---|
62 | * Revision 1.14 2003/12/17 00:18:40 cargilld
|
---|
63 | * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data.
|
---|
64 | *
|
---|
65 | * Revision 1.13 2003/11/14 22:35:09 neilg
|
---|
66 | * changes in support of second phase of XSModel implementation; thanks to David Cargill
|
---|
67 | *
|
---|
68 | * Revision 1.12 2003/11/12 20:35:31 peiyongz
|
---|
69 | * Stateless Grammar: ValidationContext
|
---|
70 | *
|
---|
71 | * Revision 1.11 2003/11/06 19:28:11 knoaman
|
---|
72 | * PSVI support for annotations.
|
---|
73 | *
|
---|
74 | * Revision 1.10 2003/10/14 15:22:28 peiyongz
|
---|
75 | * Implementation of Serialization/Deserialization
|
---|
76 | *
|
---|
77 | * Revision 1.9 2003/09/22 19:49:03 neilg
|
---|
78 | * implement change to Grammar::putElem(XMLElementDecl, bool). If Grammars are used only to hold declared objects, there will be no need for the fElemNonDeclPool tables; make Grammar implementations lazily create them only if the application requires them (which good cpplications should not.)
|
---|
79 | *
|
---|
80 | * Revision 1.8 2003/07/31 17:12:10 peiyongz
|
---|
81 | * Grammar embed grammar description
|
---|
82 | *
|
---|
83 | * Revision 1.7 2003/05/16 21:43:21 knoaman
|
---|
84 | * Memory manager implementation: Modify constructors to pass in the memory manager.
|
---|
85 | *
|
---|
86 | * Revision 1.6 2003/05/15 18:57:27 knoaman
|
---|
87 | * Partial implementation of the configurable memory manager.
|
---|
88 | *
|
---|
89 | * Revision 1.5 2002/11/04 14:49:41 tng
|
---|
90 | * C++ Namespace Support.
|
---|
91 | *
|
---|
92 | * Revision 1.4 2002/08/22 15:42:10 tng
|
---|
93 | * Remove unused parameter variables in inline functions.
|
---|
94 | *
|
---|
95 | * Revision 1.3 2002/07/11 18:21:20 knoaman
|
---|
96 | * Grammar caching/preparsing - initial implementation.
|
---|
97 | *
|
---|
98 | * Revision 1.2 2002/07/05 17:08:10 tng
|
---|
99 | * [Bug 10119] Grammar::getGrammarType need a const modifier
|
---|
100 | *
|
---|
101 | * Revision 1.1.1.1 2002/02/01 22:22:46 peiyongz
|
---|
102 | * sane_include
|
---|
103 | *
|
---|
104 | * Revision 1.14 2001/11/19 18:26:31 knoaman
|
---|
105 | * no message
|
---|
106 | *
|
---|
107 | * Revision 1.13 2001/10/09 12:18:26 tng
|
---|
108 | * Leak fix: should use delete [] to delete fTargetNamespace.
|
---|
109 | *
|
---|
110 | * Revision 1.12 2001/10/04 15:11:51 knoaman
|
---|
111 | * Add support for circular import.
|
---|
112 | *
|
---|
113 | * Revision 1.10 2001/09/14 14:50:22 tng
|
---|
114 | * Schema: Fix some wildcard bugs, and some retrieving qualified/unqualified element decl problems.
|
---|
115 | *
|
---|
116 | * Revision 1.9 2001/08/21 16:06:11 tng
|
---|
117 | * Schema: Unique Particle Attribution Constraint Checking.
|
---|
118 | *
|
---|
119 | * Revision 1.8 2001/07/31 15:27:10 knoaman
|
---|
120 | * Added support for <attributeGroup>.
|
---|
121 | *
|
---|
122 | * Revision 1.7 2001/07/24 18:33:46 knoaman
|
---|
123 | * Added support for <group> + extra constraint checking for complexType
|
---|
124 | *
|
---|
125 | * Revision 1.6 2001/06/25 12:51:57 knoaman
|
---|
126 | * Add constraint checking on elements in complex types to prevent same
|
---|
127 | * element names from having different definitions - use substitueGroups.
|
---|
128 | *
|
---|
129 | * Revision 1.5 2001/05/28 20:56:19 tng
|
---|
130 | * Schema: Move getTargetNamespace as virtual function in base class Grammar
|
---|
131 | *
|
---|
132 | * Revision 1.4 2001/05/11 13:27:36 tng
|
---|
133 | * Copyright update.
|
---|
134 | *
|
---|
135 | * Revision 1.3 2001/05/03 20:34:43 tng
|
---|
136 | * Schema: SchemaValidator update
|
---|
137 | *
|
---|
138 | * Revision 1.2 2001/04/19 17:43:19 knoaman
|
---|
139 | * More schema implementation classes.
|
---|
140 | *
|
---|
141 | * Revision 1.1 2001/03/21 21:56:33 tng
|
---|
142 | * Schema: Add Schema Grammar, Schema Validator, and split the DTDValidator into DTDValidator, DTDScanner, and DTDGrammar.
|
---|
143 | *
|
---|
144 | */
|
---|
145 |
|
---|
146 |
|
---|
147 |
|
---|
148 | #if !defined(SCHEMAGRAMMAR_HPP)
|
---|
149 | #define SCHEMAGRAMMAR_HPP
|
---|
150 |
|
---|
151 | #include <xercesc/framework/XMLNotationDecl.hpp>
|
---|
152 | #include <xercesc/util/RefHash3KeysIdPool.hpp>
|
---|
153 | #include <xercesc/util/NameIdPool.hpp>
|
---|
154 | #include <xercesc/util/StringPool.hpp>
|
---|
155 | #include <xercesc/validators/common/Grammar.hpp>
|
---|
156 | #include <xercesc/validators/schema/SchemaElementDecl.hpp>
|
---|
157 | #include <xercesc/util/ValueVectorOf.hpp>
|
---|
158 | #include <xercesc/validators/datatype/IDDatatypeValidator.hpp>
|
---|
159 | #include <xercesc/validators/datatype/DatatypeValidatorFactory.hpp>
|
---|
160 | #include <xercesc/framework/XMLSchemaDescription.hpp>
|
---|
161 | #include <xercesc/framework/ValidationContext.hpp>
|
---|
162 |
|
---|
163 | XERCES_CPP_NAMESPACE_BEGIN
|
---|
164 |
|
---|
165 | //
|
---|
166 | // This class stores the Schema information
|
---|
167 | // NOTE: Schemas are not namespace aware, so we just use regular NameIdPool
|
---|
168 | // data structures to store element and attribute decls. They are all set
|
---|
169 | // to be in the global namespace and the full QName is used as the base name
|
---|
170 | // of the decl. This means that all the URI parameters below are expected
|
---|
171 | // to be null pointers (and anything else will cause an exception.)
|
---|
172 | //
|
---|
173 |
|
---|
174 | // ---------------------------------------------------------------------------
|
---|
175 | // Forward Declarations
|
---|
176 | // ---------------------------------------------------------------------------
|
---|
177 | class ComplexTypeInfo;
|
---|
178 | class NamespaceScope;
|
---|
179 | class XercesGroupInfo;
|
---|
180 | class XercesAttGroupInfo;
|
---|
181 | class XSAnnotation;
|
---|
182 |
|
---|
183 | // ---------------------------------------------------------------------------
|
---|
184 | // typedef declaration
|
---|
185 | // ---------------------------------------------------------------------------
|
---|
186 | typedef ValueVectorOf<SchemaElementDecl*> ElemVector;
|
---|
187 |
|
---|
188 |
|
---|
189 | class VALIDATORS_EXPORT SchemaGrammar : public Grammar
|
---|
190 | {
|
---|
191 | public:
|
---|
192 | // -----------------------------------------------------------------------
|
---|
193 | // Constructors and Destructor
|
---|
194 | // -----------------------------------------------------------------------
|
---|
195 | SchemaGrammar(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
|
---|
196 | virtual ~SchemaGrammar();
|
---|
197 |
|
---|
198 | // -----------------------------------------------------------------------
|
---|
199 | // Implementation of Virtual Interface
|
---|
200 | // -----------------------------------------------------------------------
|
---|
201 | virtual Grammar::GrammarType getGrammarType() const;
|
---|
202 | virtual const XMLCh* getTargetNamespace() const;
|
---|
203 |
|
---|
204 | // this method should only be used while the grammar is being
|
---|
205 | // constructed, not while it is being used
|
---|
206 | // in a validation episode!
|
---|
207 | virtual XMLElementDecl* findOrAddElemDecl
|
---|
208 | (
|
---|
209 | const unsigned int uriId
|
---|
210 | , const XMLCh* const baseName
|
---|
211 | , const XMLCh* const prefixName
|
---|
212 | , const XMLCh* const qName
|
---|
213 | , unsigned int scope
|
---|
214 | , bool& wasAdded
|
---|
215 | ) ;
|
---|
216 |
|
---|
217 | virtual unsigned int getElemId
|
---|
218 | (
|
---|
219 | const unsigned int uriId
|
---|
220 | , const XMLCh* const baseName
|
---|
221 | , const XMLCh* const qName
|
---|
222 | , unsigned int scope
|
---|
223 | ) const ;
|
---|
224 |
|
---|
225 | virtual const XMLElementDecl* getElemDecl
|
---|
226 | (
|
---|
227 | const unsigned int uriId
|
---|
228 | , const XMLCh* const baseName
|
---|
229 | , const XMLCh* const qName
|
---|
230 | , unsigned int scope
|
---|
231 | ) const ;
|
---|
232 |
|
---|
233 | virtual XMLElementDecl* getElemDecl
|
---|
234 | (
|
---|
235 | const unsigned int uriId
|
---|
236 | , const XMLCh* const baseName
|
---|
237 | , const XMLCh* const qName
|
---|
238 | , unsigned int scope
|
---|
239 | );
|
---|
240 |
|
---|
241 | virtual const XMLElementDecl* getElemDecl
|
---|
242 | (
|
---|
243 | const unsigned int elemId
|
---|
244 | ) const;
|
---|
245 |
|
---|
246 | virtual XMLElementDecl* getElemDecl
|
---|
247 | (
|
---|
248 | const unsigned int elemId
|
---|
249 | );
|
---|
250 |
|
---|
251 | virtual const XMLNotationDecl* getNotationDecl
|
---|
252 | (
|
---|
253 | const XMLCh* const notName
|
---|
254 | ) const;
|
---|
255 |
|
---|
256 | virtual XMLNotationDecl* getNotationDecl
|
---|
257 | (
|
---|
258 | const XMLCh* const notName
|
---|
259 | );
|
---|
260 |
|
---|
261 | virtual bool getValidated() const;
|
---|
262 |
|
---|
263 | virtual XMLElementDecl* putElemDecl
|
---|
264 | (
|
---|
265 | const unsigned int uriId
|
---|
266 | , const XMLCh* const baseName
|
---|
267 | , const XMLCh* const prefixName
|
---|
268 | , const XMLCh* const qName
|
---|
269 | , unsigned int scope
|
---|
270 | , const bool notDeclared = false
|
---|
271 | );
|
---|
272 |
|
---|
273 | virtual unsigned int putElemDecl
|
---|
274 | (
|
---|
275 | XMLElementDecl* const elemDecl
|
---|
276 | , const bool notDeclared = false
|
---|
277 | ) ;
|
---|
278 |
|
---|
279 | virtual unsigned int putNotationDecl
|
---|
280 | (
|
---|
281 | XMLNotationDecl* const notationDecl
|
---|
282 | ) const;
|
---|
283 |
|
---|
284 | virtual void setValidated(const bool newState);
|
---|
285 |
|
---|
286 | virtual void reset();
|
---|
287 |
|
---|
288 | // -----------------------------------------------------------------------
|
---|
289 | // Getter methods
|
---|
290 | // -----------------------------------------------------------------------
|
---|
291 | RefHash3KeysIdPoolEnumerator<SchemaElementDecl> getElemEnumerator() const;
|
---|
292 | NameIdPoolEnumerator<XMLNotationDecl> getNotationEnumerator() const;
|
---|
293 | RefHashTableOf<XMLAttDef>* getAttributeDeclRegistry() const;
|
---|
294 | RefHashTableOf<ComplexTypeInfo>* getComplexTypeRegistry() const;
|
---|
295 | RefHashTableOf<XercesGroupInfo>* getGroupInfoRegistry() const;
|
---|
296 | RefHashTableOf<XercesAttGroupInfo>* getAttGroupInfoRegistry() const;
|
---|
297 | DatatypeValidatorFactory* getDatatypeRegistry();
|
---|
298 | NamespaceScope* getNamespaceScope() const;
|
---|
299 | RefHash2KeysTableOf<ElemVector>* getValidSubstitutionGroups() const;
|
---|
300 |
|
---|
301 | //deprecated
|
---|
302 | RefHashTableOf<XMLRefInfo>* getIDRefList() const;
|
---|
303 |
|
---|
304 | ValidationContext* getValidationContext() const;
|
---|
305 |
|
---|
306 | // -----------------------------------------------------------------------
|
---|
307 | // Setter methods
|
---|
308 | // -----------------------------------------------------------------------
|
---|
309 | void setTargetNamespace(const XMLCh* const targetNamespace);
|
---|
310 | void setAttributeDeclRegistry(RefHashTableOf<XMLAttDef>* const attReg);
|
---|
311 | void setComplexTypeRegistry(RefHashTableOf<ComplexTypeInfo>* const other);
|
---|
312 | void setGroupInfoRegistry(RefHashTableOf<XercesGroupInfo>* const other);
|
---|
313 | void setAttGroupInfoRegistry(RefHashTableOf<XercesAttGroupInfo>* const other);
|
---|
314 | void setNamespaceScope(NamespaceScope* const nsScope);
|
---|
315 | void setValidSubstitutionGroups(RefHash2KeysTableOf<ElemVector>* const);
|
---|
316 |
|
---|
317 | virtual void setGrammarDescription( XMLGrammarDescription*);
|
---|
318 | virtual XMLGrammarDescription* getGrammarDescription() const;
|
---|
319 |
|
---|
320 | // -----------------------------------------------------------------------
|
---|
321 | // Helper methods
|
---|
322 | // -----------------------------------------------------------------------
|
---|
323 | unsigned int putGroupElemDecl
|
---|
324 | (
|
---|
325 | XMLElementDecl* const elemDecl
|
---|
326 | ) const;
|
---|
327 |
|
---|
328 | // -----------------------------------------------------------------------
|
---|
329 | // Annotation management methods
|
---|
330 | // -----------------------------------------------------------------------
|
---|
331 | /**
|
---|
332 | * Add annotation to the list of annotations for a given key
|
---|
333 | */
|
---|
334 | void putAnnotation(void* key, XSAnnotation* const annotation);
|
---|
335 |
|
---|
336 | /**
|
---|
337 | * Add global annotation
|
---|
338 | *
|
---|
339 | * Note: XSAnnotation acts as a linked list
|
---|
340 | */
|
---|
341 | void addAnnotation(XSAnnotation* const annotation);
|
---|
342 |
|
---|
343 | /**
|
---|
344 | * Retrieve the annotation that is associated with the specified key
|
---|
345 | *
|
---|
346 | * @param key represents a schema component object (i.e. SchemaGrammar)
|
---|
347 | * @return XSAnnotation associated with the key object
|
---|
348 | */
|
---|
349 | XSAnnotation* getAnnotation(const void* const key);
|
---|
350 |
|
---|
351 | /**
|
---|
352 | * Retrieve the annotation that is associated with the specified key
|
---|
353 | *
|
---|
354 | * @param key represents a schema component object (i.e. SchemaGrammar)
|
---|
355 | * @return XSAnnotation associated with the key object
|
---|
356 | */
|
---|
357 | const XSAnnotation* getAnnotation(const void* const key) const;
|
---|
358 |
|
---|
359 | /**
|
---|
360 | * Get global annotation
|
---|
361 | */
|
---|
362 | XSAnnotation* getAnnotation();
|
---|
363 | const XSAnnotation* getAnnotation() const;
|
---|
364 |
|
---|
365 | /***
|
---|
366 | * Support for Serialization/De-serialization
|
---|
367 | ***/
|
---|
368 | DECL_XSERIALIZABLE(SchemaGrammar)
|
---|
369 |
|
---|
370 | private:
|
---|
371 | // -----------------------------------------------------------------------
|
---|
372 | // Unimplemented constructors and operators
|
---|
373 | // -----------------------------------------------------------------------
|
---|
374 | SchemaGrammar(const SchemaGrammar&);
|
---|
375 | SchemaGrammar& operator=(const SchemaGrammar&);
|
---|
376 |
|
---|
377 | // -----------------------------------------------------------------------
|
---|
378 | // Helper methods
|
---|
379 | // -----------------------------------------------------------------------
|
---|
380 | void cleanUp();
|
---|
381 |
|
---|
382 | // -----------------------------------------------------------------------
|
---|
383 | // Private data members
|
---|
384 | //
|
---|
385 | // fElemDeclPool
|
---|
386 | // This is the element decl pool. It contains all of the elements
|
---|
387 | // declared in the Schema (and their associated attributes.)
|
---|
388 | //
|
---|
389 | // fElemNonDeclPool
|
---|
390 | // This is the element decl pool that is is populated as new elements
|
---|
391 | // are seen in the XML document (not declared in the Schema), and they
|
---|
392 | // are given default characteristics.
|
---|
393 | //
|
---|
394 | // fGroupElemDeclPool
|
---|
395 | // This is the element decl pool for elements in a group that are
|
---|
396 | // referenced in different scope. It contains all of the elements
|
---|
397 | // declared in the Schema (and their associated attributes.)
|
---|
398 | //
|
---|
399 | // fNotationDeclPool
|
---|
400 | // This is a pool of NotationDecl objects, which contains all of the
|
---|
401 | // notations declared in the Schema.
|
---|
402 | //
|
---|
403 | // fTargetNamespace
|
---|
404 | // Target name space for this grammar.
|
---|
405 | //
|
---|
406 | // fAttributeDeclRegistry
|
---|
407 | // Global attribute declarations
|
---|
408 | //
|
---|
409 | // fComplexTypeRegistry
|
---|
410 | // Stores complexType declaration info
|
---|
411 | //
|
---|
412 | // fGroupInfoRegistry
|
---|
413 | // Stores global <group> declaration info
|
---|
414 | //
|
---|
415 | // fAttGroupInfoRegistry
|
---|
416 | // Stores global <attributeGroup> declaration info
|
---|
417 | //
|
---|
418 | // fDatatypeRegistry
|
---|
419 | // Datatype validator factory
|
---|
420 | //
|
---|
421 | // fNamespaceScope
|
---|
422 | // Prefix to Namespace map
|
---|
423 | //
|
---|
424 | // fValidSubstitutionGroups
|
---|
425 | // Valid list of elements that can substitute a given element
|
---|
426 | //
|
---|
427 | // fIDRefList
|
---|
428 | // List of ids of schema declarations extracted during schema grammar
|
---|
429 | // traversal
|
---|
430 | //
|
---|
431 | // fValidated
|
---|
432 | // Indicates if the content of the Grammar has been pre-validated
|
---|
433 | // or not (UPA checking, etc.). When using a cached grammar, no need
|
---|
434 | // for pre content validation.
|
---|
435 | //
|
---|
436 | // fGramDesc: adopted
|
---|
437 | //
|
---|
438 | // -----------------------------------------------------------------------
|
---|
439 | XMLCh* fTargetNamespace;
|
---|
440 | RefHash3KeysIdPool<SchemaElementDecl>* fElemDeclPool;
|
---|
441 | RefHash3KeysIdPool<SchemaElementDecl>* fElemNonDeclPool;
|
---|
442 | RefHash3KeysIdPool<SchemaElementDecl>* fGroupElemDeclPool;
|
---|
443 | NameIdPool<XMLNotationDecl>* fNotationDeclPool;
|
---|
444 | RefHashTableOf<XMLAttDef>* fAttributeDeclRegistry;
|
---|
445 | RefHashTableOf<ComplexTypeInfo>* fComplexTypeRegistry;
|
---|
446 | RefHashTableOf<XercesGroupInfo>* fGroupInfoRegistry;
|
---|
447 | RefHashTableOf<XercesAttGroupInfo>* fAttGroupInfoRegistry;
|
---|
448 | NamespaceScope* fNamespaceScope;
|
---|
449 | RefHash2KeysTableOf<ElemVector>* fValidSubstitutionGroups;
|
---|
450 | ValidationContext* fValidationContext;
|
---|
451 | MemoryManager* fMemoryManager;
|
---|
452 | bool fValidated;
|
---|
453 | DatatypeValidatorFactory fDatatypeRegistry;
|
---|
454 | XMLSchemaDescription* fGramDesc;
|
---|
455 | RefHashTableOf<XSAnnotation>* fAnnotations;
|
---|
456 | };
|
---|
457 |
|
---|
458 |
|
---|
459 | // ---------------------------------------------------------------------------
|
---|
460 | // SchemaGrammar: Getter methods
|
---|
461 | // ---------------------------------------------------------------------------
|
---|
462 | inline RefHash3KeysIdPoolEnumerator<SchemaElementDecl>
|
---|
463 | SchemaGrammar::getElemEnumerator() const
|
---|
464 | {
|
---|
465 | return RefHash3KeysIdPoolEnumerator<SchemaElementDecl>(fElemDeclPool, false, fMemoryManager);
|
---|
466 | }
|
---|
467 |
|
---|
468 | inline NameIdPoolEnumerator<XMLNotationDecl>
|
---|
469 | SchemaGrammar::getNotationEnumerator() const
|
---|
470 | {
|
---|
471 | return NameIdPoolEnumerator<XMLNotationDecl>(fNotationDeclPool, fMemoryManager);
|
---|
472 | }
|
---|
473 |
|
---|
474 | inline RefHashTableOf<XMLAttDef>* SchemaGrammar::getAttributeDeclRegistry() const {
|
---|
475 |
|
---|
476 | return fAttributeDeclRegistry;
|
---|
477 | }
|
---|
478 |
|
---|
479 | inline RefHashTableOf<ComplexTypeInfo>*
|
---|
480 | SchemaGrammar::getComplexTypeRegistry() const {
|
---|
481 |
|
---|
482 | return fComplexTypeRegistry;
|
---|
483 | }
|
---|
484 |
|
---|
485 | inline RefHashTableOf<XercesGroupInfo>*
|
---|
486 | SchemaGrammar::getGroupInfoRegistry() const {
|
---|
487 |
|
---|
488 | return fGroupInfoRegistry;
|
---|
489 | }
|
---|
490 |
|
---|
491 | inline RefHashTableOf<XercesAttGroupInfo>*
|
---|
492 | SchemaGrammar::getAttGroupInfoRegistry() const {
|
---|
493 |
|
---|
494 | return fAttGroupInfoRegistry;
|
---|
495 | }
|
---|
496 |
|
---|
497 | inline DatatypeValidatorFactory* SchemaGrammar::getDatatypeRegistry() {
|
---|
498 |
|
---|
499 | return &fDatatypeRegistry;
|
---|
500 | }
|
---|
501 |
|
---|
502 | inline NamespaceScope* SchemaGrammar::getNamespaceScope() const {
|
---|
503 |
|
---|
504 | return fNamespaceScope;
|
---|
505 | }
|
---|
506 |
|
---|
507 | inline RefHash2KeysTableOf<ElemVector>*
|
---|
508 | SchemaGrammar::getValidSubstitutionGroups() const {
|
---|
509 |
|
---|
510 | return fValidSubstitutionGroups;
|
---|
511 | }
|
---|
512 |
|
---|
513 | inline RefHashTableOf<XMLRefInfo>* SchemaGrammar::getIDRefList() const {
|
---|
514 |
|
---|
515 | return fValidationContext->getIdRefList();
|
---|
516 | }
|
---|
517 |
|
---|
518 | inline ValidationContext* SchemaGrammar::getValidationContext() const {
|
---|
519 |
|
---|
520 | return fValidationContext;
|
---|
521 | }
|
---|
522 |
|
---|
523 | inline XMLGrammarDescription* SchemaGrammar::getGrammarDescription() const
|
---|
524 | {
|
---|
525 | return fGramDesc;
|
---|
526 | }
|
---|
527 |
|
---|
528 | inline XSAnnotation* SchemaGrammar::getAnnotation(const void* const key)
|
---|
529 | {
|
---|
530 | return fAnnotations->get(key);
|
---|
531 | }
|
---|
532 |
|
---|
533 | inline const XSAnnotation* SchemaGrammar::getAnnotation(const void* const key) const
|
---|
534 | {
|
---|
535 | return fAnnotations->get(key);
|
---|
536 | }
|
---|
537 |
|
---|
538 | inline XSAnnotation* SchemaGrammar::getAnnotation()
|
---|
539 | {
|
---|
540 | return fAnnotations->get(this);
|
---|
541 | }
|
---|
542 |
|
---|
543 | inline const XSAnnotation* SchemaGrammar::getAnnotation() const
|
---|
544 | {
|
---|
545 | return fAnnotations->get(this);
|
---|
546 | }
|
---|
547 |
|
---|
548 | // -----------------------------------------------------------------------
|
---|
549 | // Setter methods
|
---|
550 | // -----------------------------------------------------------------------
|
---|
551 | inline void SchemaGrammar::setTargetNamespace(const XMLCh* const targetNamespace)
|
---|
552 | {
|
---|
553 | if (fTargetNamespace)
|
---|
554 | fMemoryManager->deallocate(fTargetNamespace);//delete [] fTargetNamespace;
|
---|
555 | fTargetNamespace = XMLString::replicate(targetNamespace, fMemoryManager);
|
---|
556 | }
|
---|
557 |
|
---|
558 | inline void
|
---|
559 | SchemaGrammar::setAttributeDeclRegistry(RefHashTableOf<XMLAttDef>* const attReg) {
|
---|
560 |
|
---|
561 | fAttributeDeclRegistry = attReg;
|
---|
562 | }
|
---|
563 |
|
---|
564 | inline void
|
---|
565 | SchemaGrammar::setComplexTypeRegistry(RefHashTableOf<ComplexTypeInfo>* const other) {
|
---|
566 |
|
---|
567 | fComplexTypeRegistry = other;
|
---|
568 | }
|
---|
569 |
|
---|
570 | inline void
|
---|
571 | SchemaGrammar::setGroupInfoRegistry(RefHashTableOf<XercesGroupInfo>* const other) {
|
---|
572 |
|
---|
573 | fGroupInfoRegistry = other;
|
---|
574 | }
|
---|
575 |
|
---|
576 | inline void
|
---|
577 | SchemaGrammar::setAttGroupInfoRegistry(RefHashTableOf<XercesAttGroupInfo>* const other) {
|
---|
578 |
|
---|
579 | fAttGroupInfoRegistry = other;
|
---|
580 | }
|
---|
581 |
|
---|
582 | inline void SchemaGrammar::setNamespaceScope(NamespaceScope* const nsScope) {
|
---|
583 |
|
---|
584 | fNamespaceScope = nsScope;
|
---|
585 | }
|
---|
586 |
|
---|
587 | inline void
|
---|
588 | SchemaGrammar::setValidSubstitutionGroups(RefHash2KeysTableOf<ElemVector>* const other) {
|
---|
589 |
|
---|
590 | fValidSubstitutionGroups = other;
|
---|
591 | }
|
---|
592 |
|
---|
593 |
|
---|
594 | // ---------------------------------------------------------------------------
|
---|
595 | // SchemaGrammar: Virtual methods
|
---|
596 | // ---------------------------------------------------------------------------
|
---|
597 | inline Grammar::GrammarType SchemaGrammar::getGrammarType() const {
|
---|
598 | return Grammar::SchemaGrammarType;
|
---|
599 | }
|
---|
600 |
|
---|
601 | inline const XMLCh* SchemaGrammar::getTargetNamespace() const {
|
---|
602 | return fTargetNamespace;
|
---|
603 | }
|
---|
604 |
|
---|
605 | // Element Decl
|
---|
606 | inline unsigned int SchemaGrammar::getElemId (const unsigned int uriId
|
---|
607 | , const XMLCh* const baseName
|
---|
608 | , const XMLCh* const
|
---|
609 | , unsigned int scope ) const
|
---|
610 | {
|
---|
611 | //
|
---|
612 | // In this case, we don't return zero to mean 'not found', so we have to
|
---|
613 | // map it to the official not found value if we don't find it.
|
---|
614 | //
|
---|
615 | const SchemaElementDecl* decl = fElemDeclPool->getByKey(baseName, uriId, scope);
|
---|
616 | if (!decl) {
|
---|
617 |
|
---|
618 | decl = fGroupElemDeclPool->getByKey(baseName, uriId, scope);
|
---|
619 |
|
---|
620 | if (!decl)
|
---|
621 | return XMLElementDecl::fgInvalidElemId;
|
---|
622 | }
|
---|
623 | return decl->getId();
|
---|
624 | }
|
---|
625 |
|
---|
626 | inline const XMLElementDecl* SchemaGrammar::getElemDecl( const unsigned int uriId
|
---|
627 | , const XMLCh* const baseName
|
---|
628 | , const XMLCh* const
|
---|
629 | , unsigned int scope ) const
|
---|
630 | {
|
---|
631 | const SchemaElementDecl* decl = fElemDeclPool->getByKey(baseName, uriId, scope);
|
---|
632 |
|
---|
633 | if (!decl) {
|
---|
634 |
|
---|
635 | decl = fGroupElemDeclPool->getByKey(baseName, uriId, scope);
|
---|
636 |
|
---|
637 | if (!decl && fElemNonDeclPool)
|
---|
638 | decl = fElemNonDeclPool->getByKey(baseName, uriId, scope);
|
---|
639 | }
|
---|
640 |
|
---|
641 | return decl;
|
---|
642 | }
|
---|
643 |
|
---|
644 | inline XMLElementDecl* SchemaGrammar::getElemDecl (const unsigned int uriId
|
---|
645 | , const XMLCh* const baseName
|
---|
646 | , const XMLCh* const
|
---|
647 | , unsigned int scope )
|
---|
648 | {
|
---|
649 | SchemaElementDecl* decl = fElemDeclPool->getByKey(baseName, uriId, scope);
|
---|
650 |
|
---|
651 | if (!decl) {
|
---|
652 |
|
---|
653 | decl = fGroupElemDeclPool->getByKey(baseName, uriId, scope);
|
---|
654 |
|
---|
655 | if (!decl && fElemNonDeclPool)
|
---|
656 | decl = fElemNonDeclPool->getByKey(baseName, uriId, scope);
|
---|
657 | }
|
---|
658 |
|
---|
659 | return decl;
|
---|
660 | }
|
---|
661 |
|
---|
662 | inline const XMLElementDecl* SchemaGrammar::getElemDecl(const unsigned int elemId) const
|
---|
663 | {
|
---|
664 | // Look up this element decl by id
|
---|
665 | const SchemaElementDecl* decl = fElemDeclPool->getById(elemId);
|
---|
666 |
|
---|
667 | if (!decl)
|
---|
668 | decl = fGroupElemDeclPool->getById(elemId);
|
---|
669 |
|
---|
670 | return decl;
|
---|
671 | }
|
---|
672 |
|
---|
673 | inline XMLElementDecl* SchemaGrammar::getElemDecl(const unsigned int elemId)
|
---|
674 | {
|
---|
675 | // Look up this element decl by id
|
---|
676 | SchemaElementDecl* decl = fElemDeclPool->getById(elemId);
|
---|
677 |
|
---|
678 | if (!decl)
|
---|
679 | decl = fGroupElemDeclPool->getById(elemId);
|
---|
680 |
|
---|
681 | return decl;
|
---|
682 | }
|
---|
683 |
|
---|
684 | inline unsigned int
|
---|
685 | SchemaGrammar::putElemDecl(XMLElementDecl* const elemDecl,
|
---|
686 | const bool notDeclared)
|
---|
687 | {
|
---|
688 | if (notDeclared)
|
---|
689 | {
|
---|
690 | if(!fElemNonDeclPool)
|
---|
691 | fElemNonDeclPool = new (fMemoryManager) RefHash3KeysIdPool<SchemaElementDecl>(29, true, 128, fMemoryManager);
|
---|
692 | return fElemNonDeclPool->put(elemDecl->getBaseName(), elemDecl->getURI(), ((SchemaElementDecl* )elemDecl)->getEnclosingScope(), (SchemaElementDecl*) elemDecl);
|
---|
693 | }
|
---|
694 |
|
---|
695 | return fElemDeclPool->put(elemDecl->getBaseName(), elemDecl->getURI(), ((SchemaElementDecl* )elemDecl)->getEnclosingScope(), (SchemaElementDecl*) elemDecl);
|
---|
696 | }
|
---|
697 |
|
---|
698 | inline unsigned int SchemaGrammar::putGroupElemDecl (XMLElementDecl* const elemDecl) const
|
---|
699 | {
|
---|
700 | return fGroupElemDeclPool->put(elemDecl->getBaseName(), elemDecl->getURI(), ((SchemaElementDecl* )elemDecl)->getEnclosingScope(), (SchemaElementDecl*) elemDecl);
|
---|
701 | }
|
---|
702 |
|
---|
703 | // Notation Decl
|
---|
704 | inline const XMLNotationDecl* SchemaGrammar::getNotationDecl(const XMLCh* const notName) const
|
---|
705 | {
|
---|
706 | return fNotationDeclPool->getByKey(notName);
|
---|
707 | }
|
---|
708 |
|
---|
709 | inline XMLNotationDecl* SchemaGrammar::getNotationDecl(const XMLCh* const notName)
|
---|
710 | {
|
---|
711 | return fNotationDeclPool->getByKey(notName);
|
---|
712 | }
|
---|
713 |
|
---|
714 | inline unsigned int SchemaGrammar::putNotationDecl(XMLNotationDecl* const notationDecl) const
|
---|
715 | {
|
---|
716 | return fNotationDeclPool->put(notationDecl);
|
---|
717 | }
|
---|
718 |
|
---|
719 | inline bool SchemaGrammar::getValidated() const
|
---|
720 | {
|
---|
721 | return fValidated;
|
---|
722 | }
|
---|
723 |
|
---|
724 | inline void SchemaGrammar::setValidated(const bool newState)
|
---|
725 | {
|
---|
726 | fValidated = newState;
|
---|
727 | }
|
---|
728 |
|
---|
729 | XERCES_CPP_NAMESPACE_END
|
---|
730 |
|
---|
731 | #endif
|
---|