使用系统xsd对xml进行脱机验证

时间:2012-05-02 17:41:24

标签: xml xsd xsd-validation

当我们将xsd放在xsi:schemaLocation中时,是否从互联网上下载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">

编辑:

看起来我错了。只有在jar文件中找不到dtd / xsd时,spring才会进入Internet。我拉了互联网插头,看到应用程序工作正常。

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

抱歉遇到麻烦和错误的问题。

1 个答案:

答案 0 :(得分:0)

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

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