我使用javax.xml.validation.Validator来验证xml文件。在xsd中,一个元素有如下的ID属性。
<xs:attribute name="id" type="xs:ID" use="required"/>
当验证时,在DOMResultBuilder类的第255行。
((ElementImpl) elem).setIdAttributeNode (attr, true);
这一行执行后,再到ElementImpl类第948行执行时。
if (at.getOwnerElement() != this) {}
这将导致错误:org.w3c.dom.DOMException: NOT_FOUND_ERR: An attempt is made to reference a node in a context where it does not exist.It is because "at.getOwnerElement()" will return null, but how could this happen? 我的xml如下。
<cp:ruleset>
<cp:rule id="rule_cdiv_00">
</cp:rule>
</cp:ruleset>
非常感谢你的建议
/add 18 JunNow我知道这是jdk8的一个bug,com.sun.org.apache.xerces.internal.jaxp.validation.DOMResultBuilder,链接如下。https:/issues.apache.orgjirabrowseXERCESJ-1212。
但我如何在我的项目中修复它?