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: PSVIItem.hpp 568078 2007-08-21 11:43:25Z amassari $ |
---|
20 | */ |
---|
21 | |
---|
22 | #if !defined(PSVIITEM_HPP) |
---|
23 | #define PSVIITEM_HPP |
---|
24 | |
---|
25 | #include <xercesc/util/PlatformUtils.hpp> |
---|
26 | |
---|
27 | XERCES_CPP_NAMESPACE_BEGIN |
---|
28 | |
---|
29 | /** |
---|
30 | * Represent the PSVI contributions for one element or one attribute information item. |
---|
31 | * This is *always* owned by the validator /parser object from which |
---|
32 | * it is obtained. It is designed to be subclassed; subclasses will |
---|
33 | * specify under what conditions it may be relied upon to have meaningful contents. |
---|
34 | */ |
---|
35 | |
---|
36 | // forward declarations |
---|
37 | class XSTypeDefinition; |
---|
38 | class XSSimpleTypeDefinition; |
---|
39 | class XSValue; |
---|
40 | |
---|
41 | class XMLPARSER_EXPORT PSVIItem : public XMemory |
---|
42 | { |
---|
43 | public: |
---|
44 | |
---|
45 | enum VALIDITY_STATE { |
---|
46 | /** Validity value indicating that validation has either not |
---|
47 | been performed or that a strict assessment of validity could |
---|
48 | not be performed |
---|
49 | */ |
---|
50 | VALIDITY_NOTKNOWN = 0, |
---|
51 | |
---|
52 | /** Validity value indicating that validation has been strictly |
---|
53 | assessed and the element in question is invalid according to the |
---|
54 | rules of schema validation. |
---|
55 | */ |
---|
56 | VALIDITY_INVALID = 1, |
---|
57 | |
---|
58 | /** Validity value indicating that validation has been strictly |
---|
59 | assessed and the element in question is valid according to the rules |
---|
60 | of schema validation. |
---|
61 | */ |
---|
62 | VALIDITY_VALID = 2 |
---|
63 | }; |
---|
64 | |
---|
65 | enum ASSESSMENT_TYPE { |
---|
66 | /** Validation status indicating that schema validation has been |
---|
67 | performed and the element in question has specifically been skipped. |
---|
68 | */ |
---|
69 | VALIDATION_NONE = 0, |
---|
70 | |
---|
71 | /** Validation status indicating that schema validation has been |
---|
72 | performed on the element in question under the rules of lax validation. |
---|
73 | */ |
---|
74 | VALIDATION_PARTIAL = 1, |
---|
75 | |
---|
76 | /** Validation status indicating that full schema validation has been |
---|
77 | performed on the element. */ |
---|
78 | VALIDATION_FULL = 2 |
---|
79 | }; |
---|
80 | |
---|
81 | // Constructors and Destructor |
---|
82 | // ----------------------------------------------------------------------- |
---|
83 | /** @name Constructors */ |
---|
84 | //@{ |
---|
85 | |
---|
86 | /** |
---|
87 | * The default constructor |
---|
88 | * |
---|
89 | * @param manager The configurable memory manager |
---|
90 | */ |
---|
91 | PSVIItem(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); |
---|
92 | |
---|
93 | //@}; |
---|
94 | |
---|
95 | /** @name Destructor */ |
---|
96 | //@{ |
---|
97 | virtual ~PSVIItem(); |
---|
98 | //@} |
---|
99 | |
---|
100 | //--------------------- |
---|
101 | /** @name PSVIItem methods */ |
---|
102 | |
---|
103 | //@{ |
---|
104 | |
---|
105 | /** |
---|
106 | * [validation context] |
---|
107 | * |
---|
108 | * @return A string identifying the nearest ancestor element |
---|
109 | * information item with a [schema information] property |
---|
110 | * (or this element item itself if it has such a property) |
---|
111 | * (form to be determined) |
---|
112 | * @see <a href="http://www.w3.org/TR/xmlschema-1/#e-validation_context">XML Schema Part 1: Structures [validation context]</a> |
---|
113 | */ |
---|
114 | const XMLCh *getValidationContext(); |
---|
115 | |
---|
116 | /** |
---|
117 | * Determine the validity of the node with respect |
---|
118 | * to the validation being attempted |
---|
119 | * |
---|
120 | * @return return the [validity] property. Possible values are: |
---|
121 | * VALIDITY_UNKNOWN, VALIDITY_INVALID, VALIDITY_VALID |
---|
122 | */ |
---|
123 | VALIDITY_STATE getValidity() const; |
---|
124 | |
---|
125 | /** |
---|
126 | * Determines the extent to which the item has been validated |
---|
127 | * |
---|
128 | * @return return the [validation attempted] property. The possible values are |
---|
129 | * VALIDATION_NONE, VALIDATION_ORDERED_PARTIAL and VALIDATION_FULL |
---|
130 | */ |
---|
131 | ASSESSMENT_TYPE getValidationAttempted() const; |
---|
132 | |
---|
133 | /** |
---|
134 | * A list of error codes generated from validation attempts. |
---|
135 | * Need to find all the possible subclause reports that need reporting |
---|
136 | * |
---|
137 | * @return list of error codes |
---|
138 | */ |
---|
139 | /*** |
---|
140 | const XMLCh ** getErrorCodes(); |
---|
141 | ****/ |
---|
142 | |
---|
143 | /** |
---|
144 | * [schema normalized value] |
---|
145 | * |
---|
146 | * @see <a href="http://www.w3.org/TR/xmlschema-1/#e-schema_normalized_value">XML Schema Part 1: Structures [schema normalized value]</a> |
---|
147 | * @return the normalized value of this item after validation |
---|
148 | */ |
---|
149 | const XMLCh *getSchemaNormalizedValue(); |
---|
150 | |
---|
151 | /** |
---|
152 | * An item isomorphic to the type definition used to validate this element. |
---|
153 | * |
---|
154 | * @return a type declaration |
---|
155 | */ |
---|
156 | virtual XSTypeDefinition *getTypeDefinition() = 0; |
---|
157 | |
---|
158 | /** |
---|
159 | * If and only if that type definition is a simple type definition |
---|
160 | * with {variety} union, or a complex type definition whose {content type} |
---|
161 | * is a simple thype definition with {variety} union, then an item isomorphic |
---|
162 | * to that member of the union's {member type definitions} which actually |
---|
163 | * validated the element item's normalized value. |
---|
164 | * |
---|
165 | * @return a simple type declaration |
---|
166 | */ |
---|
167 | virtual XSSimpleTypeDefinition *getMemberTypeDefinition() = 0; |
---|
168 | |
---|
169 | /** |
---|
170 | * [schema default] |
---|
171 | * |
---|
172 | * @return The canonical lexical representation of the declaration's {value constraint} value. |
---|
173 | * @see <a href="http://www.w3.org/TR/xmlschema-1/#e-schema_default">XML Schema Part 1: Structures [schema default]</a> |
---|
174 | */ |
---|
175 | const XMLCh *getSchemaDefault(); |
---|
176 | |
---|
177 | /** |
---|
178 | * [schema specified] |
---|
179 | * @see <a href="http://www.w3.org/TR/xmlschema-1/#e-schema_specified">XML Schema Part 1: Structures [schema specified]</a> |
---|
180 | * @return true - value was specified in schema, false - value comes from the infoset |
---|
181 | */ |
---|
182 | bool getIsSchemaSpecified() const; |
---|
183 | |
---|
184 | /** |
---|
185 | * Return the canonical representation of this value. |
---|
186 | * Note that, formally, this is not a PSVI property. |
---|
187 | * @return string representing the canonical representation, if this item |
---|
188 | * was validated by a simple type definition for which canonical |
---|
189 | * representations of values are defined. |
---|
190 | */ |
---|
191 | const XMLCh *getCanonicalRepresentation() const; |
---|
192 | |
---|
193 | //@} |
---|
194 | |
---|
195 | /** |
---|
196 | * |
---|
197 | * Get actual value in the form of XSValue, |
---|
198 | * caller needs to delete the object returned. |
---|
199 | * |
---|
200 | * @return an XSValue |
---|
201 | */ |
---|
202 | virtual XSValue *getActualValue() const; |
---|
203 | |
---|
204 | //---------------------------------- |
---|
205 | /** methods needed by implementation */ |
---|
206 | |
---|
207 | //@{ |
---|
208 | |
---|
209 | void setValidationAttempted(PSVIItem::ASSESSMENT_TYPE attemptType); |
---|
210 | void setValidity(PSVIItem::VALIDITY_STATE validity); |
---|
211 | |
---|
212 | /** reset the object |
---|
213 | * @param validationContext corresponds to schema validation context property |
---|
214 | * @param normalizedValue corresponds to schema normalized value property |
---|
215 | * @param validityState state of item's validity |
---|
216 | * @param assessmentType type of assessment carried out on item |
---|
217 | */ |
---|
218 | void reset( |
---|
219 | const XMLCh* const validationContext |
---|
220 | , const XMLCh* const normalizedValue |
---|
221 | , const VALIDITY_STATE validityState |
---|
222 | , const ASSESSMENT_TYPE assessmentType |
---|
223 | ); |
---|
224 | //@} |
---|
225 | private: |
---|
226 | |
---|
227 | // ----------------------------------------------------------------------- |
---|
228 | // Unimplemented constructors and operators |
---|
229 | // ----------------------------------------------------------------------- |
---|
230 | PSVIItem(const PSVIItem&); |
---|
231 | PSVIItem & operator=(const PSVIItem &); |
---|
232 | |
---|
233 | |
---|
234 | protected: |
---|
235 | // ----------------------------------------------------------------------- |
---|
236 | // data members |
---|
237 | // ----------------------------------------------------------------------- |
---|
238 | // fMemoryManager: |
---|
239 | // used for any memory allocations |
---|
240 | // fValidationContext |
---|
241 | // corresponds to the schema [validation context] property |
---|
242 | // fNormalizedValue |
---|
243 | // The schema normalized value (when present) |
---|
244 | // fDefaultValue |
---|
245 | // default value specified in the schema, if any |
---|
246 | // fCanonicalValue |
---|
247 | // canonicalized version of normalizedValue |
---|
248 | // fValidityState |
---|
249 | // Whether this item is valid or not |
---|
250 | // fAssessmentType |
---|
251 | // The kind of assessment that produced the given validity outcome |
---|
252 | // fIsSpecified |
---|
253 | // Whether this item exists because a default was specified in the schema |
---|
254 | // fType |
---|
255 | // type responsible for validating this item |
---|
256 | // fMemberType |
---|
257 | // If fType is a union type, the member type that validated this item |
---|
258 | MemoryManager* const fMemoryManager; |
---|
259 | const XMLCh* fValidationContext; |
---|
260 | const XMLCh* fNormalizedValue; |
---|
261 | const XMLCh* fDefaultValue; |
---|
262 | XMLCh* fCanonicalValue; |
---|
263 | VALIDITY_STATE fValidityState; |
---|
264 | ASSESSMENT_TYPE fAssessmentType; |
---|
265 | bool fIsSpecified; |
---|
266 | XSTypeDefinition * fType; |
---|
267 | XSSimpleTypeDefinition* fMemberType; |
---|
268 | }; |
---|
269 | |
---|
270 | inline PSVIItem::~PSVIItem() {} |
---|
271 | |
---|
272 | inline const XMLCh *PSVIItem::getValidationContext() |
---|
273 | { |
---|
274 | return fValidationContext; |
---|
275 | } |
---|
276 | |
---|
277 | inline const XMLCh* PSVIItem::getSchemaNormalizedValue() |
---|
278 | { |
---|
279 | return fNormalizedValue; |
---|
280 | } |
---|
281 | |
---|
282 | inline const XMLCh* PSVIItem::getSchemaDefault() |
---|
283 | { |
---|
284 | return fDefaultValue; |
---|
285 | } |
---|
286 | |
---|
287 | inline const XMLCh* PSVIItem::getCanonicalRepresentation() const |
---|
288 | { |
---|
289 | return fCanonicalValue; |
---|
290 | } |
---|
291 | |
---|
292 | inline PSVIItem::VALIDITY_STATE PSVIItem::getValidity() const |
---|
293 | { |
---|
294 | return fValidityState; |
---|
295 | } |
---|
296 | |
---|
297 | inline bool PSVIItem::getIsSchemaSpecified() const |
---|
298 | { |
---|
299 | return fIsSpecified; |
---|
300 | } |
---|
301 | |
---|
302 | inline PSVIItem::ASSESSMENT_TYPE PSVIItem::getValidationAttempted() const |
---|
303 | { |
---|
304 | return fAssessmentType; |
---|
305 | } |
---|
306 | |
---|
307 | XERCES_CPP_NAMESPACE_END |
---|
308 | |
---|
309 | #endif |
---|