source: NonGTP/Xerces/xercesc/framework/psvi/PSVIItem.hpp @ 188

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