根据XSD java验证XML

时间:2012-04-09 16:13:02

标签: java xml xsd

使用Xerces,我得到以下错误:

Parsing error:  Document is invalid: no grammar found.
Parsing error:  Document root element "TXLife", must match DOCTYPE root "null".

我已通过设置

解决了这个问题
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://ACORD.org/Standards/Life/2 file:///C:/Users/Himanshuy/workspace/XMLUnit/TXLife2.26.00.xsd" xmlns="http://ACORD.org/Standards/Life/2"

但是现在SAXParser在将它与XMLSpy验证错误进行比较时给出了错误的验证错误。 SAXParser给了我:

Invalid content was found starting with element <element>

XMLSpy告诉我:

<element> is not allowed at this location under element <some_parent_element>

这里的XMLSpy是正确的。

如何从Java验证中获得相同的结果?

0 个答案:

没有答案