source: obsolete/tags/VUT/0.4/GtpVisibilityPreprocessor/support/xerces/include/xercesc/framework/psvi/PSVIItem.hpp @ 358

Revision 358, 11.3 KB checked in by bittner, 19 years ago (diff)

xerces added

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