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