【发布时间】:2019-09-18 11:12:01
【问题描述】:
目前我正在使用 javax.xml.validation.Validator 针对给定的 xsd 验证 xml。我已经设置了自定义错误处理程序来获取所有异常,而不是在第一个异常时退出。
Sample xsd:
<xs:element type="xs:string" name="att1"/>
<xs:element type="xs:string" name="att2"/>
<xs:element type="xs:string" name="att3"/>
<xs:element type="xs:string" name="att4"/>
In xml if att2 and att3 values are not there, I am getting below exception.
cvc-complex-type.2.4.a: Invalid content was found starting with element 'att4'. One of '{"https://******":att2}' is expected.
But I need exception to be like this i.e. both att2 and att3 should be shown in expected list.
cvc-complex-type.2.4.a: Invalid content was found starting with element 'att4'. One of '{"https://******":att2, "https://******":att3}' is expected.
我怎样才能做到这一点?
【问题讨论】:
标签: java xml validation xsd schema