source: trunk/VUT/GtpVisibilityPreprocessor/support/xerces/include/xercesc/validators/schema/SchemaAttDef.hpp @ 358

Revision 358, 18.0 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: SchemaAttDef.hpp,v $
19 * Revision 1.14  2004/09/20 14:47:13  amassari
20 * Mark some methods as deprecated
21 *
22 * Revision 1.13  2004/09/08 13:56:56  peiyongz
23 * Apache License Version 2.0
24 *
25 * Revision 1.12  2004/01/29 11:52:31  cargilld
26 * Code cleanup changes to get rid of various compiler diagnostic messages.
27 *
28 * Revision 1.11  2003/12/24 17:42:03  knoaman
29 * Misc. PSVI updates
30 *
31 * Revision 1.10  2003/12/17 20:50:35  knoaman
32 * PSVI: fix for annotation of attributes in attributeGroup/derived types
33 *
34 * Revision 1.9  2003/11/24 05:13:41  neilg
35 * update method documentation
36 *
37 * Revision 1.8  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.7  2003/10/10 16:25:40  peiyongz
43 * Implementation of Serialization/Deserialization
44 *
45 * Revision 1.6  2003/05/18 14:02:07  knoaman
46 * Memory manager implementation: pass per instance manager.
47 *
48 * Revision 1.5  2003/05/16 21:43:21  knoaman
49 * Memory manager implementation: Modify constructors to pass in the memory manager.
50 *
51 * Revision 1.4  2003/02/06 13:51:55  gareth
52 * fixed bug with multiple attributes being validated by the same union type.
53 *
54 * Revision 1.3  2003/01/29 19:47:16  gareth
55 * added DOMTypeInfo and some PSVI methods
56 *
57 * Revision 1.2  2002/11/04 14:49:41  tng
58 * C++ Namespace Support.
59 *
60 * Revision 1.1.1.1  2002/02/01 22:22:46  peiyongz
61 * sane_include
62 *
63 * Revision 1.6  2001/08/10 12:34:25  knoaman
64 * Fix compilation error.
65 *
66 * Revision 1.5  2001/08/09 15:23:16  knoaman
67 * add support for <anyAttribute> declaration.
68 *
69 * Revision 1.4  2001/07/31 15:26:54  knoaman
70 * Added support for <attributeGroup>.
71 *
72 * Revision 1.3  2001/05/11 17:17:41  tng
73 * Schema: DatatypeValidator fixes.  By Pei Yong Zhang.
74 *
75 * Revision 1.2  2001/05/11 13:27:34  tng
76 * Copyright update.
77 *
78 * Revision 1.1  2001/02/27 18:48:22  tng
79 * Schema: Add SchemaAttDef, SchemaElementDecl, SchemaAttDefList.
80 *
81 */
82#if !defined(SCHEMAATTDEF_HPP)
83#define SCHEMAATTDEF_HPP
84
85#include <xercesc/util/XMLString.hpp>
86#include <xercesc/framework/XMLAttDef.hpp>
87#include <xercesc/util/ValueVectorOf.hpp>
88#include <xercesc/validators/datatype/DatatypeValidator.hpp>
89#include <xercesc/validators/datatype/UnionDatatypeValidator.hpp>
90#include <xercesc/validators/schema/PSVIDefs.hpp>
91
92XERCES_CPP_NAMESPACE_BEGIN
93
94class DatatypeValidator;
95class QName;
96class ComplexTypeInfo;
97//
98//  This class is a derivative of the core XMLAttDef class. This class adds
99//  any Schema specific data members and provides Schema specific implementations
100//  of any underlying attribute def virtual methods.
101//
102class VALIDATORS_EXPORT SchemaAttDef : public XMLAttDef
103{
104public :
105    // -----------------------------------------------------------------------
106    //  Constructors and Destructors
107    // -----------------------------------------------------------------------
108    SchemaAttDef(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
109    SchemaAttDef
110    (
111          const XMLCh* const           prefix
112        , const XMLCh* const           localPart
113        , const int                    uriId
114        , const XMLAttDef::AttTypes    type = CData
115        , const XMLAttDef::DefAttTypes defType = Implied
116        , MemoryManager* const         manager = XMLPlatformUtils::fgMemoryManager
117    );
118    SchemaAttDef
119    (
120          const XMLCh* const           prefix
121        , const XMLCh* const           localPart
122        , const int                    uriId
123        , const XMLCh* const           attValue
124        , const XMLAttDef::AttTypes    type
125        , const XMLAttDef::DefAttTypes defType
126        , const XMLCh* const           enumValues = 0
127        , MemoryManager* const         manager = XMLPlatformUtils::fgMemoryManager
128    );
129    SchemaAttDef
130    (
131          const SchemaAttDef*                   other
132    );
133    virtual ~SchemaAttDef();
134
135    // -----------------------------------------------------------------------
136    //  Implementation of the XMLAttDef interface
137    // -----------------------------------------------------------------------
138    virtual const XMLCh* getFullName() const;
139    virtual void reset();
140
141
142    // ----------------------------------------------------------------------
143    // Partial implementation of PSVI
144    // The values these methods return are only accurate until the DOMAttr
145    // is created that uses the values. After this a clean up method is called
146    // and the SchemaAttDef may be used again.
147    // note that some of this information has dependancies. For example,
148    // if something is not valid then the information returned by the other
149    // calls may be meaningless
150    // See http://www.w3.org/TR/xmlschema-1/ for detailed information
151    // ----------------------------------------------------------------------
152
153    /**
154     * The appropriate case among the following:
155     * 1 If it was strictly assessed, then the appropriate case among the following:
156     * 1.1 If it was valid as defined by Attribute Locally Valid (3.2.4), then valid;
157     * 1.2 otherwise invalid.
158     * 2 otherwise notKnown.
159     * @deprecated
160     */
161    PSVIDefs::Validity getValidity() const;
162
163    /**
164     * The appropriate case among the following:
165     * 1 If it was strictly assessed, then full;
166     * 2 otherwise none.
167     * @deprecated
168     */
169    PSVIDefs::Validation getValidationAttempted() const;
170
171    /**
172     * @return the complexity. Always simple for attrs
173     * @deprecated
174     */
175    PSVIDefs::Complexity getTypeType() const;
176
177    /**
178     * The target namespace of the type definition.
179     * @deprecated
180     */
181    const XMLCh* getTypeUri() const;
182
183    /**
184     * The {name} of the type definition, if it is not absent.
185     * @deprecated
186     */
187    const XMLCh* getTypeName() const;
188
189    /**
190     * true if the {name} of the type definition is absent, otherwise false.
191     * @deprecated
192     */
193    bool getTypeAnonymous() const;
194
195    /**
196     * If this method returns true and validity is VALID then the next three
197     * produce accurate results
198     * @return true if the element is validated using a union type
199     * @deprecated
200     */
201    bool isTypeDefinitionUnion() const;
202
203    /**
204     * The {target namespace} of the actual member type definition.
205     * @deprecated
206     */
207    const XMLCh* getMemberTypeUri() const;
208
209    /**
210     * @return true if the {name} of the actual member type definition is absent, otherwise false.
211     * @deprecated
212     */
213    bool getMemberTypeAnonymous() const;
214
215    /**
216     * @return the {name} of the actual member type definition, if it is not absent.
217     * @deprecated
218     */
219    const XMLCh* getMemberTypeName() const;
220
221    /*
222     * @deprecated
223     */
224    virtual const XMLCh* getDOMTypeInfoUri() const;
225    /*
226     * @deprecated
227     */
228    virtual const XMLCh* getDOMTypeInfoName() const;
229   
230   
231
232    // -----------------------------------------------------------------------
233    //  Getter methods
234    // -----------------------------------------------------------------------
235    unsigned int getElemId() const;
236    QName* getAttName() const;
237    DatatypeValidator* getDatatypeValidator() const;
238    ValueVectorOf<unsigned int>* getNamespaceList() const;
239    const SchemaAttDef* getBaseAttDecl() const;
240    SchemaAttDef* getBaseAttDecl();
241    PSVIDefs::PSVIScope getPSVIScope() const;
242
243    /*
244     * @deprecated
245     */
246    ComplexTypeInfo* getEnclosingCT() const;
247
248    // -----------------------------------------------------------------------
249    //  Setter methods
250    // -----------------------------------------------------------------------
251    void setElemId(const unsigned int newId);
252    void setAttName
253    (
254        const XMLCh* const        prefix
255       ,const XMLCh* const        localPart
256       ,const int                 uriId = -1
257    );
258    void setDatatypeValidator(DatatypeValidator* newDatatypeValidator);
259    /*
260     * @deprecated
261     */
262    void setAnyDatatypeValidator(DatatypeValidator* newDatatypeValidator);
263    void setBaseAttDecl(SchemaAttDef* const attDef);
264    void setPSVIScope(const PSVIDefs::PSVIScope toSet);
265
266    /*
267     * @deprecated
268     */
269    void setMembertypeValidator(const DatatypeValidator* newDatatypeValidator);
270    void setNamespaceList(const ValueVectorOf<unsigned int>* const toSet);
271    void resetNamespaceList();
272    /*
273     * @deprecated
274     */
275    void setValidity(PSVIDefs::Validity valid);
276    /*
277     * @deprecated
278     */
279    void setValidationAttempted(PSVIDefs::Validation validation);
280    void setEnclosingCT(ComplexTypeInfo* complexTypeInfo);
281    /***
282     * Support for Serialization/De-serialization
283     ***/
284    DECL_XSERIALIZABLE(SchemaAttDef)
285
286private :
287    // -----------------------------------------------------------------------
288    //  Unimplemented constructors and operators
289    // -----------------------------------------------------------------------
290    SchemaAttDef(const SchemaAttDef&);
291    SchemaAttDef& operator=(const SchemaAttDef&);
292
293    // -----------------------------------------------------------------------
294    //  Private data members
295    //
296    //  fElemId
297    //      This is the id of the element (the id is into the element decl
298    //      pool) of the element this attribute def said it belonged to.
299    //      This is used later to link back to the element, mostly for
300    //      validation purposes.
301    //
302    //  fAttName
303    //      This is the name of the attribute.
304    //
305    //  fDatatypeValidator
306    //      The DatatypeValidator used to validate this attribute type.
307    //
308    //  fAnyDatatypeValidator
309    //      Tempory storage for the DatatypeValidator used to validate an any
310    //
311    //  fMemberTypeValidator
312    //      Tempory storage used when the validator being used is of union type.
313    //      This stores the actual member validator used to validate.
314    //
315    //  fNamespaceList
316    //      The list of namespace values for a wildcard attribute
317    //
318    //  fValidity
319    //      After this attr has been validated this is its validity
320    //
321    //  fValidation
322    //      The type of validation that happened to this attr
323    //
324    //  fBaseAttDecl
325    //      The base attribute declaration that this attribute is based on
326    //      NOTE: we do not have a notion of attribute use, so in the case
327    //      of ref'd attributes and inherited attributes, we make a copy
328    //      of the actual attribute declaration. The fBaseAttDecl stores that
329    //      declaration, and will be helpful when we build the XSModel (i.e
330    //      easy access the XSAnnotation object).
331    // -----------------------------------------------------------------------
332    unsigned int                 fElemId;
333    QName*                       fAttName;
334    DatatypeValidator*           fDatatypeValidator;
335    DatatypeValidator*           fAnyDatatypeValidator;
336    const DatatypeValidator*     fMemberTypeValidator;
337    ValueVectorOf<unsigned int>* fNamespaceList;
338    PSVIDefs::Validity           fValidity;
339    PSVIDefs::Validation         fValidation;
340    PSVIDefs::PSVIScope          fPSVIScope;
341    SchemaAttDef*                fBaseAttDecl;
342};
343
344
345// ---------------------------------------------------------------------------
346//  SchemaAttDef: Getter methods
347// ---------------------------------------------------------------------------
348inline unsigned int SchemaAttDef::getElemId() const
349{
350    return fElemId;
351}
352
353
354inline QName* SchemaAttDef::getAttName() const
355{
356    return fAttName;
357}
358
359inline DatatypeValidator* SchemaAttDef::getDatatypeValidator() const
360{
361    return fDatatypeValidator;
362}
363
364inline void SchemaAttDef::setValidity(PSVIDefs::Validity valid) {
365    fValidity = valid;
366}
367
368inline void SchemaAttDef::setValidationAttempted(PSVIDefs::Validation validation) {
369    fValidation = validation;
370}
371
372
373inline const XMLCh* SchemaAttDef::getTypeName() const {
374    if(fAnyDatatypeValidator)
375        return fAnyDatatypeValidator->getTypeLocalName();
376    else if(fDatatypeValidator)
377        return fDatatypeValidator->getTypeLocalName();
378
379    //its anySimpleType if we have not done validation on it
380    if(getValidationAttempted() == PSVIDefs::NONE)
381        return SchemaSymbols::fgDT_ANYSIMPLETYPE;
382
383
384    return 0;
385}
386
387inline PSVIDefs::Complexity SchemaAttDef::getTypeType() const {
388    return PSVIDefs::SIMPLE;
389}
390
391inline const XMLCh* SchemaAttDef::getTypeUri() const {
392    if(fAnyDatatypeValidator)
393        return fAnyDatatypeValidator->getTypeUri();
394    else if(fDatatypeValidator)
395        return fDatatypeValidator->getTypeUri();
396
397    //its anySimpleType if we have not done validation on it
398    if(getValidationAttempted() == PSVIDefs::NONE)
399        return SchemaSymbols::fgURI_SCHEMAFORSCHEMA;
400
401    return 0;
402}
403
404
405inline const XMLCh* SchemaAttDef::getMemberTypeName() const {
406    if(fMemberTypeValidator)
407        return fMemberTypeValidator->getTypeLocalName();
408    return 0;
409}
410
411inline const XMLCh* SchemaAttDef::getMemberTypeUri() const {
412    if(fMemberTypeValidator)
413        return fMemberTypeValidator->getTypeUri();
414    return 0;
415}
416
417inline PSVIDefs::Validity SchemaAttDef::getValidity() const {
418    return fValidity;
419}
420
421inline PSVIDefs::Validation SchemaAttDef::getValidationAttempted() const {
422    return fValidation;
423}
424
425inline const XMLCh* SchemaAttDef::getDOMTypeInfoName() const {
426    if(fValidity != PSVIDefs::VALID)
427        return SchemaSymbols::fgDT_ANYSIMPLETYPE;
428    if(getTypeAnonymous() || getMemberTypeAnonymous())
429        return 0;
430    if(fMemberTypeValidator)
431        return getMemberTypeName();
432
433    return getTypeName();
434}
435
436inline const XMLCh* SchemaAttDef::getDOMTypeInfoUri() const {
437    if(fValidity != PSVIDefs::VALID)
438        return SchemaSymbols::fgURI_SCHEMAFORSCHEMA;
439    if(getTypeAnonymous() || getMemberTypeAnonymous())
440        return 0;
441    if(fMemberTypeValidator)
442        return getMemberTypeUri();
443    return getTypeUri();
444}
445
446inline bool SchemaAttDef::getTypeAnonymous() const {
447    if(fAnyDatatypeValidator)
448        return fAnyDatatypeValidator->getAnonymous();
449    else if(fDatatypeValidator)
450        return fDatatypeValidator->getAnonymous();
451
452    return false;
453}
454
455inline bool SchemaAttDef::getMemberTypeAnonymous() const {
456    if(fMemberTypeValidator)
457        return fMemberTypeValidator->getAnonymous();
458
459    return false;
460}
461
462inline bool SchemaAttDef::isTypeDefinitionUnion() const {
463   if(fAnyDatatypeValidator && fAnyDatatypeValidator->getType() == DatatypeValidator::Union ||
464      fDatatypeValidator && fDatatypeValidator->getType() == DatatypeValidator::Union)
465       return true;
466    return false;
467}
468
469inline ValueVectorOf<unsigned int>*
470SchemaAttDef::getNamespaceList() const {
471    return fNamespaceList;
472}
473
474inline ComplexTypeInfo* SchemaAttDef::getEnclosingCT() const
475{
476    return 0;
477}
478
479inline SchemaAttDef* SchemaAttDef::getBaseAttDecl()
480{
481    return fBaseAttDecl;
482}
483
484inline const SchemaAttDef* SchemaAttDef::getBaseAttDecl() const
485{
486    return fBaseAttDecl;
487}
488
489inline PSVIDefs::PSVIScope SchemaAttDef::getPSVIScope() const
490{
491    return fPSVIScope;
492}
493
494// ---------------------------------------------------------------------------
495//  SchemaAttDef: Setter methods
496// ---------------------------------------------------------------------------
497inline void SchemaAttDef::setElemId(const unsigned int newId)
498{
499    fElemId = newId;
500}
501
502inline void SchemaAttDef::setDatatypeValidator(DatatypeValidator* newDatatypeValidator)
503{
504    fDatatypeValidator = newDatatypeValidator;
505}
506
507inline void SchemaAttDef::setAnyDatatypeValidator(DatatypeValidator* newDatatypeValidator)
508{
509    fAnyDatatypeValidator = newDatatypeValidator;
510}
511
512inline void SchemaAttDef::setMembertypeValidator(const DatatypeValidator* newDatatypeValidator)
513{
514    fMemberTypeValidator = newDatatypeValidator;
515}
516
517inline void SchemaAttDef::resetNamespaceList() {
518
519    if (fNamespaceList && fNamespaceList->size()) {
520        fNamespaceList->removeAllElements();
521    }
522}
523
524inline void SchemaAttDef::setNamespaceList(const ValueVectorOf<unsigned int>* const toSet) {
525
526    if (toSet && toSet->size()) {
527
528        if (fNamespaceList) {
529            *fNamespaceList = *toSet;
530        }
531        else {
532            fNamespaceList = new (getMemoryManager()) ValueVectorOf<unsigned int>(*toSet);
533        }
534    }
535    else  {
536        resetNamespaceList();
537    }
538}
539
540inline void SchemaAttDef::reset() {
541    if(fAnyDatatypeValidator && fAnyDatatypeValidator->getType() == DatatypeValidator::Union)
542        ((UnionDatatypeValidator *)fAnyDatatypeValidator)->reset();
543    else if(fDatatypeValidator && fDatatypeValidator->getType() == DatatypeValidator::Union)
544        ((UnionDatatypeValidator *)fDatatypeValidator)->reset();
545    fAnyDatatypeValidator = 0;
546    fMemberTypeValidator = 0;
547    fValidity = PSVIDefs::UNKNOWN;
548    fValidation = PSVIDefs::NONE;   
549}
550
551inline void SchemaAttDef::setEnclosingCT(ComplexTypeInfo*)
552{
553}
554
555inline void SchemaAttDef::setBaseAttDecl(SchemaAttDef* const attDef)
556{
557    fBaseAttDecl = attDef;
558}
559
560inline void SchemaAttDef::setPSVIScope(const PSVIDefs::PSVIScope toSet)
561{
562    fPSVIScope = toSet;
563}
564
565XERCES_CPP_NAMESPACE_END
566
567#endif
Note: See TracBrowser for help on using the repository browser.