2012-11-28 25 views
0

我正在使用VB.NET - C#的答案很好。根據消息區分例外的替代方法嗎?

我正在構建一個處理對特定XmlSchema的XML驗證的系統。對於我的XML文檔中的每個錯誤,我都有一個SchemaException實例,從中我可以獲取錯誤的行號和位置以及消息。據我所知,確定特定錯誤(無效屬性,缺失元素等)的唯一方法是讀取由於MS未來可能改變它以及消息被本地化的可能性而不可靠的消息字符串。

我需要能夠這些錯誤區分而不必爲了顯示自己的自定義錯誤,並突出我的文本編輯器中的錯誤,依靠.Message財產

將這些區別開來的正確方法是什麼?這是可能的,對吧?

更多信息:

異常並不總是報告中,我想開始突出位置的LinePosition屬性 - 所有的屬性有關的異常報告爲實例的屬性開始,我想如果這是問題,能夠突出顯示屬性值。

SchemaException提供了一個SourceSchemaObject屬性,我可以使用它來確定問題是來自元素還是屬性,並且運氣有點小,可以讓我通過提取導致錯誤並以某種方式將其與SourceSchemaObject進行比較的XML文本,但這種感覺像是一個非常複雜和棘手的解決方案 - 如果我能夠解決具體的錯誤,我可以做到這一點正則表達式工作沒有問題。

回答

3

好的,我最終這樣做了。我認爲這個例外必須具有內部價值,以表明產生該信息的具體錯誤,所以我使用ILSpy深入瞭解它的靈魂。事實證明,它確實有一個名爲「res」的內部字段,它包含一個映射到我們可以使用反射訪問的錯誤的字符串。

我寫了一個小擴展方法,以字符串的形式爲我檢索這個錯誤。

<Extension()> 
Public Function getErrorType(ByRef ref As XmlSchemaException) As XmlSchemaExceptionErrorType 
     Return GetType(XmlSchemaException).GetField("res", Reflection.BindingFlags.NonPublic Or Reflection.BindingFlags.Instance).GetValue(ref) 
End Function 

這是偉大的,但我不想記住所有那些字符串選擇案例的情況,所以我寫了一個腳本,我使用ILSpy一個ENUM和提取的源轉換重新寫的擴展方法如下:

<Extension()> 
Public Function getErrorType(ByRef ref As XmlSchemaException) As XmlSchemaExceptionErrorType 
    Dim res As String = GetType(XmlSchemaException).GetField("res", Reflection.BindingFlags.NonPublic Or Reflection.BindingFlags.Instance).GetValue(ref) 
    Return CType(System.Enum.Parse(GetType(XmlSchemaExceptionErrorType), res), XmlSchemaExceptionErrorType) 
End Function 

