00001
00002
00003 #if !defined(XERCESC_INCLUDE_GUARD_ERRHEADER_XMLValid)
00004 #define XERCESC_INCLUDE_GUARD_ERRHEADER_XMLValid
00005
00006 #include <xercesc/framework/XMLErrorReporter.hpp>
00007 #include <xercesc/util/XercesDefs.hpp>
00008 #include <xercesc/dom/DOMError.hpp>
00009
00010 XERCES_CPP_NAMESPACE_BEGIN
00011
00012 class XMLValid
00013 {
00014 public :
00015 enum Codes
00016 {
00017 NoError = 0
00018 , E_LowBounds = 1
00019 , ElementNotDefined = 2
00020 , AttNotDefined = 3
00021 , NotationNotDeclared = 4
00022 , RootElemNotLikeDocType = 5
00023 , RequiredAttrNotProvided = 6
00024 , ElementNotValidForContent = 7
00025 , BadIDAttrDefType = 8
00026 , InvalidEmptyAttValue = 9
00027 , ElementAlreadyExists = 10
00028 , MultipleIdAttrs = 11
00029 , ReusedIDValue = 12
00030 , IDNotDeclared = 13
00031 , UnknownNotRefAttr = 14
00032 , UndeclaredElemInDocType = 15
00033 , EmptyNotValidForContent = 16
00034 , AttNotDefinedForElement = 17
00035 , BadEntityRefAttr = 18
00036 , UnknownEntityRefAttr = 19
00037 , ColonNotValidWithNS = 20
00038 , NotEnoughElemsForCM = 21
00039 , NoCharDataInCM = 22
00040 , DoesNotMatchEnumList = 23
00041 , AttrValNotName = 24
00042 , NoMultipleValues = 25
00043 , NotSameAsFixedValue = 26
00044 , RepElemInMixed = 27
00045 , FeatureUnsupported = 28
00046 , GroupContentRestricted = 29
00047 , UnknownBaseDatatype = 30
00048 , NoContentForRef = 31
00049 , DatatypeError = 32
00050 , ProhibitedAttributePresent = 33
00051 , IllegalXMLSpace = 34
00052 , WrongTargetNamespace = 35
00053 , SimpleTypeHasChild = 36
00054 , NoDatatypeValidatorForSimpleType = 37
00055 , GrammarNotFound = 38
00056 , DisplayErrorMessage = 39
00057 , NillNotAllowed = 40
00058 , NilAttrNotEmpty = 41
00059 , FixedDifferentFromActual = 42
00060 , NoDatatypeValidatorForAttribute = 43
00061 , GenericError = 44
00062 , ElementNotQualified = 45
00063 , ElementNotUnQualified = 46
00064 , VC_IllegalRefInStandalone = 47
00065 , NoDefAttForStandalone = 48
00066 , NoAttNormForStandalone = 49
00067 , NoWSForStandalone = 50
00068 , VC_EntityNotFound = 51
00069 , PartialMarkupInPE = 52
00070 , DatatypeValidationFailure = 53
00071 , UniqueParticleAttributionFail = 54
00072 , NoAbstractInXsiType = 55
00073 , NoDirectUseAbstractElement = 56
00074 , NoUseAbstractType = 57
00075 , BadXsiType = 58
00076 , NonDerivedXsiType = 59
00077 , ElemNoSubforBlock = 60
00078 , TypeNoSubforBlock = 61
00079 , AttributeNotQualified = 62
00080 , AttributeNotUnQualified = 63
00081 , IC_FieldMultipleMatch = 64
00082 , IC_UnknownField = 65
00083 , IC_AbsentKeyValue = 66
00084 , IC_KeyNotEnoughValues = 67
00085 , IC_KeyMatchesNillable = 68
00086 , IC_DuplicateUnique = 69
00087 , IC_DuplicateKey = 70
00088 , IC_KeyRefOutOfScope = 71
00089 , IC_KeyNotFound = 72
00090 , NonWSContent = 73
00091 , EmptyElemNotationAttr = 74
00092 , EmptyElemHasContent = 75
00093 , ElemOneNotationAttr = 76
00094 , AttrDupToken = 77
00095 , ElemChildrenHasInvalidWS = 78
00096 , E_HighBounds = 79
00097 , W_LowBounds = 80
00098 , W_HighBounds = 81
00099 , F_LowBounds = 82
00100 , F_HighBounds = 83
00101 };
00102
00103 static bool isFatal(const XMLValid::Codes toCheck)
00104 {
00105 return ((toCheck >= F_LowBounds) && (toCheck <= F_HighBounds));
00106 }
00107
00108 static bool isWarning(const XMLValid::Codes toCheck)
00109 {
00110 return ((toCheck >= W_LowBounds) && (toCheck <= W_HighBounds));
00111 }
00112
00113 static bool isError(const XMLValid::Codes toCheck)
00114 {
00115 return ((toCheck >= E_LowBounds) && (toCheck <= E_HighBounds));
00116 }
00117
00118 static XMLErrorReporter::ErrTypes errorType(const XMLValid::Codes toCheck)
00119 {
00120 if ((toCheck >= W_LowBounds) && (toCheck <= W_HighBounds))
00121 return XMLErrorReporter::ErrType_Warning;
00122 else if ((toCheck >= F_LowBounds) && (toCheck <= F_HighBounds))
00123 return XMLErrorReporter::ErrType_Fatal;
00124 else if ((toCheck >= E_LowBounds) && (toCheck <= E_HighBounds))
00125 return XMLErrorReporter::ErrType_Error;
00126 return XMLErrorReporter::ErrTypes_Unknown;
00127 }
00128 static DOMError::ErrorSeverity DOMErrorType(const XMLValid::Codes toCheck)
00129 {
00130 if ((toCheck >= W_LowBounds) && (toCheck <= W_HighBounds))
00131 return DOMError::DOM_SEVERITY_WARNING;
00132 else if ((toCheck >= F_LowBounds) && (toCheck <= F_HighBounds))
00133 return DOMError::DOM_SEVERITY_FATAL_ERROR;
00134 else return DOMError::DOM_SEVERITY_ERROR;
00135 }
00136
00137 private:
00138
00139
00140
00141 XMLValid();
00142 };
00143
00144 XERCES_CPP_NAMESPACE_END
00145
00146 #endif
00147