首页 > 解决方案 > XSD 验证错误 - 缺少有关 xsd 架构错误代码的详细信息

问题描述

在 .net core 2.2 中尝试针对 XSD 验证 XML 时,我们无法获得确切的架构验证错误。验证错误仅提供有关验证失败的 XML 元素名称的详细信息,而不是 XSD 架构验证失败的详细信息。

.net xml 解析器抛出以下错误

The element 'SignonRq' in namespace 'http://www.ACORD.org/standards/PC_Surety/ACORD1/xml/' has invalid child element 'CustLangPref' in namespace '{http://www.ACORD.org/standards/PC_Surety/ACORD1/xml/}'. List of possible elements expected: 'SignonPswd, SignonCert, SignonTransport, SessKey, ClientDt' in namespace 'http://www.ACORD.org/standards/PC_Surety/ACORD1/xml/'.

如果我们在 Java 中运行,同样的验证会抛出错误。

Error - Line 42, 19: org.xml.sax.SAXParseException; lineNumber: 42; columnNumber: 19; cvc-complex-type.2.4.a: Invalid content was found starting with element 'PostalCode'. One of '{"http://www.ACORD.org/standards/PC_Surety/ACORD1/xml/":Country, "http://www.ACORD.org/standards/PC_Surety/ACORD1/xml/":Latitude, "http://www.ACORD.org/standards/PC_Surety/ACORD1/xml/":Longitude, "http://www.ACORD.org/standards/PC_Surety/ACORD1/xml/":County, "http://www.ACORD.org/standards/PC_Surety/ACORD1/xml/":Region, "http://www.ACORD.org/standards/PC_Surety/ACORD1/xml/":RegionCd, "http://www.ACORD.org/standards/PC_Surety/ACORD1/xml/":Township, "http://www.ACORD.org/standards/PC_Surety/ACORD1/xml/":LegalAddr, "http://www.ACORD.org/standards/PC_Surety/ACORD1/xml/":ItemIdInfo, "http://www.ACORD.org/standards/PC_Surety/ACORD1/xml/":CountyTownCd, "http://www.CSIO.org/standards/PC_Surety/CSIO1/xml/":TownCd, "http://www.CSIO.org/standards/PC_Surety/CSIO1/xml/":AddrFormatCd, "http://www.CSIO.org/standards/PC_Surety/CSIO1/xml/":LengthTimeAddr, "http://www.CSIO.org/standards/PC_Surety/CSIO1/xml/":AddrValidationdInd}' is expected.

没有办法在 .Net Core 中获得像 -"cvc-complex-type.2.4.a" 这样的 cvc 异常模式代码。请专家提出您的意见。

标签: c#.netxsd-validationsystem.xml

解决方案


推荐阅读