source: NonGTP/Xerces/xerces/include/xercesc/validators/schema/SchemaElementDecl.hpp @ 358

Revision 358, 34.5 KB checked in by bittner, 19 years ago (diff)

xerces added

Line 
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: SchemaElementDecl.hpp,v $
19 * Revision 1.22  2004/09/08 13:56:56  peiyongz
20 * Apache License Version 2.0
21 *
22 * Revision 1.21  2004/02/05 18:08:38  cargilld
23 * Code cleanup changes to get rid of various compiler diagnostic messages.
24 *
25 * Revision 1.20  2004/01/29 11:52:31  cargilld
26 * Code cleanup changes to get rid of various compiler diagnostic messages.
27 *
28 * Revision 1.19  2003/12/24 17:42:03  knoaman
29 * Misc. PSVI updates
30 *
31 * Revision 1.18  2003/12/12 18:36:37  peiyongz
32 * getObjectType()
33 *
34 * Revision 1.17  2003/11/24 05:21:04  neilg
35 * update method documentation
36 *
37 * Revision 1.16  2003/11/21 22:34:46  neilg
38 * More schema component model implementation, thanks to David Cargill.
39 * In particular, this cleans up and completes the XSModel, XSNamespaceItem,
40 * XSAttributeDeclaration and XSAttributeGroup implementations.
41 *
42 * Revision 1.15  2003/11/06 15:30:08  neilg
43 * first part of PSVI/schema component model implementation, thanks to David Cargill.  This covers setting the PSVIHandler on parser objects, as well as implementing XSNotation, XSSimpleTypeDefinition, XSIDCDefinition, and most of XSWildcard, XSComplexTypeDefinition, XSElementDeclaration, XSAttributeDeclaration and XSAttributeUse.
44 *
45 * Revision 1.14  2003/10/14 15:22:28  peiyongz
46 * Implementation of Serialization/Deserialization
47 *
48 * Revision 1.13  2003/10/05 02:08:05  neilg
49 * Because it makes grammars un-sharable between parsers running on multiple threads, xsi:type should not be handled by modifying element declarations.  Modifying implementation so it no longer relies on this kind of behaviour; marking methods as deprecated which imply that xsi:type will be handled in this way.  Once their behaviour is handled elsewhere, these methods should eventually be removed
50 *
51 * Revision 1.12  2003/08/29 11:44:18  gareth
52 * If a type was explicitly declared as anyType that now gets set in DOMTypeInfo. Added test cases.
53 *
54 * Revision 1.11  2003/05/18 14:02:08  knoaman
55 * Memory manager implementation: pass per instance manager.
56 *
57 * Revision 1.10  2003/05/16 21:43:21  knoaman
58 * Memory manager implementation: Modify constructors to pass in the memory manager.
59 *
60 * Revision 1.9  2003/05/15 18:57:27  knoaman
61 * Partial implementation of the configurable memory manager.
62 *
63 * Revision 1.8  2003/01/29 19:47:16  gareth
64 * added DOMTypeInfo and some PSVI methods
65 *
66 * Revision 1.7  2002/11/04 14:49:41  tng
67 * C++ Namespace Support.
68 *
69 * Revision 1.6  2002/07/12 15:17:48  knoaman
70 * For a given global element, store info about a substitution group element
71 * as a SchemaElementDecl and not as a string.
72 *
73 * Revision 1.5  2002/04/01 15:47:06  knoaman
74 * Move Element Consistency checking (ref to global declarations) to SchemaValidator.
75 *
76 * Revision 1.4  2002/03/21 16:31:43  knoaman
77 * Remove data/methods from SchemaElementDecl that are not used.
78 *
79 * Revision 1.3  2002/03/04 15:09:50  knoaman
80 * Fix for bug 6834.
81 *
82 * Revision 1.2  2002/02/06 22:30:50  knoaman
83 * Added a new attribute to store the wild card information for elements of type 'anyType'.
84 *
85 * Revision 1.1.1.1  2002/02/01 22:22:46  peiyongz
86 * sane_include
87 *
88 * Revision 1.16  2001/11/23 18:25:45  tng
89 * Eliminate Warning from AIX xlC 3.6: 1540-399: (W) "IdentityConstraint" is undefined.  The delete operator will not call a destructor.
90 *
91 * Revision 1.15  2001/11/02 14:13:45  knoaman
92 * Add support for identity constraints.
93 *
94 * Revision 1.14  2001/10/11 12:07:39  tng
95 * Schema: model type should be based on complextypeinfo if exists.
96 *
97 * Revision 1.13  2001/09/05 20:49:11  knoaman
98 * Fix for complexTypes with mixed content model.
99 *
100 * Revision 1.12  2001/08/29 20:52:35  tng
101 * Schema: xsi:type support
102 *
103 * Revision 1.11  2001/08/21 16:06:11  tng
104 * Schema: Unique Particle Attribution Constraint Checking.
105 *
106 * Revision 1.10  2001/08/09 15:23:16  knoaman
107 * add support for <anyAttribute> declaration.
108 *
109 * Revision 1.9  2001/07/24 18:33:46  knoaman
110 * Added support for <group> + extra constraint checking for complexType
111 *
112 * Revision 1.8  2001/06/13 20:51:15  peiyongz
113 * fIsMixed: to handle mixed Content Model
114 *
115 * Revision 1.7  2001/05/11 13:27:36  tng
116 * Copyright update.
117 *
118 * Revision 1.6  2001/05/03 20:34:43  tng
119 * Schema: SchemaValidator update
120 *
121 * Revision 1.5  2001/05/03 19:18:01  knoaman
122 * TraverseSchema Part II.
123 *
124 * Revision 1.4  2001/04/19 17:43:17  knoaman
125 * More schema implementation classes.
126 *
127 * Revision 1.3  2001/03/21 21:56:33  tng
128 * Schema: Add Schema Grammar, Schema Validator, and split the DTDValidator into DTDValidator, DTDScanner, and DTDGrammar.
129 *
130 * Revision 1.2  2001/03/21 19:30:17  tng
131 * Schema: Content Model Updates, by Pei Yong Zhang.
132 *
133 * Revision 1.1  2001/02/27 18:48:23  tng
134 * Schema: Add SchemaAttDef, SchemaElementDecl, SchemaAttDefList.
135 *
136 */
137
138
139#if !defined(SCHEMAELEMENTDECL_HPP)
140#define SCHEMAELEMENTDECL_HPP
141
142#include <xercesc/util/QName.hpp>
143#include <xercesc/validators/common/Grammar.hpp>
144#include <xercesc/validators/schema/ComplexTypeInfo.hpp>
145#include <xercesc/validators/schema/identity/IdentityConstraint.hpp>
146#include <xercesc/validators/datatype/DatatypeValidator.hpp>
147#include <xercesc/validators/datatype/UnionDatatypeValidator.hpp>
148#include <xercesc/validators/schema/PSVIDefs.hpp>
149
150XERCES_CPP_NAMESPACE_BEGIN
151
152class ContentSpecNode;
153class SchemaAttDefList;
154
155//
156//  This class is a derivative of the basic element decl. This one implements
157//  the virtuals so that they work for a Schema.
158//
159class VALIDATORS_EXPORT SchemaElementDecl : public XMLElementDecl
160{
161public :
162
163    // -----------------------------------------------------------------------
164    //  Class specific types
165    //
166    //  ModelTypes
167    //      Indicates the type of content model that an element has. This
168    //      indicates how the content model is represented and validated.
169    // -----------------------------------------------------------------------
170    enum ModelTypes
171    {
172        Empty
173        , Any
174        , Mixed_Simple
175        , Mixed_Complex
176        , Children
177        , Simple
178
179        , ModelTypes_Count
180    };
181
182    // -----------------------------------------------------------------------
183    //  Constructors and Destructor
184    // -----------------------------------------------------------------------
185    SchemaElementDecl(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
186    SchemaElementDecl
187    (
188          const XMLCh* const   prefix
189        , const XMLCh* const   localPart
190        , const int            uriId
191        , const ModelTypes     modelType = Any
192        , const int            enclosingScope = Grammar::TOP_LEVEL_SCOPE
193        , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
194    );
195
196    SchemaElementDecl
197    (
198          const QName* const   elementName
199        , const ModelTypes     modelType = Any
200        , const int            enclosingScope = Grammar::TOP_LEVEL_SCOPE
201        , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
202    );
203
204    ~SchemaElementDecl();
205
206
207    // -----------------------------------------------------------------------
208    //  The virtual element decl interface
209    // -----------------------------------------------------------------------
210    virtual XMLAttDef* findAttr
211    (
212        const   XMLCh* const    qName
213        , const unsigned int    uriId
214        , const XMLCh* const    baseName
215        , const XMLCh* const    prefix
216        , const LookupOpts      options
217        ,       bool&           wasAdded
218    )   const;
219    virtual XMLAttDefList& getAttDefList() const;
220    virtual CharDataOpts getCharDataOpts() const;
221    virtual bool hasAttDefs() const;
222    // @deprecated; not thread-safe
223    virtual bool resetDefs();
224    virtual const ContentSpecNode* getContentSpec() const;
225    virtual ContentSpecNode* getContentSpec();
226    virtual void setContentSpec(ContentSpecNode* toAdopt);
227    virtual XMLContentModel* getContentModel();
228    virtual void setContentModel(XMLContentModel* const newModelToAdopt);
229    virtual const XMLCh* getFormattedContentModel ()   const;
230
231
232    // -----------------------------------------------------------------------
233    //  Getter methods
234    // -----------------------------------------------------------------------
235    const SchemaAttDef* getAttDef(const XMLCh* const baseName, const int uriId) const;
236    SchemaAttDef* getAttDef(const XMLCh* const baseName, const int uriId);
237    const SchemaAttDef* getAttWildCard() const;
238    SchemaAttDef* getAttWildCard();
239    ModelTypes getModelType() const;
240    PSVIDefs::PSVIScope getPSVIScope() const;
241    DatatypeValidator* getDatatypeValidator() const;
242    int getEnclosingScope() const;
243    int getFinalSet() const;
244    int getBlockSet() const;
245    int getMiscFlags() const;
246    XMLCh* getDefaultValue() const;
247    ComplexTypeInfo* getComplexTypeInfo() const;
248    virtual bool isGlobalDecl() const;
249    SchemaElementDecl* getSubstitutionGroupElem() const;
250
251
252    // ----------------------------------------------------------------------
253    // Partial implementation of PSVI
254    // The values these methods return are only accurate until the cleanUp method
255    // is called (in the end tag part of the scanner you are using)
256    // note that some of this information has dependancies. For example,
257    // if something is not valid then the information returned by the other
258    // calls may be meaningless
259    // See http://www.w3.org/TR/xmlschema-1/ for detailed information
260    // ----------------------------------------------------------------------
261
262
263    /**
264     * The appropriate case among the following:
265     * 1 If it was strictly assessed, then the appropriate case among the following:
266     * 1.1 If all of the following are true
267     *    1.1.1
268     *    1.1.1.1 clause 1.1 of Schema-Validity Assessment (Element) (3.3.4) applied and the item was valid as defined by Element Locally Valid (Element) (3.3.4);
269     *    1.1.1.2 clause 1.2 of Schema-Validity Assessment (Element) (3.3.4) applied and the item was valid as defined by Element Locally Valid (Type) (3.3.4).
270     *    1.1.2 Neither its [children] nor its [attributes] contains an information item (element or attribute respectively) whose [validity] is invalid.
271     *    1.1.3 Neither its [children] nor its [attributes] contains an information item (element or attribute respectively) with a context-determined declaration of mustFind whose [validity] is unknown.
272     * , then valid;
273     *    1.2 otherwise invalid.
274     *    2 otherwise notKnown.
275     * @deprecated; not thread-safe
276     */
277    PSVIDefs::Validity getValidity() const;
278
279
280    /**
281     * The appropriate case among the following:
282     * 1 If it was strictly assessed and neither its [children] nor its [attributes] contains an information item (element or attribute respectively) whose [validation attempted] is not full, then full;
283     * 2 If it was not strictly assessed and neither its [children] nor its [attributes] contains an information item (element or attribute respectively) whose [validation attempted] is not none, then none;
284     *3 otherwise partial.
285     * @deprecated; not thread-safe
286     */
287    PSVIDefs::Validation getValidationAttempted() const;
288
289
290    /**
291     * @return the complexity. simple or complex, depending on the type definition.
292     * @deprecated; not thread-safe
293     */
294    PSVIDefs::Complexity getTypeType() const;
295
296    /**
297     * The target namespace of the type definition.
298     * @deprecated; not thread-safe (will not work with xsi:type and shared grammars)
299     */
300    const XMLCh* getTypeUri() const;
301
302    /**
303     * The {name} of the type definition, if it is not absent.
304     * @deprecated; not thread-safe (will not work with xsi:type and shared grammars)
305     */
306    const XMLCh* getTypeName() const;
307
308    /**
309     * true if the {name} of the type definition is absent, otherwise false.
310     * @deprecated; not thread-safe (will not work with xsi:type and shared grammars)
311     */
312    bool getTypeAnonymous() const;
313
314    /**
315     * If this method returns true and validity is VALID then the next three
316     * produce accurate results
317     * @return true if the element is validated using a union type
318     * @deprecated; not thread-safe (will not work with xsi:type and shared grammars)
319     */
320    bool isTypeDefinitionUnion() const;
321
322    /**
323     * The {target namespace} of the actual member type definition.
324     * @deprecated; not thread-safe (will not work with xsi:type and shared grammars)
325     */
326    const XMLCh* getMemberTypeUri() const;
327
328    /**
329     * @return true if the {name} of the actual member type definition is absent, otherwise false.
330     * @deprecated; not thread-safe (will not work with xsi:type and shared grammars)
331     */
332    bool getMemberTypeAnonymous() const;
333
334    /**
335     * @return the {name} of the actual member type definition, if it is not absent.
336     * @deprecated; not thread-safe (will not work with xsi:type and shared grammars)
337     */
338    const XMLCh* getMemberTypeName() const;
339
340
341    /**
342     * @deprecated; not thread-safe (will not work with xsi:type and shared grammars)
343     */
344    virtual const XMLCh* getDOMTypeInfoUri() const;
345    /**
346     * @deprecated; not thread-safe (will not work with xsi:type and shared grammars)
347     */
348    virtual const XMLCh* getDOMTypeInfoName() const;
349
350
351    // -----------------------------------------------------------------------
352    //  Setter methods
353    // -----------------------------------------------------------------------
354    /**
355     * @deprecated; not actually used
356     */   
357    void setElemId(unsigned int elemId);
358    void setModelType(const SchemaElementDecl::ModelTypes toSet);
359    void setPSVIScope(const PSVIDefs::PSVIScope toSet);
360    void setDatatypeValidator(DatatypeValidator* newDatatypeValidator);
361    void setEnclosingScope(const int enclosingScope);
362    void setFinalSet(const int finalSet);
363    void setBlockSet(const int blockSet);
364    void setMiscFlags(const int flags);
365    void setDefaultValue(const XMLCh* const value);
366    void setComplexTypeInfo(ComplexTypeInfo* const typeInfo);
367    /**
368     * @deprecated; not thread-safe (will not work with xsi:type and shared grammars)
369     */
370    void setXsiComplexTypeInfo(ComplexTypeInfo* const typeInfo);
371    /**
372     * @deprecated; not thread-safe (will not work with xsi:type and shared grammars)
373     */
374    void setXsiSimpleTypeInfo(const DatatypeValidator* const dtv);
375    void setAttWildCard(SchemaAttDef* const attWildCard);
376    void setSubstitutionGroupElem(SchemaElementDecl* const elemDecl);
377    /**
378     * @deprecated; not thread-safe (will not work with xsi:type and shared grammars)
379     */
380    void setValidity(PSVIDefs::Validity valid);
381    /**
382     * @deprecated; not thread-safe (will not work with xsi:type and shared grammars)
383     */
384    void setValidationAttempted(PSVIDefs::Validation validation);
385   
386    /**
387     * called when element content of this element was validated
388     * @deprecated; not thread-safe (will not work with xsi:type and shared grammars)
389     */
390    void updateValidityFromElement(const XMLElementDecl *decl, Grammar::GrammarType eleGrammar);
391   
392    //called when attribute content of this element was validated   
393    // @deprecated; should not be needed in a thread-safe implementation
394    void updateValidityFromAttribute(const SchemaAttDef *def);
395
396    /**
397     * cleans up inbetween uses of the SchemaElementDecl. Resets xsiType, Validity etc.
398     * @deprecated; not thread-safe (will not work with xsi:type and shared grammars)
399     */
400    void reset();
401
402    // -----------------------------------------------------------------------
403    //  IC methods
404    // -----------------------------------------------------------------------
405    void addIdentityConstraint(IdentityConstraint* const ic);
406    unsigned int getIdentityConstraintCount() const;
407    IdentityConstraint* getIdentityConstraintAt(unsigned int index) const;
408
409    /***
410     * Support for Serialization/De-serialization
411     ***/
412    DECL_XSERIALIZABLE(SchemaElementDecl)
413
414    virtual XMLElementDecl::objectType  getObjectType() const;
415
416private :
417    // -----------------------------------------------------------------------
418    //  Unimplemented constructors and operators
419    // -----------------------------------------------------------------------
420    SchemaElementDecl(const SchemaElementDecl&);
421    SchemaElementDecl& operator=(const SchemaElementDecl&);
422
423    // -----------------------------------------------------------------------
424    //  Private data members
425    //
426    //  fModelType
427    //      The content model type of this element. This tells us what kind
428    //      of content model to create.
429    //
430    //  fDatatypeValidator
431    //      The DatatypeValidator used to validate this element type.
432    //
433    //  fEnclosingScope
434    //      The enclosing scope where this element is declared.
435    //
436    //  fFinalSet
437    //      The value set of the 'final' attribute.
438    //
439    //  fBlockSet
440    //      The value set of the 'block' attribute.
441    //
442    //  fMiscFlags
443    //      Stores 'abstract/nullable' values
444    //
445    //  fDefaultValue
446    //      The defalut/fixed value
447    //
448    //  fComplexTypeInfo
449    //      Stores complex type information
450    //      (no need to delete - handled by schema grammar)
451    //
452    //  fAttDefs
453    //      The list of attributes that are faulted in for this element
454    //      when ComplexTypeInfo does not exist.  We want to keep track
455    //      of these faulted in attributes to avoid duplicate redundant
456    //      error.
457    //
458    //  fXsiComplexTypeInfo
459    //      Temporary store the xsi:type ComplexType here for validation
460    //      If it presents, then it takes precedence than its own fComplexTypeInfo.
461    //
462    //  fXsiSimpleTypeInfo
463    //      Temporary store the xsi:type SimpleType here for validation
464    //      If it present then the information from it will be returned rather than fDatatypeValidator
465    //
466    //  fIdentityConstraints
467    //      Store information about an element identity constraints.
468    //
469    //  fAttWildCard
470    //      Store wildcard attribute in the case of an element with a type of
471    //      'anyType'.
472    //
473    //  fSubstitutionGroupElem
474    //      The substitution group element declaration.
475    //
476    //  fValidity
477    //      After this attr has been validated this is its validity
478    //
479    //  fValidation
480    //      The type of validation that happened to this attr
481    //
482    //  fSeenValidation
483    //      set to true when a piece of content of this element is validated
484    //
485    //  fSeenNoValidation
486    //      set to true when a piece of content of this element is laxly or skip validated
487    //
488    //  fHadContent
489    //      true when this element actually had content.
490    // -----------------------------------------------------------------------
491
492    // -----------------------------------------------------------------------
493    ModelTypes                         fModelType;
494    PSVIDefs::PSVIScope                fPSVIScope;
495    DatatypeValidator*                 fDatatypeValidator;
496    int                                fEnclosingScope;
497    int                                fFinalSet;
498    int                                fBlockSet;
499    int                                fMiscFlags;   
500    XMLCh*                             fDefaultValue;
501    ComplexTypeInfo*                   fComplexTypeInfo;
502    RefHash2KeysTableOf<SchemaAttDef>* fAttDefs;
503    ComplexTypeInfo*                   fXsiComplexTypeInfo;
504    const DatatypeValidator*           fXsiSimpleTypeInfo;
505    RefVectorOf<IdentityConstraint>*   fIdentityConstraints;
506    SchemaAttDef*                      fAttWildCard;
507    SchemaElementDecl*                 fSubstitutionGroupElem;
508    PSVIDefs::Validity                 fValidity;
509    PSVIDefs::Validation               fValidation;
510    bool                               fSeenValidation;
511    bool                               fSeenNoValidation;
512    bool                               fHadContent;
513};
514
515// ---------------------------------------------------------------------------
516//  SchemaElementDecl: XMLElementDecl virtual interface implementation
517// ---------------------------------------------------------------------------
518inline ContentSpecNode* SchemaElementDecl::getContentSpec()
519{
520    if (fComplexTypeInfo != 0) {
521        return fComplexTypeInfo->getContentSpec();
522    }
523
524    return 0;
525}
526
527inline const ContentSpecNode* SchemaElementDecl::getContentSpec() const
528{
529    if (fComplexTypeInfo != 0) {
530        return fComplexTypeInfo->getContentSpec();
531    }
532
533    return 0;
534}
535
536inline void
537SchemaElementDecl::setContentSpec(ContentSpecNode*)
538{
539    //Handled by complexType
540}
541
542inline XMLContentModel* SchemaElementDecl::getContentModel()
543{
544    if (fComplexTypeInfo != 0) {
545        return fComplexTypeInfo->getContentModel();
546    }
547    return 0;
548}
549
550inline void
551SchemaElementDecl::setContentModel(XMLContentModel* const)
552{
553    //Handled by complexType
554}
555
556
557// ---------------------------------------------------------------------------
558//  SchemaElementDecl: Getter methods
559// ---------------------------------------------------------------------------
560inline SchemaElementDecl::ModelTypes SchemaElementDecl::getModelType() const
561{
562    if (fComplexTypeInfo) {
563        return (SchemaElementDecl::ModelTypes) fComplexTypeInfo->getContentType();
564    }
565
566    return fModelType;
567}
568
569inline PSVIDefs::PSVIScope SchemaElementDecl::getPSVIScope() const
570{
571    return fPSVIScope;
572}
573
574inline DatatypeValidator* SchemaElementDecl::getDatatypeValidator() const
575{
576
577    return fDatatypeValidator;
578}
579
580inline int SchemaElementDecl::getEnclosingScope() const
581{
582    return fEnclosingScope;
583}
584
585inline int SchemaElementDecl::getFinalSet() const
586{
587    return fFinalSet;
588}
589
590inline int SchemaElementDecl::getBlockSet() const
591{
592    return fBlockSet;
593}
594
595inline int SchemaElementDecl::getMiscFlags() const
596{
597    return fMiscFlags;
598}
599
600inline XMLCh* SchemaElementDecl::getDefaultValue() const
601{
602    return fDefaultValue;
603}
604
605inline ComplexTypeInfo* SchemaElementDecl::getComplexTypeInfo() const
606{
607
608    return fComplexTypeInfo;
609}
610
611inline const SchemaAttDef* SchemaElementDecl::getAttWildCard() const {
612
613    return fAttWildCard;
614}
615
616inline SchemaAttDef* SchemaElementDecl::getAttWildCard() {
617
618    return fAttWildCard;
619}
620
621inline bool SchemaElementDecl::isGlobalDecl() const {
622
623    return (fEnclosingScope == Grammar::TOP_LEVEL_SCOPE);
624}
625
626inline SchemaElementDecl*
627SchemaElementDecl::getSubstitutionGroupElem() const {
628
629    return fSubstitutionGroupElem;
630}
631
632inline const XMLCh* SchemaElementDecl::getTypeName() const {
633    // removing fXsi* references would break DOMTypeInfo implementation completely;
634    // will have to wait for now
635    if (fXsiComplexTypeInfo)
636        return fXsiComplexTypeInfo->getTypeLocalName();
637    else if (fComplexTypeInfo)
638        return fComplexTypeInfo->getTypeLocalName();
639    else if(fXsiSimpleTypeInfo)
640        return fXsiSimpleTypeInfo->getTypeLocalName();
641    else if(fDatatypeValidator)
642        return fDatatypeValidator->getTypeLocalName();
643
644    //its anyType if we have not done validation on it or none of the above exist
645    return SchemaSymbols::fgATTVAL_ANYTYPE;
646}
647
648inline PSVIDefs::Complexity SchemaElementDecl::getTypeType() const {
649    if(getModelType() == Simple) {
650        return PSVIDefs::SIMPLE;
651    }
652    else {
653        return PSVIDefs::COMPLEX;
654    }
655}
656
657
658inline const XMLCh* SchemaElementDecl::getTypeUri() const {
659    // removing fXsi* references would break DOMTypeInfo implementation completely;
660    // will have to wait for now
661    if (fXsiComplexTypeInfo)
662        return fXsiComplexTypeInfo->getTypeUri();
663    else if (fComplexTypeInfo)
664        return fComplexTypeInfo->getTypeUri();
665    else if(fXsiSimpleTypeInfo)
666        return fXsiSimpleTypeInfo->getTypeUri();
667    else if(fDatatypeValidator)
668        return fDatatypeValidator->getTypeUri();
669
670    //its anyType if we have not done validation on it or none of the above exist
671    return SchemaSymbols::fgURI_SCHEMAFORSCHEMA;
672}
673
674inline const XMLCh* SchemaElementDecl::getMemberTypeName() const {
675    // removing fXsi* references would break DOMTypeInfo implementation completely;
676    // will have to wait for now
677    if(fXsiSimpleTypeInfo && fXsiSimpleTypeInfo->getType() == DatatypeValidator::Union)
678        return ((UnionDatatypeValidator*)fXsiSimpleTypeInfo)->getMemberTypeName();
679    else if(fDatatypeValidator && fDatatypeValidator->getType() == DatatypeValidator::Union)
680        return ((UnionDatatypeValidator*)fDatatypeValidator)->getMemberTypeName();
681    return 0;
682}
683
684inline const XMLCh* SchemaElementDecl::getMemberTypeUri() const {
685    // removing fXsi* references would break DOMTypeInfo implementation completely;
686    // will have to wait for now
687    if(fXsiSimpleTypeInfo && fXsiSimpleTypeInfo->getType() == DatatypeValidator::Union)
688        return ((UnionDatatypeValidator*)fXsiSimpleTypeInfo)->getMemberTypeUri();
689    if(fDatatypeValidator && fDatatypeValidator->getType() == DatatypeValidator::Union)
690        return ((UnionDatatypeValidator*)fDatatypeValidator)->getMemberTypeUri();
691
692    return 0;
693}
694
695inline bool SchemaElementDecl::getMemberTypeAnonymous() const {
696    // removing fXsi* references would break DOMTypeInfo implementation completely;
697    // will have to wait for now
698    if(fXsiSimpleTypeInfo && fXsiSimpleTypeInfo->getType() == DatatypeValidator::Union)
699        return ((UnionDatatypeValidator*)fXsiSimpleTypeInfo)->getMemberTypeAnonymous();
700    else if(fDatatypeValidator && fDatatypeValidator->getType() == DatatypeValidator::Union)
701        return ((UnionDatatypeValidator*)fDatatypeValidator)->getMemberTypeAnonymous();
702    return false;
703}
704
705inline bool SchemaElementDecl::isTypeDefinitionUnion() const {
706    // removing fXsi* references would break DOMTypeInfo implementation completely;
707    // will have to wait for now
708   if(fXsiSimpleTypeInfo && fXsiSimpleTypeInfo->getType() == DatatypeValidator::Union ||
709      fDatatypeValidator && fDatatypeValidator->getType() == DatatypeValidator::Union)
710       return true;
711    return false;
712}
713
714inline PSVIDefs::Validity SchemaElementDecl::getValidity() const {
715    return fValidity;
716}
717
718inline PSVIDefs::Validation SchemaElementDecl::getValidationAttempted() const {
719    if(!fHadContent)
720        return fValidation;
721
722    if(!fSeenNoValidation && fSeenValidation)
723        return PSVIDefs::FULL;
724    else if(fSeenNoValidation && !fSeenValidation)
725        return PSVIDefs::NONE;
726    else
727        return PSVIDefs::PARTIAL;
728}
729
730inline bool SchemaElementDecl::getTypeAnonymous() const {
731   
732    //REVISIT - since xsi type have to be accessed through names
733    //presumeably they cannot be anonymous
734   
735    if (fXsiComplexTypeInfo) {
736        return fXsiComplexTypeInfo->getAnonymous();
737    }
738    else if (fComplexTypeInfo) {
739        return fComplexTypeInfo->getAnonymous();
740    }
741    else if(fXsiSimpleTypeInfo) {
742        return fXsiSimpleTypeInfo->getAnonymous();
743    }
744    else if(fDatatypeValidator){
745        return fDatatypeValidator->getAnonymous();
746    }
747
748    return false;
749}
750
751inline const XMLCh* SchemaElementDecl::getDOMTypeInfoName() const {
752    // removing fXsi* references would break DOMTypeInfo implementation completely;
753    // will have to wait for now
754    if(fValidity != PSVIDefs::VALID) {
755        if(getTypeType() == PSVIDefs::SIMPLE)
756            return SchemaSymbols::fgDT_ANYSIMPLETYPE;
757        else
758            return SchemaSymbols::fgATTVAL_ANYTYPE;
759    }
760
761    if(getTypeAnonymous() || getMemberTypeAnonymous())
762        return 0;
763    if(fDatatypeValidator && fDatatypeValidator->getType() == DatatypeValidator::Union)
764        return ((UnionDatatypeValidator*)fDatatypeValidator)->getMemberTypeName();
765    if(fXsiSimpleTypeInfo && fXsiSimpleTypeInfo->getType() == DatatypeValidator::Union)
766        return ((UnionDatatypeValidator*)fXsiSimpleTypeInfo)->getMemberTypeName();
767    return getTypeName();
768}
769
770inline const XMLCh* SchemaElementDecl::getDOMTypeInfoUri() const {
771
772    // removing fXsi* references would break DOMTypeInfo implementation completely;
773    // will have to wait for now
774    if(fValidity != PSVIDefs::VALID)
775        return SchemaSymbols::fgURI_SCHEMAFORSCHEMA;
776
777    if(getTypeAnonymous() || getMemberTypeAnonymous())
778        return 0;
779
780    if(fDatatypeValidator && fDatatypeValidator->getType() == DatatypeValidator::Union)
781        return ((UnionDatatypeValidator*)fDatatypeValidator)->getMemberTypeUri();
782
783    if(fXsiSimpleTypeInfo && fXsiSimpleTypeInfo->getType() == DatatypeValidator::Union)
784        return ((UnionDatatypeValidator*)fXsiSimpleTypeInfo)->getMemberTypeUri();
785
786
787    return getTypeUri();
788}
789
790// ---------------------------------------------------------------------------
791//  SchemaElementDecl: Setter methods
792// ---------------------------------------------------------------------------
793inline void
794SchemaElementDecl::setElemId(unsigned int)
795{
796    //there is not getElemId so this is not needed. mark deprecated.
797    //fElemId = elemId;
798}
799
800inline void
801SchemaElementDecl::setModelType(const SchemaElementDecl::ModelTypes toSet)
802{
803    fModelType = toSet;
804}
805
806inline void
807SchemaElementDecl::setPSVIScope(const PSVIDefs::PSVIScope toSet)
808{
809    fPSVIScope = toSet;
810}
811
812inline void SchemaElementDecl::setDatatypeValidator(DatatypeValidator* newDatatypeValidator)
813{
814    fDatatypeValidator = newDatatypeValidator;
815}
816
817inline void SchemaElementDecl::setEnclosingScope(const int newEnclosingScope)
818{
819    fEnclosingScope = newEnclosingScope;
820}
821
822inline void SchemaElementDecl::setFinalSet(const int finalSet)
823{
824    fFinalSet = finalSet;
825}
826
827inline void SchemaElementDecl::setBlockSet(const int blockSet)
828{
829    fBlockSet = blockSet;
830}
831
832inline void SchemaElementDecl::setMiscFlags(const int flags)
833{
834    fMiscFlags = flags;
835}
836
837inline void SchemaElementDecl::setDefaultValue(const XMLCh* const value)
838{
839    if (fDefaultValue) {
840        getMemoryManager()->deallocate(fDefaultValue);//delete[] fDefaultValue;
841    }
842
843    fDefaultValue = XMLString::replicate(value, getMemoryManager());
844}
845
846inline void
847SchemaElementDecl::setComplexTypeInfo(ComplexTypeInfo* const typeInfo)
848{
849    fComplexTypeInfo = typeInfo;
850}
851
852inline void
853SchemaElementDecl::setXsiComplexTypeInfo(ComplexTypeInfo* const typeInfo)
854{
855    fXsiComplexTypeInfo = typeInfo;
856}
857
858inline void
859SchemaElementDecl::setXsiSimpleTypeInfo(const DatatypeValidator* const dtv)
860{
861    fXsiSimpleTypeInfo = dtv;
862}
863
864inline void
865SchemaElementDecl::setAttWildCard(SchemaAttDef* const attWildCard) {
866
867    if (fAttWildCard)
868        delete fAttWildCard;
869
870    fAttWildCard = attWildCard;
871}
872
873inline void
874SchemaElementDecl::setSubstitutionGroupElem(SchemaElementDecl* const elemDecl) {
875
876    fSubstitutionGroupElem = elemDecl;
877}
878
879inline void SchemaElementDecl::setValidity(PSVIDefs::Validity valid) {
880    fValidity = valid;
881}
882
883inline void SchemaElementDecl::setValidationAttempted(PSVIDefs::Validation validation) {
884    fValidation = validation;
885}
886
887inline void SchemaElementDecl::updateValidityFromAttribute(const SchemaAttDef *def) {
888
889    PSVIDefs::Validation curValAttemted = def->getValidationAttempted();
890    PSVIDefs::Validity curVal = def->getValidity();
891       
892    if(curValAttemted == PSVIDefs::NONE || curValAttemted == PSVIDefs::PARTIAL) {
893        fSeenNoValidation = true;
894        fValidity = PSVIDefs::UNKNOWN;
895    }
896    else {
897        fSeenValidation = true;
898    }
899       
900    if(curVal == PSVIDefs::INVALID)
901        fValidity = PSVIDefs::INVALID;
902
903    fHadContent = true;
904}
905
906inline void SchemaElementDecl::updateValidityFromElement(const XMLElementDecl *decl, Grammar::GrammarType eleGrammar) {
907
908    if (eleGrammar == Grammar::SchemaGrammarType) {                   
909        PSVIDefs::Validation curValAttemted = ((SchemaElementDecl *)decl)->getValidationAttempted();
910        PSVIDefs::Validity curVal = ((SchemaElementDecl *)decl)->getValidity();
911       
912        if(curValAttemted == PSVIDefs::NONE || curValAttemted == PSVIDefs::PARTIAL) {
913            fSeenNoValidation = true;
914            fValidity = PSVIDefs::UNKNOWN;
915        }
916        else {
917            fSeenValidation = true;
918        }
919       
920        if(curVal == PSVIDefs::INVALID)
921            fValidity = PSVIDefs::INVALID;
922    }
923
924    fHadContent = true;
925
926}
927
928inline void SchemaElementDecl::reset() {
929    if(fXsiSimpleTypeInfo && fXsiSimpleTypeInfo->getType() == DatatypeValidator::Union)
930        ((UnionDatatypeValidator *)fXsiSimpleTypeInfo)->reset();
931    if(fDatatypeValidator && fDatatypeValidator->getType() == DatatypeValidator::Union)
932        ((UnionDatatypeValidator *)fDatatypeValidator)->reset();
933
934    setXsiSimpleTypeInfo(0);
935    setXsiComplexTypeInfo(0);
936    fValidity = PSVIDefs::UNKNOWN;
937    fValidation = PSVIDefs::NONE;   
938    fSeenValidation = false;
939    fSeenNoValidation = false;
940    fHadContent = false;
941}
942
943// ---------------------------------------------------------------------------
944//  SchemaElementDecl: IC methods
945// ---------------------------------------------------------------------------
946inline void
947SchemaElementDecl::addIdentityConstraint(IdentityConstraint* const ic) {
948
949    if (!fIdentityConstraints) {
950        fIdentityConstraints = new (getMemoryManager()) RefVectorOf<IdentityConstraint>(16, true, getMemoryManager());
951    }
952
953    fIdentityConstraints->addElement(ic);
954}
955
956inline unsigned int SchemaElementDecl::getIdentityConstraintCount() const {
957
958    if (fIdentityConstraints) {
959        return fIdentityConstraints->size();
960    }
961
962    return 0;
963}
964
965inline IdentityConstraint*
966SchemaElementDecl::getIdentityConstraintAt(unsigned int index) const {
967
968    if (fIdentityConstraints) {
969        return fIdentityConstraints->elementAt(index);
970    }
971
972    return 0;
973}
974
975XERCES_CPP_NAMESPACE_END
976
977#endif
Note: See TracBrowser for help on using the repository browser.