Public Enum XmlSchemaExceptionErrorType As Integer 
     Sch_ParEntityRefNesting = 0 
     Sch_NotTokenString = 1 
     Sch_XsdDateTimeCompare = 2 
     Sch_InvalidNullCast = 3 
     Sch_InvalidDateTimeOption = 4 
     Sch_StandAloneNormalization = 5 
     Sch_UnSpecifiedDefaultAttributeInExternalStandalone = 6 
     Sch_DefaultException = 7 
     Sch_DupElementDecl = 8 
     Sch_IdAttrDeclared = 9 
     Sch_RootMatchDocType = 10 
     Sch_DupId = 11 
     Sch_UndeclaredElement = 12 
     Sch_UndeclaredAttribute = 13 
     Sch_UndeclaredNotation = 14 
     Sch_UndeclaredId = 15 
     Sch_SchemaRootExpected = 16 
     Sch_XSDSchemaRootExpected = 17 
     Sch_UnsupportedAttribute = 18 
     Sch_UnsupportedElement = 19 
     Sch_MissAttribute = 20 
     Sch_AnnotationLocation = 21 
     Sch_DataTypeTextOnly = 22 
     Sch_UnknownModel = 23 
     Sch_UnknownOrder = 24 
     Sch_UnknownContent = 25 
     Sch_UnknownRequired = 26 
     Sch_UnknownDtType = 27 
     Sch_MixedMany = 28 
     Sch_GroupDisabled = 29 
     Sch_MissDtvalue = 30 
     Sch_MissDtvaluesAttribute = 31 
     Sch_DupDtType = 32 
     Sch_DupAttribute = 33 
     Sch_RequireEnumeration = 34 
     Sch_DefaultIdValue = 35 
     Sch_ElementNotAllowed = 36 
     Sch_ElementMissing = 37 
     Sch_ManyMaxOccurs = 38 
     Sch_MaxOccursInvalid = 39 
     Sch_MinOccursInvalid = 40 
     Sch_DtMaxLengthInvalid = 41 
     Sch_DtMinLengthInvalid = 42 
     Sch_DupDtMaxLength = 43 
     Sch_DupDtMinLength = 44 
     Sch_DtMinMaxLength = 45 
     Sch_DupElement = 46 
     Sch_DupGroupParticle = 47 
     Sch_InvalidValue = 48 
     Sch_InvalidValueDetailed = 49 
     Sch_InvalidValueDetailedAttribute = 50 
     Sch_MissRequiredAttribute = 51 
     Sch_FixedAttributeValue = 52 
     Sch_FixedElementValue = 53 
     Sch_AttributeValueDataTypeDetailed = 54 
     Sch_AttributeDefaultDataType = 55 
     Sch_IncludeLocation = 56 
     Sch_ImportLocation = 57 
     Sch_RedefineLocation = 58 
     Sch_InvalidBlockDefaultValue = 59 
     Sch_InvalidFinalDefaultValue = 60 
     Sch_InvalidElementBlockValue = 61 
     Sch_InvalidElementFinalValue = 62 
     Sch_InvalidSimpleTypeFinalValue = 63 
     Sch_InvalidComplexTypeBlockValue = 64 
     Sch_InvalidComplexTypeFinalValue = 65 
     Sch_DupIdentityConstraint = 66 
     Sch_DupGlobalElement = 67 
     Sch_DupGlobalAttribute = 68 
     Sch_DupSimpleType = 69 
     Sch_DupComplexType = 70 
     Sch_DupGroup = 71 
     Sch_DupAttributeGroup = 72 
     Sch_DupNotation = 73 
     Sch_DefaultFixedAttributes = 74 
     Sch_FixedInRef = 75 
     Sch_FixedDefaultInRef = 76 
     Sch_DupXsdElement = 77 
     Sch_ForbiddenAttribute = 78 
     Sch_AttributeIgnored = 79 
     Sch_ElementRef = 80 
     Sch_TypeMutualExclusive = 81 
     Sch_ElementNameRef = 82 
     Sch_AttributeNameRef = 83 
     Sch_TextNotAllowed = 84 
     Sch_UndeclaredType = 85 
     Sch_UndeclaredSimpleType = 86 
     Sch_UndeclaredEquivClass = 87 
     Sch_AttListPresence = 88 
     Sch_NotationValue = 89 
     Sch_EnumerationValue = 90 
     Sch_EmptyAttributeValue = 91 
     Sch_InvalidLanguageId = 92 
     Sch_XmlSpace = 93 
     Sch_InvalidXsdAttributeValue = 94 
     Sch_InvalidXsdAttributeDatatypeValue = 95 
     Sch_ElementValueDataTypeDetailed = 96 
     Sch_InvalidElementDefaultValue = 97 
     Sch_NonDeterministic = 98 
     Sch_NonDeterministicAnyEx = 99 
     Sch_NonDeterministicAnyAny = 100 
     Sch_StandAlone = 101 
     Sch_XmlNsAttribute = 102 
     Sch_AllElement = 103 
     Sch_MismatchTargetNamespaceInclude = 104 
     Sch_MismatchTargetNamespaceImport = 105 
     Sch_MismatchTargetNamespaceEx = 106 
     Sch_XsiTypeNotFound = 107 
     Sch_XsiTypeAbstract = 108 
     Sch_ListFromNonatomic = 109 
     Sch_UnionFromUnion = 110 
     Sch_DupLengthFacet = 111 
     Sch_DupMinLengthFacet = 112 
     Sch_DupMaxLengthFacet = 113 
     Sch_DupWhiteSpaceFacet = 114 
     Sch_DupMaxInclusiveFacet = 115 
     Sch_DupMaxExclusiveFacet = 116 
     Sch_DupMinInclusiveFacet = 117 
     Sch_DupMinExclusiveFacet = 118 
     Sch_DupTotalDigitsFacet = 119 
     Sch_DupFractionDigitsFacet = 120 
     Sch_LengthFacetProhibited = 121 
     Sch_MinLengthFacetProhibited = 122 
     Sch_MaxLengthFacetProhibited = 123 
     Sch_PatternFacetProhibited = 124 
     Sch_EnumerationFacetProhibited = 125 
     Sch_WhiteSpaceFacetProhibited = 126 
     Sch_MaxInclusiveFacetProhibited = 127 
     Sch_MaxExclusiveFacetProhibited = 128 
     Sch_MinInclusiveFacetProhibited = 129 
     Sch_MinExclusiveFacetProhibited = 130 
     Sch_TotalDigitsFacetProhibited = 131 
     Sch_FractionDigitsFacetProhibited = 132 
     Sch_LengthFacetInvalid = 133 
     Sch_MinLengthFacetInvalid = 134 
     Sch_MaxLengthFacetInvalid = 135 
     Sch_MaxInclusiveFacetInvalid = 136 
     Sch_MaxExclusiveFacetInvalid = 137 
     Sch_MinInclusiveFacetInvalid = 138 
     Sch_MinExclusiveFacetInvalid = 139 
     Sch_TotalDigitsFacetInvalid = 140 
     Sch_FractionDigitsFacetInvalid = 141 
     Sch_PatternFacetInvalid = 142 
     Sch_EnumerationFacetInvalid = 143 
     Sch_InvalidWhiteSpace = 144 
     Sch_UnknownFacet = 145 
     Sch_LengthAndMinMax = 146 
     Sch_MinLengthGtMaxLength = 147 
     Sch_FractionDigitsGtTotalDigits = 148 
     Sch_LengthConstraintFailed = 149 
     Sch_MinLengthConstraintFailed = 150 
     Sch_MaxLengthConstraintFailed = 151 
     Sch_PatternConstraintFailed = 152 
     Sch_EnumerationConstraintFailed = 153 
     Sch_MaxInclusiveConstraintFailed = 154 
     Sch_MaxExclusiveConstraintFailed = 155 
     Sch_MinInclusiveConstraintFailed = 156 
     Sch_MinExclusiveConstraintFailed = 157 
     Sch_TotalDigitsConstraintFailed = 158 
     Sch_FractionDigitsConstraintFailed = 159 
     Sch_UnionFailedEx = 160 
     Sch_NotationRequired = 161 
     Sch_DupNotationAttribute = 162 
     Sch_MissingPublicSystemAttribute = 163 
     Sch_NotationAttributeOnEmptyElement = 164 
     Sch_RefNotInScope = 165 
     Sch_UndeclaredIdentityConstraint = 166 
     Sch_RefInvalidIdentityConstraint = 167 
     Sch_RefInvalidCardin = 168 
     Sch_ReftoKeyref = 169 
     Sch_EmptyXPath = 170 
     Sch_UnresolvedPrefix = 171 
     Sch_UnresolvedKeyref = 172 
     Sch_ICXpathError = 173 
     Sch_SelectorAttr = 174 
     Sch_FieldSimpleTypeExpected = 175 
     Sch_FieldSingleValueExpected = 176 
     Sch_MissingKey = 177 
     Sch_DuplicateKey = 178 
     Sch_TargetNamespaceXsi = 179 
     Sch_UndeclaredEntity = 180 
     Sch_UnparsedEntityRef = 181 
     Sch_MaxOccursInvalidXsd = 182 
     Sch_MinOccursInvalidXsd = 183 
     Sch_MaxInclusiveExclusive = 184 
     Sch_MinInclusiveExclusive = 185 
     Sch_MinInclusiveGtMaxInclusive = 186 
     Sch_MinExclusiveGtMaxExclusive = 187 
     Sch_MinInclusiveGtMaxExclusive = 188 
     Sch_MinExclusiveGtMaxInclusive = 189 
     Sch_SimpleTypeRestriction = 190 
     Sch_InvalidFacetPosition = 191 
     Sch_AttributeMutuallyExclusive = 192 
     Sch_AnyAttributeLastChild = 193 
     Sch_ComplexTypeContentModel = 194 
     Sch_ComplexContentContentModel = 195 
     Sch_NotNormalizedString = 196 
     Sch_FractionDigitsNotOnDecimal = 197 
     Sch_ContentInNill = 198 
     Sch_NoElementSchemaFound = 199 
     Sch_NoAttributeSchemaFound = 200 
     Sch_InvalidNamespace = 201 
     Sch_InvalidTargetNamespaceAttribute = 202 
     Sch_InvalidNamespaceAttribute = 203 
     Sch_InvalidSchemaLocation = 204 
     Sch_ImportTargetNamespace = 205 
     Sch_ImportTargetNamespaceNull = 206 
     Sch_GroupDoubleRedefine = 207 
     Sch_ComponentRedefineNotFound = 208 
     Sch_GroupRedefineNotFound = 209 
     Sch_AttrGroupDoubleRedefine = 210 
     Sch_AttrGroupRedefineNotFound = 211 
     Sch_ComplexTypeDoubleRedefine = 212 
     Sch_ComplexTypeRedefineNotFound = 213 
     Sch_SimpleToComplexTypeRedefine = 214 
     Sch_SimpleTypeDoubleRedefine = 215 
     Sch_ComplexToSimpleTypeRedefine = 216 
     Sch_SimpleTypeRedefineNotFound = 217 
     Sch_MinMaxGroupRedefine = 218 
     Sch_MultipleGroupSelfRef = 219 
     Sch_MultipleAttrGroupSelfRef = 220 
     Sch_InvalidTypeRedefine = 221 
     Sch_InvalidElementRef = 222 
     Sch_MinGtMax = 223 
     Sch_DupSelector = 224 
     Sch_IdConstraintNoSelector = 225 
     Sch_IdConstraintNoFields = 226 
     Sch_IdConstraintNoRefer = 227 
     Sch_SelectorBeforeFields = 228 
     Sch_NoSimpleTypeContent = 229 
     Sch_SimpleTypeRestRefBase = 230 
     Sch_SimpleTypeRestRefBaseNone = 231 
     Sch_SimpleTypeListRefBase = 232 
     Sch_SimpleTypeListRefBaseNone = 233 
     Sch_SimpleTypeUnionNoBase = 234 
     Sch_NoRestOrExtQName = 235 
     Sch_NoRestOrExt = 236 
     Sch_NoGroupParticle = 237 
     Sch_InvalidAllMin = 238 
     Sch_InvalidAllMax = 239 
     Sch_InvalidFacet = 240 
     Sch_AbstractElement = 241 
     Sch_XsiTypeBlockedEx = 242 
     Sch_InvalidXsiNill = 243 
     Sch_SubstitutionNotAllowed = 244 
     Sch_SubstitutionBlocked = 245 
     Sch_InvalidElementInEmptyEx = 246 
     Sch_InvalidElementInTextOnlyEx = 247 
     Sch_InvalidTextInElement = 248 
     Sch_InvalidElementContent = 249 
     Sch_InvalidElementContentComplex = 250 
     Sch_IncompleteContent = 251 
     Sch_IncompleteContentComplex = 252 
     Sch_InvalidTextInElementExpecting = 253 
     Sch_InvalidElementContentExpecting = 254 
     Sch_InvalidElementContentExpectingComplex = 255 
     Sch_IncompleteContentExpecting = 256 
     Sch_IncompleteContentExpectingComplex = 257 
     Sch_InvalidElementSubstitution = 258 
     Sch_ElementNameAndNamespace = 259 
     Sch_ElementName = 260 
     Sch_ContinuationString = 261 
     Sch_AnyElementNS = 262 
     Sch_AnyElement = 263 
     Sch_InvalidTextInEmpty = 264 
     Sch_InvalidWhitespaceInEmpty = 265 
     Sch_InvalidPIComment = 266 
     Sch_InvalidAttributeRef = 267 
     Sch_OptionalDefaultAttribute = 268 
     Sch_AttributeCircularRef = 269 
     Sch_IdentityConstraintCircularRef = 270 
     Sch_SubstitutionCircularRef = 271 
     Sch_InvalidAnyAttribute = 272 
     Sch_DupIdAttribute = 273 
     Sch_InvalidAllElementMax = 274 
     Sch_InvalidAny = 275 
     Sch_InvalidAnyDetailed = 276 
     Sch_InvalidExamplar = 277 
     Sch_NoExamplar = 278 
     Sch_InvalidSubstitutionMember = 279 
     Sch_RedefineNoSchema = 280 
     Sch_ProhibitedAttribute = 281 
     Sch_TypeCircularRef = 282 
     Sch_TwoIdAttrUses = 283 
     Sch_AttrUseAndWildId = 284 
     Sch_MoreThanOneWildId = 285 
     Sch_BaseFinalExtension = 286 
     Sch_NotSimpleContent = 287 
     Sch_NotComplexContent = 288 
     Sch_BaseFinalRestriction = 289 
     Sch_BaseFinalList = 290 
     Sch_BaseFinalUnion = 291 
     Sch_UndefBaseRestriction = 292 
     Sch_UndefBaseExtension = 293 
     Sch_DifContentType = 294 
     Sch_InvalidContentRestriction = 295 
     Sch_InvalidContentRestrictionDetailed = 296 
     Sch_InvalidBaseToEmpty = 297 
     Sch_InvalidBaseToMixed = 298 
     Sch_DupAttributeUse = 299 
     Sch_InvalidParticleRestriction = 300 
     Sch_InvalidParticleRestrictionDetailed = 301 
     Sch_ForbiddenDerivedParticleForAll = 302 
     Sch_ForbiddenDerivedParticleForElem = 303 
     Sch_ForbiddenDerivedParticleForChoice = 304 
     Sch_ForbiddenDerivedParticleForSeq = 305 
     Sch_ElementFromElement = 306 
     Sch_ElementFromAnyRule1 = 307 
     Sch_ElementFromAnyRule2 = 308 
     Sch_AnyFromAnyRule1 = 309 
     Sch_AnyFromAnyRule2 = 310 
     Sch_AnyFromAnyRule3 = 311 
     Sch_GroupBaseFromAny1 = 312 
     Sch_GroupBaseFromAny2 = 313 
     Sch_ElementFromGroupBase1 = 314 
     Sch_ElementFromGroupBase2 = 315 
     Sch_ElementFromGroupBase3 = 316 
     Sch_GroupBaseRestRangeInvalid = 317 
     Sch_GroupBaseRestNoMap = 318 
     Sch_GroupBaseRestNotEmptiable = 319 
     Sch_SeqFromAll = 320 
     Sch_SeqFromChoice = 321 
     Sch_UndefGroupRef = 322 
     Sch_GroupCircularRef = 323 
     Sch_AllRefNotRoot = 324 
     Sch_AllRefMinMax = 325 
     Sch_NotAllAlone = 326 
     Sch_AttributeGroupCircularRef = 327 
     Sch_UndefAttributeGroupRef = 328 
     Sch_InvalidAttributeExtension = 329 
     Sch_InvalidAnyAttributeRestriction = 330 
     Sch_AttributeRestrictionProhibited = 331 
     Sch_AttributeRestrictionInvalid = 332 
     Sch_AttributeFixedInvalid = 333 
     Sch_AttributeUseInvalid = 334 
     Sch_AttributeRestrictionInvalidFromWildcard = 335 
     Sch_NoDerivedAttribute = 336 
     Sch_UnexpressibleAnyAttribute = 337 
     Sch_RefInvalidAttribute = 338 
     Sch_ElementCircularRef = 339 
     Sch_RefInvalidElement = 340 
     Sch_ElementCannotHaveValue = 341 
     Sch_ElementInMixedWithFixed = 342 
     Sch_ElementTypeCollision = 343 
     Sch_InvalidIncludeLocation = 344 
     Sch_CannotLoadSchema = 345 
     Sch_CannotLoadSchemaLocation = 346 
     Sch_LengthGtBaseLength = 347 
     Sch_MinLengthGtBaseMinLength = 348 
     Sch_MaxLengthGtBaseMaxLength = 349 
     Sch_MaxMinLengthBaseLength = 350 
     Sch_MaxInclusiveMismatch = 351 
     Sch_MaxExclusiveMismatch = 352 
     Sch_MinInclusiveMismatch = 353 
     Sch_MinExclusiveMismatch = 354 
     Sch_MinExlIncMismatch = 355 
     Sch_MinExlMaxExlMismatch = 356 
     Sch_MinIncMaxExlMismatch = 357 
     Sch_MinIncExlMismatch = 358 
     Sch_MaxIncExlMismatch = 359 
     Sch_MaxExlIncMismatch = 360 
     Sch_TotalDigitsMismatch = 361 
     Sch_FacetBaseFixed = 362 
     Sch_WhiteSpaceRestriction1 = 363 
     Sch_WhiteSpaceRestriction2 = 364 
     Sch_XsiNilAndFixed = 365 
     Sch_MixSchemaTypes = 366 
     Sch_XSDSchemaOnly = 367 
     Sch_InvalidPublicAttribute = 368 
     Sch_InvalidSystemAttribute = 369 
     Sch_TypeAfterConstraints = 370 
     Sch_XsiNilAndType = 371 
     Sch_DupSimpleTypeChild = 372 
     Sch_InvalidIdAttribute = 373 
     Sch_InvalidNameAttributeEx = 374 
     Sch_InvalidAttribute = 375 
     Sch_EmptyChoice = 376 
     Sch_DerivedNotFromBase = 377 
     Sch_NeedSimpleTypeChild = 378 
     Sch_InvalidCollection = 379 
     Sch_UnrefNS = 380 
     Sch_InvalidSimpleTypeRestriction = 381 
     Sch_MultipleRedefine = 382 
     Sch_NullValue = 383 
     Sch_ComplexContentModel = 384 
     Sch_SchemaNotPreprocessed = 385 
     Sch_SchemaNotRemoved = 386 
     Sch_ComponentAlreadySeenForNS = 387 
     Sch_DefaultAttributeNotApplied = 388 
     Sch_NotXsiAttribute = 389 
     Sch_SchemaDoesNotExist = 390 
     Sch_InvalidStartTransition = 391 
     Sch_InvalidStateTransition = 392 
     Sch_InvalidEndValidation = 393 
     Sch_InvalidEndElementCall = 394 
     Sch_InvalidEndElementCallTyped = 395 
     Sch_InvalidEndElementMultiple = 396 
     Sch_DuplicateAttribute = 397 
     Sch_InvalidPartialValidationType = 398 
     Sch_SchemaElementNameMismatch = 399 
     Sch_SchemaAttributeNameMismatch = 400 
     Sch_ValidateAttributeInvalidCall = 401 
     Sch_ValidateElementInvalidCall = 402 
     Sch_EnumNotStarted = 403 
     Sch_EnumFinished = 404 
     Sch_ErrorPosition = 405 
     Sch_ReservedNsDecl = 406 
     Sch_NotInSchemaCollection = 407 
     Sch_NotationNotAttr = 408 
     Sch_InvalidContent = 409 
     Sch_InvalidContentExpecting = 410 
     Sch_InvalidTextWhiteSpace = 411 
     Sch_XSCHEMA = 412 
     Sch_DubSchema = 413 
     Sch_AttributeValueDataType = 414 
     Sch_ElementValueDataType = 415 
     Sch_NonDeterministicAny = 416 
     Sch_MismatchTargetNamespace = 417 
     Sch_UnionFailed = 418 
     Sch_XsiTypeBlocked = 419 
     Sch_InvalidElementInEmpty = 420 
     Sch_InvalidElementInTextOnly = 421 
     Sch_InvalidNameAttribute = 422 
    End Enum 

