我收到以下错误消息:
无法读取架构文档'ofbiz.apache.org/dtds/widget-screen.xsd',因为1)找不到该文档;2)无法读取文件;3)文档的根元素不是
<xsd:schema>
。
我有一个XML文件,如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xml>
<screens xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/widget-screen.xsd">
<screen name="ShippingAgreement">
<section>
<actions>
<set field="selectedMenuItem" value="facilityShipment"/>
<set field="selectedSubMenuItem" value="ShippingContract"/>
</actions>
<widgets>
<decorator-screen name="DelysCommonDecorator" location="${parameters.mainDecoratorLocation}">
<decorator-section name="body">
</decorator-section>
</decorator-screen>
</widgets>
</section>
</screen>
</screens>
为什么我不能针对XSD文件http://ofbiz.apache.org/dtds/widget-screen.xsd进行验证?
我可以从浏览器访问http://ofbiz.apache.org/dtds/widget-screen.xsd。假设您也有权访问所指定的XSD xsi:noNamespaceSchemaLocation
,请从XML中删除以下行
<!DOCTYPE xml>
并且您的XML将针对给定的XSD有效。
我删除了<!DOCTYPE xml>,但是我的xml无效。
<!DOCTYPE xml>
在使用坚如磐石的基于Xerces-J的验证器进行回答之前,我确认无行是有效的。您收到什么错误消息,并且使用什么验证程序?我收到如下错误:无法读取架构文档' ofbiz.apache.org/dtds/widget-screen.xsd ',因为1)找不到文档;2)无法读取文件;3)文档的根元素不是<xsd:schema>。我使用Eclipse 4.4.1的XML验证程序进行验证
当您单击以下链接时会发生什么:ofbiz.apache.org/dtds/widget-screen.xsd
然后怀疑Eclipse 4.4.1的XML验证程序。我可以告诉您的是,当删除DOCTYPE行时,XML对每个XSD有效。尝试其他工具。