3

当我们将 xsd 放入 xsi:schemaLocation 时,它会从 Internet 下载 xsd 并验证 xml 吗?

如果是这种情况,我想通过下载 xsd 来进行离线验证,我该如何实现?

我知道如何对 DTD 进行离线验证,但不确定 xsd。

对于 DTD,我目前正在执行以下操作:

<!DOCTYPE struts-config SYSTEM "struts-config_1_1.dtd">

我可以做这样的事情吗?

<!-- beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans 
           http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
           http://www.springframework.org/schema/context
           http://www.springframework.org/schema/context/spring-context-3.0.xsd"-->

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans 
                           file://spring-beans-3.0.xsd
                           http://www.springframework.org/schema/context
                           file://spring-context-3.0.xsd">

编辑:

看来我错了。spring 只有在 jar 文件中找不到 dtd/xsd 时才会访问 Internet。我拔下互联网插头,发现应用程序运行良好。

另外,来源:https ://forum.hibernate.org/viewtopic.php?f=1&t=949031

很抱歉给您带来麻烦和错误的问题。

4

1 回答 1

0

是的你可以; 您需要确保的是 URI 必须对您的方案有效(在您的情况下为 file://,在 Windows 上更像是 file://c:/something/my.xsd)。

确保所有 XSD 文件也都存储在本地,并且 XSD 文件之间的所有引用都是正确的。

于 2012-05-02T17:57:20.017 回答