source: icXML/icXML-devel/src/xercesc/validators/schema/GeneralAttributeCheck.hpp @ 2734

Last change on this file since 2734 was 2722, checked in by cameron, 7 years ago

Original Xerces files with import mods for icxercesc

File size: 7.9 KB
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: GeneralAttributeCheck.hpp 729944 2008-12-29 17:03:32Z amassari $
20 */
21
22#if !defined(XERCESC_INCLUDE_GUARD_GENERALATTRIBUTECHECK_HPP)
23#define XERCESC_INCLUDE_GUARD_GENERALATTRIBUTECHECK_HPP
24
25/**
26  * A general purpose class to check for valid values of attributes, as well
27  * as check for proper association with corresponding schema elements.
28  */
29
30// ---------------------------------------------------------------------------
31//  Includes
32// ---------------------------------------------------------------------------
33#include <icxercesc/util/RefHashTableOf.hpp>
34#include <icxercesc/util/ValueHashTableOf.hpp>
35#include <xercesc/validators/datatype/IDDatatypeValidator.hpp>
36#include <xercesc/framework/ValidationContext.hpp>
37
38XERCES_CPP_NAMESPACE_BEGIN
39
40// ---------------------------------------------------------------------------
41//  Forward declaration
42// ---------------------------------------------------------------------------
43class TraverseSchema;
44class DOMElement;
45class DOMNode;
46
47class VALIDATORS_EXPORT GeneralAttributeCheck : public XMemory
48{
49public:
50    // -----------------------------------------------------------------------
51    //  Constants
52    // -----------------------------------------------------------------------
53    //Elements
54    enum
55    {
56        E_All,
57        E_Annotation,
58        E_Any,
59        E_AnyAttribute,
60        E_Appinfo,
61        E_AttributeGlobal,
62        E_AttributeLocal,
63        E_AttributeRef,
64        E_AttributeGroupGlobal,
65        E_AttributeGroupRef,
66        E_Choice,
67        E_ComplexContent,
68        E_ComplexTypeGlobal,
69        E_ComplexTypeLocal,
70        E_Documentation,
71        E_ElementGlobal,
72        E_ElementLocal,
73        E_ElementRef,
74        E_Enumeration,
75        E_Extension,
76        E_Field,
77        E_FractionDigits,
78        E_GroupGlobal,
79        E_GroupRef,
80        E_Import,
81        E_Include,
82        E_Key,
83        E_KeyRef,
84        E_Length,
85        E_List,
86        E_MaxExclusive,
87        E_MaxInclusive,
88        E_MaxLength,
89        E_MinExclusive,
90        E_MinInclusive,
91        E_MinLength,
92        E_Notation,
93        E_Pattern,
94        E_Redefine,
95        E_Restriction,
96        E_Schema,
97        E_Selector,
98        E_Sequence,
99        E_SimpleContent,
100        E_SimpleTypeGlobal,
101        E_SimpleTypeLocal,
102        E_TotalDigits,
103        E_Union,
104        E_Unique,
105        E_WhiteSpace,
106
107        E_Count,
108        E_Invalid = -1
109    };
110
111    //Attributes
112    enum
113    {
114        A_Abstract,
115        A_AttributeFormDefault,
116        A_Base,
117        A_Block,
118        A_BlockDefault,
119        A_Default,
120        A_ElementFormDefault,
121        A_Final,
122        A_FinalDefault,
123        A_Fixed,
124        A_Form,
125        A_ID,
126        A_ItemType,
127        A_MaxOccurs,
128        A_MemberTypes,
129        A_MinOccurs,
130        A_Mixed,
131        A_Name,
132        A_Namespace,
133        A_Nillable,
134        A_ProcessContents,
135        A_Public,
136        A_Ref,
137        A_Refer,
138        A_SchemaLocation,
139        A_Source,
140        A_SubstitutionGroup,
141        A_System,
142        A_TargetNamespace,
143        A_Type,
144        A_Use,
145        A_Value,
146        A_Version,
147        A_XPath,
148
149        A_Count,
150        A_Invalid = -1
151    };
152
153    //Validators
154    enum {
155
156        DV_String = 0,
157        DV_AnyURI = 4,
158        DV_NonNegInt = 8,
159        DV_Boolean = 16,
160        DV_ID = 32,
161        DV_Form = 64,
162        DV_MaxOccurs = 128,
163        DV_MaxOccurs1 = 256,
164        DV_MinOccurs1 = 512,
165        DV_ProcessContents = 1024,
166        DV_Use = 2048,
167        DV_WhiteSpace = 4096,
168
169        DV_Mask = (DV_AnyURI | DV_NonNegInt | DV_Boolean | DV_ID | DV_Form |
170                   DV_MaxOccurs | DV_MaxOccurs1 | DV_MinOccurs1 |
171                   DV_ProcessContents | DV_Use | DV_WhiteSpace)
172    };
173
174    // generate element-attributes map table
175#if defined(NEED_TO_GEN_ELEM_ATT_MAP_TABLE)
176    static void initCharFlagTable();
177#endif
178
179    // -----------------------------------------------------------------------
180    //  Constructor/Destructor
181    // -----------------------------------------------------------------------
182    GeneralAttributeCheck(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
183    ~GeneralAttributeCheck();
184
185    // -----------------------------------------------------------------------
186    //  Getter methods
187    // -----------------------------------------------------------------------
188    unsigned short getFacetId(const XMLCh* const facetName, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
189
190    // -----------------------------------------------------------------------
191    //  Validation methods
192    // -----------------------------------------------------------------------
193    void checkAttributes(const DOMElement* const elem,
194                         const unsigned short elemContext,
195                         TraverseSchema* const schema,
196                         const bool isTopLevel = false,
197                         ValueVectorOf<DOMNode*>* const nonXSAttList = 0);
198
199private:
200    // -----------------------------------------------------------------------
201    //  Unimplemented constructors and operators
202    // -----------------------------------------------------------------------
203    GeneralAttributeCheck(const GeneralAttributeCheck&);
204    GeneralAttributeCheck& operator=(const GeneralAttributeCheck&);
205
206    // -----------------------------------------------------------------------
207    //  Validation methods
208    // -----------------------------------------------------------------------
209    void validate(const DOMElement* const elem, const XMLCh* const attName, const XMLCh* const attValue,
210                  const short dvIndex, TraverseSchema* const schema);
211
212    // -----------------------------------------------------------------------
213    //  Private Constants
214    // -----------------------------------------------------------------------
215    // optional vs. required attribute
216    enum {
217        Att_Required = 1,
218        Att_Optional = 2,
219        Att_Mask = 3
220    };
221
222    // -----------------------------------------------------------------------
223    //  Private data members
224    // -----------------------------------------------------------------------
225    static ValueHashTableOf<unsigned short>* fAttMap;
226    static ValueHashTableOf<unsigned short>* fFacetsMap;
227    static DatatypeValidator*                fNonNegIntDV;
228    static DatatypeValidator*                fBooleanDV;
229    static DatatypeValidator*                fAnyURIDV;
230    static unsigned short                    fgElemAttTable[E_Count][A_Count];
231    static const XMLCh*                      fAttNames[A_Count];
232    MemoryManager*                           fMemoryManager;
233    IDDatatypeValidator                      fIDValidator;
234
235private:
236    static void initialize();
237
238    friend class XMLInitializer;
239};
240
241
242// ---------------------------------------------------------------------------
243//  GeneralAttributeCheck: Getter methods
244// ---------------------------------------------------------------------------
245inline unsigned short
246GeneralAttributeCheck::getFacetId(const XMLCh* const facetName, MemoryManager* const manager) {
247
248    return fFacetsMap->get(facetName, manager);
249}
250
251XERCES_CPP_NAMESPACE_END
252
253#endif
254
255/**
256  * End of file GeneralAttributeCheck.hpp
257  */
258
Note: See TracBrowser for help on using the repository browser.