source: NonGTP/Xerces/xercesc/validators/schema/SchemaElementDecl.hpp @ 188

Revision 188, 36.4 KB checked in by mattausch, 19 years ago (diff)

added xercesc to support

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