大大!

現在,我可以做我的錯誤處理是這樣的:

Select Case e.Exception.getErrorType 
    Case XmlSchemaExceptionErrorType.Sch_UndeclaredAttribute 
     ' Error specific code 
    Case XmlSchemaExceptionErrorType.Sch_UndeclaredElement 
     ' Error specific code 
    Case Else 
     ' General code for handling any other errors we don't specifically care about 
End Select 
0

您可以針對模式驗證xml

驗證錯誤在XmlReaderSettings.ValidationEventHandler事件中處理。 Example here

如果您有XML模式的分類(如驗證規則),您可以將輸入消息解析/轉換爲用戶友好的消息。

對於其他非xml錯誤,請將通用try/catch處理程序添加到您正在讀取/驗證xml文件的代碼中。

+0

這就是我如何驗證我的XML - 以及在技術上我使用XPathNavigator.CheckValidity但它基本上是一樣的。我不完全確定你的分類標準是什麼意思...... – SeriousSamP

+0

如果相關,我自己創建模式 - 如果它不相關。 – SeriousSamP

+0

在我的項目中,我們通過這種方式處理xml驗證。我們對每個領域都有驗證規則(這就是我所說的分類學)。我們有一個解析器,它選擇字段名稱,並指定錯誤中的規則。規則就像數字,小數點後兩位,日期格式,字符串長度等。 – Tilak