Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:14:51

0001 /*
0002  * Licensed to the Apache Software Foundation (ASF) under one or more
0003  * contributor license agreements.  See the NOTICE file distributed with
0004  * this work for additional information regarding copyright ownership.
0005  * The ASF licenses this file to You under the Apache License, Version 2.0
0006  * (the "License"); you may not use this file except in compliance with
0007  * the License.  You may obtain a copy of the License at
0008  * 
0009  *      http://www.apache.org/licenses/LICENSE-2.0
0010  * 
0011  * Unless required by applicable law or agreed to in writing, software
0012  * distributed under the License is distributed on an "AS IS" BASIS,
0013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0014  * See the License for the specific language governing permissions and
0015  * limitations under the License.
0016  */
0017 
0018 /*
0019  * $Id$
0020  */
0021 
0022 #if !defined(XERCESC_INCLUDE_GUARD_PSVIITEM_HPP)
0023 #define XERCESC_INCLUDE_GUARD_PSVIITEM_HPP
0024 
0025 #include <xercesc/util/PlatformUtils.hpp>
0026 
0027 XERCES_CPP_NAMESPACE_BEGIN
0028 
0029 /**
0030  * Represent the PSVI contributions for one element or one attribute information item.
0031  * This is *always* owned by the validator /parser object from which
0032  * it is obtained.  It is designed to be subclassed; subclasses will
0033  * specify under what conditions it may be relied upon to have meaningful contents.
0034  */
0035 
0036 // forward declarations
0037 class XSTypeDefinition; 
0038 class XSSimpleTypeDefinition;
0039 class XSValue;
0040 
0041 class XMLPARSER_EXPORT PSVIItem : public XMemory
0042 {
0043 public:
0044 
0045     enum VALIDITY_STATE {
0046         /** Validity value indicating that validation has either not 
0047         been performed or that a strict assessment of validity could 
0048         not be performed  
0049         */
0050         VALIDITY_NOTKNOWN               = 0,
0051     
0052         /** Validity value indicating that validation has been strictly
0053          assessed and the element in question is invalid according to the 
0054          rules of schema validation.
0055         */
0056         VALIDITY_INVALID               = 1,
0057     
0058         /** Validity value indicating that validation has been strictly 
0059          assessed and the element in question is valid according to the rules 
0060          of schema validation.
0061          */
0062         VALIDITY_VALID                 = 2
0063     };
0064 
0065     enum ASSESSMENT_TYPE {
0066         /** Validation status indicating that schema validation has been 
0067          performed and the element in question has specifically been skipped.   
0068          */
0069         VALIDATION_NONE                = 0,
0070     
0071         /** Validation status indicating that schema validation has been 
0072         performed on the element in question under the rules of lax validation.
0073         */
0074         VALIDATION_PARTIAL             = 1,
0075     
0076         /**  Validation status indicating that full schema validation has been 
0077         performed on the element.  */
0078         VALIDATION_FULL                = 2
0079     };
0080 
0081     //  Constructors and Destructor
0082     // -----------------------------------------------------------------------
0083     /** @name Constructors */
0084     //@{
0085 
0086     /**
0087       * The default constructor 
0088       *
0089       * @param  manager     The configurable memory manager
0090       */
0091     PSVIItem(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
0092 
0093     //@};
0094 
0095     /** @name Destructor */
0096     //@{
0097     virtual ~PSVIItem();
0098     //@}
0099 
0100     //---------------------
0101     /** @name PSVIItem methods */
0102 
0103     //@{
0104 
0105     /**
0106      * [validation context]
0107      * 
0108      * @return A string identifying the nearest ancestor element 
0109      *          information item with a [schema information] property
0110      *         (or this element item itself if it has such a property)
0111      *          (form to be determined)
0112      * @see <a href="http://www.w3.org/TR/xmlschema-1/#e-validation_context">XML Schema Part 1: Structures [validation context]</a>
0113      */
0114     const XMLCh *getValidationContext();
0115 
0116     /**
0117      * Determine the validity of the node with respect 
0118      * to the validation being attempted
0119      * 
0120      * @return return the [validity] property. Possible values are: 
0121      *         VALIDITY_UNKNOWN, VALIDITY_INVALID, VALIDITY_VALID
0122      */
0123     VALIDITY_STATE getValidity() const;
0124 
0125     /**
0126      * Determines the extent to which the item has been validated
0127      * 
0128      * @return return the [validation attempted] property. The possible values are 
0129      *         VALIDATION_NONE, VALIDATION_ORDERED_PARTIAL and VALIDATION_FULL
0130      */
0131     ASSESSMENT_TYPE getValidationAttempted() const;
0132 
0133     /**
0134      * A list of error codes generated from validation attempts. 
0135      * Need to find all the possible sub-clause reports that need reporting
0136      * 
0137      * @return list of error codes
0138      */
0139     /***
0140     const XMLCh ** getErrorCodes();
0141     ****/
0142     
0143     /**
0144      * [schema normalized value] 
0145      * 
0146      * @see <a href="http://www.w3.org/TR/xmlschema-1/#e-schema_normalized_value">XML Schema Part 1: Structures [schema normalized value]</a>
0147      * @return the normalized value of this item after validation
0148      */
0149     const XMLCh *getSchemaNormalizedValue();
0150 
0151     /**
0152      * An item isomorphic to the type definition used to validate this element.
0153      * 
0154      * @return  a type declaration
0155      */
0156     virtual XSTypeDefinition *getTypeDefinition() = 0;
0157     
0158     /**
0159      * If and only if that type definition is a simple type definition
0160      * with {variety} union, or a complex type definition whose {content type}
0161      * is a simple thype definition with {variety} union, then an item isomorphic
0162      * to that member of the union's {member type definitions} which actually
0163      * validated the element item's normalized value.
0164      * 
0165      * @return  a simple type declaration
0166      */
0167     virtual XSSimpleTypeDefinition *getMemberTypeDefinition() = 0;
0168     
0169     /**
0170      * [schema default]
0171      * 
0172      * @return The canonical lexical representation of the declaration's {value constraint} value.
0173      * @see <a href="http://www.w3.org/TR/xmlschema-1/#e-schema_default">XML Schema Part 1: Structures [schema default]</a>
0174      */
0175     const XMLCh *getSchemaDefault();
0176 
0177     /**
0178      * [schema specified] 
0179      * @see <a href="http://www.w3.org/TR/xmlschema-1/#e-schema_specified">XML Schema Part 1: Structures [schema specified]</a>
0180      * @return true - value was specified in schema, false - value comes from the infoset
0181      */
0182     bool getIsSchemaSpecified() const;
0183 
0184     /**
0185      * Return the canonical representation of this value.
0186      * Note that, formally, this is not a PSVI property.
0187      * @return string representing the canonical representation, if this item
0188      * was validated by a simple type definition for which canonical
0189      * representations of values are defined.
0190      */
0191     const XMLCh *getCanonicalRepresentation() const;
0192 
0193     //@}
0194 
0195     /**
0196      * 
0197      * Get actual value in the form of XSValue,
0198      * caller needs to delete the object returned.
0199      *
0200      * @return  an XSValue 
0201      */
0202     virtual XSValue *getActualValue() const;
0203 
0204     //----------------------------------
0205     /** methods needed by implementation */
0206 
0207     //@{
0208 
0209     void setValidationAttempted(PSVIItem::ASSESSMENT_TYPE attemptType);
0210     void setValidity(PSVIItem::VALIDITY_STATE validity);
0211 
0212     /** reset the object
0213      * @param validationContext  corresponds to schema validation context property
0214      * @param normalizedValue  corresponds to schema normalized value property
0215      * @param validityState  state of item's validity
0216      * @param assessmentType  type of assessment carried out on item
0217      */
0218     void reset(
0219             const XMLCh* const validationContext
0220             , const XMLCh* const normalizedValue
0221             , const VALIDITY_STATE validityState
0222             , const ASSESSMENT_TYPE assessmentType
0223         );
0224     //@}
0225 private:
0226 
0227     // -----------------------------------------------------------------------
0228     //  Unimplemented constructors and operators
0229     // -----------------------------------------------------------------------
0230     PSVIItem(const PSVIItem&);
0231     PSVIItem & operator=(const PSVIItem &);
0232 
0233 
0234 protected:
0235     // -----------------------------------------------------------------------
0236     //  data members
0237     // -----------------------------------------------------------------------
0238     // fMemoryManager:
0239     //  used for any memory allocations
0240     // fValidationContext
0241     //  corresponds to the schema [validation context] property
0242     // fNormalizedValue
0243     //  The schema normalized value (when present)
0244     // fDefaultValue
0245     //  default value specified in the schema, if any
0246     // fCanonicalValue
0247     //  canonicalized version of normalizedValue
0248     // fValidityState
0249     //  Whether this item is valid or not
0250     // fAssessmentType
0251     //  The kind of assessment that produced the given validity outcome
0252     // fIsSpecified
0253     //  Whether this item exists because a default was specified in the schema
0254     // fType
0255     //  type responsible for validating this item
0256     // fMemberType
0257     //  If fType is a union type, the member type that validated this item
0258     MemoryManager* const        fMemoryManager;
0259     const XMLCh*                fValidationContext;
0260     const XMLCh*                fNormalizedValue;
0261     const XMLCh*                fDefaultValue;
0262     XMLCh*                      fCanonicalValue;
0263     VALIDITY_STATE              fValidityState;
0264     ASSESSMENT_TYPE             fAssessmentType;
0265     bool                        fIsSpecified;
0266     XSTypeDefinition *          fType;
0267     XSSimpleTypeDefinition*     fMemberType;
0268 };
0269 
0270 inline PSVIItem::~PSVIItem() {}
0271 
0272 inline const XMLCh *PSVIItem::getValidationContext() 
0273 {
0274     return fValidationContext;
0275 }
0276 
0277 inline const XMLCh* PSVIItem::getSchemaNormalizedValue() 
0278 {
0279     return fNormalizedValue;
0280 }
0281 
0282 inline const XMLCh* PSVIItem::getSchemaDefault() 
0283 {
0284     return fDefaultValue;
0285 }
0286 
0287 inline const XMLCh* PSVIItem::getCanonicalRepresentation() const
0288 {
0289     return fCanonicalValue;
0290 }
0291 
0292 inline PSVIItem::VALIDITY_STATE PSVIItem::getValidity() const
0293 {
0294     return fValidityState;
0295 }
0296 
0297 inline bool PSVIItem::getIsSchemaSpecified() const
0298 {
0299     return fIsSpecified;
0300 }
0301 
0302 inline PSVIItem::ASSESSMENT_TYPE PSVIItem::getValidationAttempted() const
0303 {
0304     return fAssessmentType;
0305 }
0306 
0307 XERCES_CPP_NAMESPACE_END
0308 
0309 #endif