00001 /*
00002 * The Apache Software License, Version 1.1
00003 *
00004 * Copyright (c) 2003 The Apache Software Foundation. All rights
00005 * reserved.
00006 *
00007 * Redistribution and use in source and binary forms, with or without
00008 * modification, are permitted provided that the following conditions
00009 * are met:
00010 *
00011 * 1. Redistributions of source code must retain the above copyright
00012 * notice, this list of conditions and the following disclaimer.
00013 *
00014 * 2. Redistributions in binary form must reproduce the above copyright
00015 * notice, this list of conditions and the following disclaimer in
00016 * the documentation and/or other materials provided with the
00017 * distribution.
00018 *
00019 * 3. The end-user documentation included with the redistribution,
00020 * if any, must include the following acknowledgment:
00021 * "This product includes software developed by the
00022 * Apache Software Foundation (http://www.apache.org/)."
00023 * Alternately, this acknowledgment may appear in the software itself,
00024 * if and wherever such third-party acknowledgments normally appear.
00025 *
00026 * 4. The names "Xerces" and "Apache Software Foundation" must
00027 * not be used to endorse or promote products derived from this
00028 * software without prior written permission. For written
00029 * permission, please contact apache\@apache.org.
00030 *
00031 * 5. Products derived from this software may not be called "Apache",
00032 * nor may "Apache" appear in their name, without prior written
00033 * permission of the Apache Software Foundation.
00034 *
00035 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
00036 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00037 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00038 * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
00039 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00040 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00041 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
00042 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00043 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00044 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
00045 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00046 * SUCH DAMAGE.
00047 * ====================================================================
00048 *
00049 * This software consists of voluntary contributions made by many
00050 * individuals on behalf of the Apache Software Foundation, and was
00051 * originally based on software copyright (c) 1999, International
00052 * Business Machines, Inc., http://www.ibm.com . For more information
00053 * on the Apache Software Foundation, please see
00054 * <http://www.apache.org/>.
00055 */
00056
00057 /*
00058 * $Log: PSVIItem.hpp,v $
00059 * Revision 1.8 2003/11/28 21:18:31 knoaman
00060 * Make use of canonical representation in PSVIElement
00061 *
00062 * Revision 1.7 2003/11/27 17:58:59 neilg
00063 * fix compilation error
00064 *
00065 * Revision 1.6 2003/11/27 16:44:59 neilg
00066 * implement isSpecified; thanks to Pete Lloyd
00067 *
00068 * Revision 1.5 2003/11/27 06:10:32 neilg
00069 * PSVIAttribute implementation
00070 *
00071 * Revision 1.4 2003/11/25 16:14:28 neilg
00072 * move inlines into PSVIItem.hpp
00073 *
00074 * Revision 1.3 2003/11/21 22:34:45 neilg
00075 * More schema component model implementation, thanks to David Cargill.
00076 * In particular, this cleans up and completes the XSModel, XSNamespaceItem,
00077 * XSAttributeDeclaration and XSAttributeGroup implementations.
00078 *
00079 * Revision 1.2 2003/11/06 15:30:04 neilg
00080 * 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.
00081 *
00082 * Revision 1.1 2003/09/16 14:33:36 neilg
00083 * PSVI/schema component model classes, with Makefile/configuration changes necessary to build them
00084 *
00085 */
00086
00087 #if !defined(PSVIITEM_HPP)
00088 #define PSVIITEM_HPP
00089
00090 #include <xercesc/util/PlatformUtils.hpp>
00091
00092 XERCES_CPP_NAMESPACE_BEGIN
00093
00101 // forward declarations
00102 class XSTypeDefinition;
00103 class XSSimpleTypeDefinition;
00104
00105 class PSVIItem : public XMemory
00106 {
00107 public:
00108
00109 enum VALIDITY_STATE {
00114 VALIDITY_NOTKNOWN = 0,
00115
00120 VALIDITY_INVALID = 1,
00121
00126 VALIDITY_VALID = 2
00127 };
00128
00129 enum ASSESSMENT_TYPE {
00133 VALIDATION_NONE = 0,
00134
00138 VALIDATION_PARTIAL = 1,
00139
00142 VALIDATION_FULL = 2
00143 };
00144
00145 // Constructors and Destructor
00146 // -----------------------------------------------------------------------
00149
00155 PSVIItem(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
00156
00158
00161 virtual ~PSVIItem();
00163
00164 //---------------------
00168
00178 const XMLCh *getValidationContext();
00179
00187 VALIDITY_STATE getValidity() const;
00188
00195 ASSESSMENT_TYPE getValidationAttempted() const;
00196
00203 /***
00204 const XMLCh ** getErrorCodes();
00205 ****/
00206
00213 const XMLCh *getSchemaNormalizedValue();
00214
00220 virtual XSTypeDefinition *getTypeDefinition() = 0;
00221
00231 virtual XSSimpleTypeDefinition *getMemberTypeDefinition() = 0;
00232
00239 const XMLCh *getSchemaDefault();
00240
00246 bool getIsSchemaSpecified() const;
00247
00255 const XMLCh *getCanonicalRepresentation() const;
00256
00258
00259 //----------------------------------
00263
00264 void setValidationAttempted(PSVIItem::ASSESSMENT_TYPE attemptType);
00265 void setValidity(PSVIItem::VALIDITY_STATE validity);
00266
00273 void reset(
00274 const XMLCh* const validationContext
00275 , const XMLCh* const normalizedValue
00276 , const VALIDITY_STATE validityState
00277 , const ASSESSMENT_TYPE assessmentType
00278 );
00280 private:
00281
00282 // -----------------------------------------------------------------------
00283 // Unimplemented constructors and operators
00284 // -----------------------------------------------------------------------
00285 PSVIItem(const PSVIItem&);
00286 PSVIItem & operator=(const PSVIItem &);
00287
00288
00289 protected:
00290 // -----------------------------------------------------------------------
00291 // data members
00292 // -----------------------------------------------------------------------
00293 // fMemoryManager:
00294 // used for any memory allocations
00295 // fValidationContext
00296 // corresponds to the schema [validation context] property
00297 // fNormalizedValue
00298 // The schema normalized value (when present)
00299 // fDefaultValue
00300 // default value specified in the schema, if any
00301 // fCanonicalValue
00302 // canonicalized version of normalizedValue
00303 // fValidityState
00304 // Whether this item is valid or not
00305 // fAssessmentType
00306 // The kind of assessment that produced the given validity outcome
00307 // fIsSpecified
00308 // Whether this item exists because a default was specified in the schema
00309 // fType
00310 // type responsible for validating this item
00311 // fMemberType
00312 // If fType is a union type, the member type that validated this item
00313MemoryManager* const fMemoryManager;
00314 const XMLCh* fValidationContext;
00315 const XMLCh* fNormalizedValue;
00316 const XMLCh* fDefaultValue;
00317 XMLCh* fCanonicalValue;
00318 VALIDITY_STATE fValidityState;
00319 ASSESSMENT_TYPE fAssessmentType;
00320 bool fIsSpecified;
00321XSTypeDefinition * fType;
00322XSSimpleTypeDefinition* fMemberType;
00323 };
00324
00325 inline PSVIItem::~PSVIItem() {}
00326
00327 inline const XMLCh *PSVIItem::getValidationContext()
00328 {
00329 return fValidationContext;
00330 }
00331
00332 inline const XMLCh* PSVIItem::getSchemaNormalizedValue()
00333 {
00334 return fNormalizedValue;
00335 }
00336
00337 inline const XMLCh* PSVIItem::getSchemaDefault()
00338 {
00339 return fDefaultValue;
00340 }
00341
00342 inline const XMLCh* PSVIItem::getCanonicalRepresentation() const
00343 {
00344 return fCanonicalValue;
00345 }
00346
00347 inline PSVIItem::VALIDITY_STATEPSVIItem::getValidity() const
00348 {
00349 return fValidityState;
00350 }
00351
00352 inline bool PSVIItem::getIsSchemaSpecified() const
00353 {
00354 return fIsSpecified;
00355 }
00356
00357 inline PSVIItem::ASSESSMENT_TYPEPSVIItem::getValidationAttempted() const
00358 {
00359 return fAssessmentType;
00360 }
00361
00362 XERCES_CPP_NAMESPACE_END
00363
00364 #endif