source: NonGTP/Xerces/xerces-c_2_8_0/include/xercesc/validators/schema/SchemaElementDecl.hpp @ 2674

Revision 2674, 29.0 KB checked in by mattausch, 16 years ago (diff)
Line 
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements.  See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License.  You may obtain a copy of the License at
8 *
9 *      http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18/*
19 * $Id: SchemaElementDecl.hpp 568078 2007-08-21 11:43:25Z amassari $
20 */
21
22
23#if !defined(SCHEMAELEMENTDECL_HPP)
24#define SCHEMAELEMENTDECL_HPP
25
26#include <xercesc/util/QName.hpp>
27#include <xercesc/validators/common/Grammar.hpp>
28#include <xercesc/validators/schema/ComplexTypeInfo.hpp>
29#include <xercesc/validators/schema/identity/IdentityConstraint.hpp>
30#include <xercesc/validators/datatype/DatatypeValidator.hpp>
31#include <xercesc/validators/datatype/UnionDatatypeValidator.hpp>
32#include <xercesc/validators/schema/PSVIDefs.hpp>
33
34XERCES_CPP_NAMESPACE_BEGIN
35
36class ContentSpecNode;
37class SchemaAttDefList;
38
39//
40//  This class is a derivative of the basic element decl. This one implements
41//  the virtuals so that they work for a Schema.
42//
43class VALIDATORS_EXPORT SchemaElementDecl : public XMLElementDecl
44{
45public :
46
47    // -----------------------------------------------------------------------
48    //  Class specific types
49    //
50    //  ModelTypes
51    //      Indicates the type of content model that an element has. This
52    //      indicates how the content model is represented and validated.
53    // -----------------------------------------------------------------------
54    enum ModelTypes
55    {
56        Empty
57        , Any
58        , Mixed_Simple
59        , Mixed_Complex
60        , Children
61        , Simple
62
63        , ModelTypes_Count
64    };
65
66    // -----------------------------------------------------------------------
67    //  Constructors and Destructor
68    // -----------------------------------------------------------------------
69    SchemaElementDecl(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
70    SchemaElementDecl
71    (
72          const XMLCh* const   prefix
73        , const XMLCh* const   localPart
74        , const int            uriId
75        , const ModelTypes     modelType = Any
76        , const int            enclosingScope = Grammar::TOP_LEVEL_SCOPE
77        , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
78    );
79
80    SchemaElementDecl
81    (
82          const QName* const   elementName
83        , const ModelTypes     modelType = Any
84        , const int            enclosingScope = Grammar::TOP_LEVEL_SCOPE
85        , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
86    );
87
88    ~SchemaElementDecl();
89
90
91    // -----------------------------------------------------------------------
92    //  The virtual element decl interface
93    // -----------------------------------------------------------------------
94    virtual XMLAttDef* findAttr
95    (
96        const   XMLCh* const    qName
97        , const unsigned int    uriId
98        , const XMLCh* const    baseName
99        , const XMLCh* const    prefix
100        , const LookupOpts      options
101        ,       bool&           wasAdded
102    )   const;
103    virtual XMLAttDefList& getAttDefList() const;
104    virtual CharDataOpts getCharDataOpts() const;
105    virtual bool hasAttDefs() const;
106    // @deprecated; not thread-safe
107    virtual bool resetDefs();
108    virtual const ContentSpecNode* getContentSpec() const;
109    virtual ContentSpecNode* getContentSpec();
110    virtual void setContentSpec(ContentSpecNode* toAdopt);
111    virtual XMLContentModel* getContentModel();
112    virtual void setContentModel(XMLContentModel* const newModelToAdopt);
113    virtual const XMLCh* getFormattedContentModel ()   const;
114
115
116    // -----------------------------------------------------------------------
117    //  Getter methods
118    // -----------------------------------------------------------------------
119    const SchemaAttDef* getAttDef(const XMLCh* const baseName, const int uriId) const;
120    SchemaAttDef* getAttDef(const XMLCh* const baseName, const int uriId);
121    const SchemaAttDef* getAttWildCard() const;
122    SchemaAttDef* getAttWildCard();
123    ModelTypes getModelType() const;
124    PSVIDefs::PSVIScope getPSVIScope() const;
125    DatatypeValidator* getDatatypeValidator() const;
126    int getEnclosingScope() const;
127    int getFinalSet() const;
128    int getBlockSet() const;
129    int getMiscFlags() const;
130    XMLCh* getDefaultValue() const;
131    ComplexTypeInfo* getComplexTypeInfo() const;
132    virtual bool isGlobalDecl() const;
133    SchemaElementDecl* getSubstitutionGroupElem() const;
134
135
136    // ----------------------------------------------------------------------
137    // Partial implementation of PSVI
138    // The values these methods return are only accurate until the cleanUp method
139    // is called (in the end tag part of the scanner you are using)
140    // note that some of this information has dependancies. For example,
141    // if something is not valid then the information returned by the other
142    // calls may be meaningless
143    // See http://www.w3.org/TR/xmlschema-1/ for detailed information
144    // ----------------------------------------------------------------------
145
146
147    /**
148     * The appropriate case among the following:
149     * 1 If it was strictly assessed, then the appropriate case among the following:
150     * 1.1 If all of the following are true
151     *    1.1.1
152     *    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);
153     *    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).
154     *    1.1.2 Neither its [children] nor its [attributes] contains an information item (element or attribute respectively) whose [validity] is invalid.
155     *    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.
156     * , then valid;
157     *    1.2 otherwise invalid.
158     *    2 otherwise notKnown.
159     * @deprecated; not thread-safe
160     */
161    PSVIDefs::Validity getValidity() const;
162
163
164    /**
165     * The appropriate case among the following:
166     * 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;
167     * 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;
168     *3 otherwise partial.
169     * @deprecated; not thread-safe
170     */
171    PSVIDefs::Validation getValidationAttempted() const;
172
173
174    /**
175     * @return the complexity. simple or complex, depending on the type definition.
176     * @deprecated; not thread-safe
177     */
178    PSVIDefs::Complexity getTypeType() const;
179
180    /**
181     * The target namespace of the type definition.
182     * @deprecated; not thread-safe (will not work with xsi:type and shared grammars)
183     */
184    const XMLCh* getTypeUri() const;
185
186    /**
187     * The {name} of the type definition, if it is not absent.
188     * @deprecated; not thread-safe (will not work with xsi:type and shared grammars)
189     */
190    const XMLCh* getTypeName() const;
191
192    /**
193     * true if the {name} of the type definition is absent, otherwise false.
194     * @deprecated; not thread-safe (will not work with xsi:type and shared grammars)
195     */
196    bool getTypeAnonymous() const;
197
198    /**
199     * If this method returns true and validity is VALID then the next three
200     * produce accurate results
201     * @return true if the element is validated using a union type
202     * @deprecated; not thread-safe (will not work with xsi:type and shared grammars)
203     */
204    bool isTypeDefinitionUnion() const;
205
206    /**
207     * The {target namespace} of the actual member type definition.
208     * @deprecated; not thread-safe (will not work with xsi:type and shared grammars)
209     */
210    const XMLCh* getMemberTypeUri() const;
211
212    /**
213     * @return true if the {name} of the actual member type definition is absent, otherwise false.
214     * @deprecated; not thread-safe (will not work with xsi:type and shared grammars)
215     */
216    bool getMemberTypeAnonymous() const;
217
218    /**
219     * @return the {name} of the actual member type definition, if it is not absent.
220     * @deprecated; not thread-safe (will not work with xsi:type and shared grammars)
221     */
222    const XMLCh* getMemberTypeName() const;
223
224
225    /**
226     * @deprecated; not thread-safe (will not work with xsi:type and shared grammars)
227     */
228    virtual const XMLCh* getDOMTypeInfoUri() const;
229    /**
230     * @deprecated; not thread-safe (will not work with xsi:type and shared grammars)
231     */
232    virtual const XMLCh* getDOMTypeInfoName() const;
233
234
235    // -----------------------------------------------------------------------
236    //  Setter methods
237    // -----------------------------------------------------------------------
238    /**
239     * @deprecated; not actually used
240     */   
241    void setElemId(unsigned int elemId);
242    void setModelType(const SchemaElementDecl::ModelTypes toSet);
243    void setPSVIScope(const PSVIDefs::PSVIScope toSet);
244    void setDatatypeValidator(DatatypeValidator* newDatatypeValidator);
245    void setEnclosingScope(const int enclosingScope);
246    void setFinalSet(const int finalSet);
247    void setBlockSet(const int blockSet);
248    void setMiscFlags(const int flags);
249    void setDefaultValue(const XMLCh* const value);
250    void setComplexTypeInfo(ComplexTypeInfo* const typeInfo);
251    /**
252     * @deprecated; not thread-safe (will not work with xsi:type and shared grammars)
253     */
254    void setXsiComplexTypeInfo(ComplexTypeInfo* const typeInfo);
255    /**
256     * @deprecated; not thread-safe (will not work with xsi:type and shared grammars)
257     */
258    void setXsiSimpleTypeInfo(const DatatypeValidator* const dtv);
259    void setAttWildCard(SchemaAttDef* const attWildCard);
260    void setSubstitutionGroupElem(SchemaElementDecl* const elemDecl);
261    /**
262     * @deprecated; not thread-safe (will not work with xsi:type and shared grammars)
263     */
264    void setValidity(PSVIDefs::Validity valid);
265    /**
266     * @deprecated; not thread-safe (will not work with xsi:type and shared grammars)
267     */
268    void setValidationAttempted(PSVIDefs::Validation validation);
269   
270    /**
271     * called when element content of this element was validated
272     * @deprecated; not thread-safe (will not work with xsi:type and shared grammars)
273     */
274    void updateValidityFromElement(const XMLElementDecl *decl, Grammar::GrammarType eleGrammar);
275   
276    //called when attribute content of this element was validated   
277    // @deprecated; should not be needed in a thread-safe implementation
278    void updateValidityFromAttribute(const SchemaAttDef *def);
279
280    /**
281     * cleans up inbetween uses of the SchemaElementDecl. Resets xsiType, Validity etc.
282     * @deprecated; not thread-safe (will not work with xsi:type and shared grammars)
283     */
284    void reset();
285
286    // -----------------------------------------------------------------------
287    //  IC methods
288    // -----------------------------------------------------------------------
289    void addIdentityConstraint(IdentityConstraint* const ic);
290    unsigned int getIdentityConstraintCount() const;
291    IdentityConstraint* getIdentityConstraintAt(unsigned int index) const;
292
293    /***
294     * Support for Serialization/De-serialization
295     ***/
296    DECL_XSERIALIZABLE(SchemaElementDecl)
297
298    virtual XMLElementDecl::objectType  getObjectType() const;
299
300private :
301    // -----------------------------------------------------------------------
302    //  Unimplemented constructors and operators
303    // -----------------------------------------------------------------------
304    SchemaElementDecl(const SchemaElementDecl&);
305    SchemaElementDecl& operator=(const SchemaElementDecl&);
306
307    // -----------------------------------------------------------------------
308    //  Private data members
309    //
310    //  fModelType
311    //      The content model type of this element. This tells us what kind
312    //      of content model to create.
313    //
314    //  fDatatypeValidator
315    //      The DatatypeValidator used to validate this element type.
316    //
317    //  fEnclosingScope
318    //      The enclosing scope where this element is declared.
319    //
320    //  fFinalSet
321    //      The value set of the 'final' attribute.
322    //
323    //  fBlockSet
324    //      The value set of the 'block' attribute.
325    //
326    //  fMiscFlags
327    //      Stores 'abstract/nullable' values
328    //
329    //  fDefaultValue
330    //      The defalut/fixed value
331    //
332    //  fComplexTypeInfo
333    //      Stores complex type information
334    //      (no need to delete - handled by schema grammar)
335    //
336    //  fAttDefs
337    //      The list of attributes that are faulted in for this element
338    //      when ComplexTypeInfo does not exist.  We want to keep track
339    //      of these faulted in attributes to avoid duplicate redundant
340    //      error.
341    //
342    //  fXsiComplexTypeInfo
343    //      Temporary store the xsi:type ComplexType here for validation
344    //      If it presents, then it takes precedence than its own fComplexTypeInfo.
345    //
346    //  fXsiSimpleTypeInfo
347    //      Temporary store the xsi:type SimpleType here for validation
348    //      If it present then the information from it will be returned rather than fDatatypeValidator
349    //
350    //  fIdentityConstraints
351    //      Store information about an element identity constraints.
352    //
353    //  fAttWildCard
354    //      Store wildcard attribute in the case of an element with a type of
355    //      'anyType'.
356    //
357    //  fSubstitutionGroupElem
358    //      The substitution group element declaration.
359    //
360    //  fValidity
361    //      After this attr has been validated this is its validity
362    //
363    //  fValidation
364    //      The type of validation that happened to this attr
365    //
366    //  fSeenValidation
367    //      set to true when a piece of content of this element is validated
368    //
369    //  fSeenNoValidation
370    //      set to true when a piece of content of this element is laxly or skip validated
371    //
372    //  fHadContent
373    //      true when this element actually had content.
374    // -----------------------------------------------------------------------
375
376    // -----------------------------------------------------------------------
377    ModelTypes                         fModelType;
378    PSVIDefs::PSVIScope                fPSVIScope;
379    PSVIDefs::Validity                 fValidity;
380    PSVIDefs::Validation               fValidation;
381
382    int                                fEnclosingScope;
383    int                                fFinalSet;
384    int                                fBlockSet;
385    int                                fMiscFlags;   
386    XMLCh*                             fDefaultValue;
387    ComplexTypeInfo*                   fComplexTypeInfo;
388    RefHash2KeysTableOf<SchemaAttDef>* fAttDefs;
389    ComplexTypeInfo*                   fXsiComplexTypeInfo;
390    const DatatypeValidator*           fXsiSimpleTypeInfo;
391    RefVectorOf<IdentityConstraint>*   fIdentityConstraints;
392    SchemaAttDef*                      fAttWildCard;
393    SchemaElementDecl*                 fSubstitutionGroupElem;
394    DatatypeValidator*                 fDatatypeValidator;
395
396    bool                               fSeenValidation;
397    bool                               fSeenNoValidation;
398    bool                               fHadContent;
399};
400
401// ---------------------------------------------------------------------------
402//  SchemaElementDecl: XMLElementDecl virtual interface implementation
403// ---------------------------------------------------------------------------
404inline ContentSpecNode* SchemaElementDecl::getContentSpec()
405{
406    if (fComplexTypeInfo != 0) {
407        return fComplexTypeInfo->getContentSpec();
408    }
409
410    return 0;
411}
412
413inline const ContentSpecNode* SchemaElementDecl::getContentSpec() const
414{
415    if (fComplexTypeInfo != 0) {
416        return fComplexTypeInfo->getContentSpec();
417    }
418
419    return 0;
420}
421
422inline void
423SchemaElementDecl::setContentSpec(ContentSpecNode*)
424{
425    //Handled by complexType
426}
427
428inline XMLContentModel* SchemaElementDecl::getContentModel()
429{
430    if (fComplexTypeInfo != 0) {
431        return fComplexTypeInfo->getContentModel();
432    }
433    return 0;
434}
435
436inline void
437SchemaElementDecl::setContentModel(XMLContentModel* const)
438{
439    //Handled by complexType
440}
441
442
443// ---------------------------------------------------------------------------
444//  SchemaElementDecl: Getter methods
445// ---------------------------------------------------------------------------
446inline SchemaElementDecl::ModelTypes SchemaElementDecl::getModelType() const
447{
448    if (fComplexTypeInfo) {
449        return (SchemaElementDecl::ModelTypes) fComplexTypeInfo->getContentType();
450    }
451
452    return fModelType;
453}
454
455inline PSVIDefs::PSVIScope SchemaElementDecl::getPSVIScope() const
456{
457    return fPSVIScope;
458}
459
460inline DatatypeValidator* SchemaElementDecl::getDatatypeValidator() const
461{
462
463    return fDatatypeValidator;
464}
465
466inline int SchemaElementDecl::getEnclosingScope() const
467{
468    return fEnclosingScope;
469}
470
471inline int SchemaElementDecl::getFinalSet() const
472{
473    return fFinalSet;
474}
475
476inline int SchemaElementDecl::getBlockSet() const
477{
478    return fBlockSet;
479}
480
481inline int SchemaElementDecl::getMiscFlags() const
482{
483    return fMiscFlags;
484}
485
486inline XMLCh* SchemaElementDecl::getDefaultValue() const
487{
488    return fDefaultValue;
489}
490
491inline ComplexTypeInfo* SchemaElementDecl::getComplexTypeInfo() const
492{
493
494    return fComplexTypeInfo;
495}
496
497inline const SchemaAttDef* SchemaElementDecl::getAttWildCard() const {
498
499    return fAttWildCard;
500}
501
502inline SchemaAttDef* SchemaElementDecl::getAttWildCard() {
503
504    return fAttWildCard;
505}
506
507inline bool SchemaElementDecl::isGlobalDecl() const {
508
509    return (fEnclosingScope == Grammar::TOP_LEVEL_SCOPE);
510}
511
512inline SchemaElementDecl*
513SchemaElementDecl::getSubstitutionGroupElem() const {
514
515    return fSubstitutionGroupElem;
516}
517
518inline const XMLCh* SchemaElementDecl::getTypeName() const {
519    // removing fXsi* references would break DOMTypeInfo implementation completely;
520    // will have to wait for now
521    if (fXsiComplexTypeInfo)
522        return fXsiComplexTypeInfo->getTypeLocalName();
523    else if (fComplexTypeInfo)
524        return fComplexTypeInfo->getTypeLocalName();
525    else if(fXsiSimpleTypeInfo)
526        return fXsiSimpleTypeInfo->getTypeLocalName();
527    else if(fDatatypeValidator)
528        return fDatatypeValidator->getTypeLocalName();
529
530    //its anyType if we have not done validation on it or none of the above exist
531    return SchemaSymbols::fgATTVAL_ANYTYPE;
532}
533
534inline PSVIDefs::Complexity SchemaElementDecl::getTypeType() const {
535    if(getModelType() == Simple) {
536        return PSVIDefs::SIMPLE;
537    }
538    else {
539        return PSVIDefs::COMPLEX;
540    }
541}
542
543
544inline const XMLCh* SchemaElementDecl::getTypeUri() const {
545    // removing fXsi* references would break DOMTypeInfo implementation completely;
546    // will have to wait for now
547    if (fXsiComplexTypeInfo)
548        return fXsiComplexTypeInfo->getTypeUri();
549    else if (fComplexTypeInfo)
550        return fComplexTypeInfo->getTypeUri();
551    else if(fXsiSimpleTypeInfo)
552        return fXsiSimpleTypeInfo->getTypeUri();
553    else if(fDatatypeValidator)
554        return fDatatypeValidator->getTypeUri();
555
556    //its anyType if we have not done validation on it or none of the above exist
557    return SchemaSymbols::fgURI_SCHEMAFORSCHEMA;
558}
559
560inline const XMLCh* SchemaElementDecl::getMemberTypeName() const {
561    // removing fXsi* references would break DOMTypeInfo implementation completely;
562    // will have to wait for now
563    if(fXsiSimpleTypeInfo && fXsiSimpleTypeInfo->getType() == DatatypeValidator::Union)
564        return ((UnionDatatypeValidator*)fXsiSimpleTypeInfo)->getMemberTypeName();
565    else if(fDatatypeValidator && fDatatypeValidator->getType() == DatatypeValidator::Union)
566        return ((UnionDatatypeValidator*)fDatatypeValidator)->getMemberTypeName();
567    return 0;
568}
569
570inline const XMLCh* SchemaElementDecl::getMemberTypeUri() const {
571    // removing fXsi* references would break DOMTypeInfo implementation completely;
572    // will have to wait for now
573    if(fXsiSimpleTypeInfo && fXsiSimpleTypeInfo->getType() == DatatypeValidator::Union)
574        return ((UnionDatatypeValidator*)fXsiSimpleTypeInfo)->getMemberTypeUri();
575    if(fDatatypeValidator && fDatatypeValidator->getType() == DatatypeValidator::Union)
576        return ((UnionDatatypeValidator*)fDatatypeValidator)->getMemberTypeUri();
577
578    return 0;
579}
580
581inline bool SchemaElementDecl::getMemberTypeAnonymous() const {
582    // removing fXsi* references would break DOMTypeInfo implementation completely;
583    // will have to wait for now
584    if(fXsiSimpleTypeInfo && fXsiSimpleTypeInfo->getType() == DatatypeValidator::Union)
585        return ((UnionDatatypeValidator*)fXsiSimpleTypeInfo)->getMemberTypeAnonymous();
586    else if(fDatatypeValidator && fDatatypeValidator->getType() == DatatypeValidator::Union)
587        return ((UnionDatatypeValidator*)fDatatypeValidator)->getMemberTypeAnonymous();
588    return false;
589}
590
591inline bool SchemaElementDecl::isTypeDefinitionUnion() const {
592    // removing fXsi* references would break DOMTypeInfo implementation completely;
593    // will have to wait for now
594   if(fXsiSimpleTypeInfo && fXsiSimpleTypeInfo->getType() == DatatypeValidator::Union ||
595      fDatatypeValidator && fDatatypeValidator->getType() == DatatypeValidator::Union)
596       return true;
597    return false;
598}
599
600inline PSVIDefs::Validity SchemaElementDecl::getValidity() const {
601    return fValidity;
602}
603
604inline PSVIDefs::Validation SchemaElementDecl::getValidationAttempted() const {
605    if(!fHadContent)
606        return fValidation;
607
608    if(!fSeenNoValidation && fSeenValidation)
609        return PSVIDefs::FULL;
610    else if(fSeenNoValidation && !fSeenValidation)
611        return PSVIDefs::NONE;
612    else
613        return PSVIDefs::PARTIAL;
614}
615
616inline bool SchemaElementDecl::getTypeAnonymous() const {
617   
618    //REVISIT - since xsi type have to be accessed through names
619    //presumeably they cannot be anonymous
620   
621    if (fXsiComplexTypeInfo) {
622        return fXsiComplexTypeInfo->getAnonymous();
623    }
624    else if (fComplexTypeInfo) {
625        return fComplexTypeInfo->getAnonymous();
626    }
627    else if(fXsiSimpleTypeInfo) {
628        return fXsiSimpleTypeInfo->getAnonymous();
629    }
630    else if(fDatatypeValidator){
631        return fDatatypeValidator->getAnonymous();
632    }
633
634    return false;
635}
636
637inline const XMLCh* SchemaElementDecl::getDOMTypeInfoName() const {
638    // removing fXsi* references would break DOMTypeInfo implementation completely;
639    // will have to wait for now
640    if(fValidity != PSVIDefs::VALID) {
641        if(getTypeType() == PSVIDefs::SIMPLE)
642            return SchemaSymbols::fgDT_ANYSIMPLETYPE;
643        else
644            return SchemaSymbols::fgATTVAL_ANYTYPE;
645    }
646
647    if(getTypeAnonymous() || getMemberTypeAnonymous())
648        return 0;
649    if(fDatatypeValidator && fDatatypeValidator->getType() == DatatypeValidator::Union)
650        return ((UnionDatatypeValidator*)fDatatypeValidator)->getMemberTypeName();
651    if(fXsiSimpleTypeInfo && fXsiSimpleTypeInfo->getType() == DatatypeValidator::Union)
652        return ((UnionDatatypeValidator*)fXsiSimpleTypeInfo)->getMemberTypeName();
653    return getTypeName();
654}
655
656inline const XMLCh* SchemaElementDecl::getDOMTypeInfoUri() const {
657
658    // removing fXsi* references would break DOMTypeInfo implementation completely;
659    // will have to wait for now
660    if(fValidity != PSVIDefs::VALID)
661        return SchemaSymbols::fgURI_SCHEMAFORSCHEMA;
662
663    if(getTypeAnonymous() || getMemberTypeAnonymous())
664        return 0;
665
666    if(fDatatypeValidator && fDatatypeValidator->getType() == DatatypeValidator::Union)
667        return ((UnionDatatypeValidator*)fDatatypeValidator)->getMemberTypeUri();
668
669    if(fXsiSimpleTypeInfo && fXsiSimpleTypeInfo->getType() == DatatypeValidator::Union)
670        return ((UnionDatatypeValidator*)fXsiSimpleTypeInfo)->getMemberTypeUri();
671
672
673    return getTypeUri();
674}
675
676// ---------------------------------------------------------------------------
677//  SchemaElementDecl: Setter methods
678// ---------------------------------------------------------------------------
679inline void
680SchemaElementDecl::setElemId(unsigned int)
681{
682    //there is not getElemId so this is not needed. mark deprecated.
683    //fElemId = elemId;
684}
685
686inline void
687SchemaElementDecl::setModelType(const SchemaElementDecl::ModelTypes toSet)
688{
689    fModelType = toSet;
690}
691
692inline void
693SchemaElementDecl::setPSVIScope(const PSVIDefs::PSVIScope toSet)
694{
695    fPSVIScope = toSet;
696}
697
698inline void SchemaElementDecl::setDatatypeValidator(DatatypeValidator* newDatatypeValidator)
699{
700    fDatatypeValidator = newDatatypeValidator;
701}
702
703inline void SchemaElementDecl::setEnclosingScope(const int newEnclosingScope)
704{
705    fEnclosingScope = newEnclosingScope;
706}
707
708inline void SchemaElementDecl::setFinalSet(const int finalSet)
709{
710    fFinalSet = finalSet;
711}
712
713inline void SchemaElementDecl::setBlockSet(const int blockSet)
714{
715    fBlockSet = blockSet;
716}
717
718inline void SchemaElementDecl::setMiscFlags(const int flags)
719{
720    fMiscFlags = flags;
721}
722
723inline void SchemaElementDecl::setDefaultValue(const XMLCh* const value)
724{
725    if (fDefaultValue) {
726        getMemoryManager()->deallocate(fDefaultValue);//delete[] fDefaultValue;
727    }
728
729    fDefaultValue = XMLString::replicate(value, getMemoryManager());
730}
731
732inline void
733SchemaElementDecl::setComplexTypeInfo(ComplexTypeInfo* const typeInfo)
734{
735    fComplexTypeInfo = typeInfo;
736}
737
738inline void
739SchemaElementDecl::setXsiComplexTypeInfo(ComplexTypeInfo* const typeInfo)
740{
741    fXsiComplexTypeInfo = typeInfo;
742}
743
744inline void
745SchemaElementDecl::setXsiSimpleTypeInfo(const DatatypeValidator* const dtv)
746{
747    fXsiSimpleTypeInfo = dtv;
748}
749
750inline void
751SchemaElementDecl::setAttWildCard(SchemaAttDef* const attWildCard) {
752
753    if (fAttWildCard)
754        delete fAttWildCard;
755
756    fAttWildCard = attWildCard;
757}
758
759inline void
760SchemaElementDecl::setSubstitutionGroupElem(SchemaElementDecl* const elemDecl) {
761
762    fSubstitutionGroupElem = elemDecl;
763}
764
765inline void SchemaElementDecl::setValidity(PSVIDefs::Validity valid) {
766    fValidity = valid;
767}
768
769inline void SchemaElementDecl::setValidationAttempted(PSVIDefs::Validation validation) {
770    fValidation = validation;
771}
772
773inline void SchemaElementDecl::updateValidityFromAttribute(const SchemaAttDef *def) {
774
775    PSVIDefs::Validation curValAttemted = def->getValidationAttempted();
776    PSVIDefs::Validity curVal = def->getValidity();
777       
778    if(curValAttemted == PSVIDefs::NONE || curValAttemted == PSVIDefs::PARTIAL) {
779        fSeenNoValidation = true;
780        fValidity = PSVIDefs::UNKNOWN;
781    }
782    else {
783        fSeenValidation = true;
784    }
785       
786    if(curVal == PSVIDefs::INVALID)
787        fValidity = PSVIDefs::INVALID;
788
789    fHadContent = true;
790}
791
792inline void SchemaElementDecl::updateValidityFromElement(const XMLElementDecl *decl, Grammar::GrammarType eleGrammar) {
793
794    if (eleGrammar == Grammar::SchemaGrammarType) {                   
795        PSVIDefs::Validation curValAttemted = ((SchemaElementDecl *)decl)->getValidationAttempted();
796        PSVIDefs::Validity curVal = ((SchemaElementDecl *)decl)->getValidity();
797       
798        if(curValAttemted == PSVIDefs::NONE || curValAttemted == PSVIDefs::PARTIAL) {
799            fSeenNoValidation = true;
800            fValidity = PSVIDefs::UNKNOWN;
801        }
802        else {
803            fSeenValidation = true;
804        }
805       
806        if(curVal == PSVIDefs::INVALID)
807            fValidity = PSVIDefs::INVALID;
808    }
809
810    fHadContent = true;
811
812}
813
814inline void SchemaElementDecl::reset() {
815    if(fXsiSimpleTypeInfo && fXsiSimpleTypeInfo->getType() == DatatypeValidator::Union)
816        ((UnionDatatypeValidator *)fXsiSimpleTypeInfo)->reset();
817    if(fDatatypeValidator && fDatatypeValidator->getType() == DatatypeValidator::Union)
818        ((UnionDatatypeValidator *)fDatatypeValidator)->reset();
819
820    setXsiSimpleTypeInfo(0);
821    setXsiComplexTypeInfo(0);
822    fValidity = PSVIDefs::UNKNOWN;
823    fValidation = PSVIDefs::NONE;   
824    fSeenValidation = false;
825    fSeenNoValidation = false;
826    fHadContent = false;
827}
828
829// ---------------------------------------------------------------------------
830//  SchemaElementDecl: IC methods
831// ---------------------------------------------------------------------------
832inline void
833SchemaElementDecl::addIdentityConstraint(IdentityConstraint* const ic) {
834
835    if (!fIdentityConstraints) {
836        fIdentityConstraints = new (getMemoryManager()) RefVectorOf<IdentityConstraint>(16, true, getMemoryManager());
837    }
838
839    fIdentityConstraints->addElement(ic);
840}
841
842inline unsigned int SchemaElementDecl::getIdentityConstraintCount() const {
843
844    if (fIdentityConstraints) {
845        return fIdentityConstraints->size();
846    }
847
848    return 0;
849}
850
851inline IdentityConstraint*
852SchemaElementDecl::getIdentityConstraintAt(unsigned int index) const {
853
854    if (fIdentityConstraints) {
855        return fIdentityConstraints->elementAt(index);
856    }
857
858    return 0;
859}
860
861XERCES_CPP_NAMESPACE_END
862
863#endif
Note: See TracBrowser for help on using the repository browser.