无法读取架构文档 [XSD],因为

Failed to read schema document [XSD] because

我收到以下错误消息:

Failed to read schema document 'ofbiz.apache.org/dtds/widget-screen.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <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。假设您也可以访问 xsi:noNamespaceSchemaLocation 指定的 XSD,请从 XML

中删除以下行
<!DOCTYPE xml>

并且您的 XML 将对给定的 XSD 有效。

我遇到了同样的问题。然后我使用的是 Netbeans IDE 11.1,后来我安装了 11.2,现在可以使用了。 您还可以检查 Fix for web.xml errors 我在网上搜索时发现它很有用:)