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

使用系统xsd对xml进行脱机验证,xml,xsd,xsd-validation,Xml,Xsd,Xsd Validation,当我们将xsd放在xsi:schemaLocation中时,它是否从internet下载xsd并验证xml 我想通过下载xsd来进行离线验证。如果是这样,我该如何实现这一点 我知道如何对DTD进行脱机验证,但对xsd不太清楚 对于DTD,我目前正在做以下工作: <!DOCTYPE struts-config SYSTEM "struts-config_1_1.dtd"> 我可以这样做吗 来自 <!-- beans xmlns="http://www.springframe

当我们将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。我拔掉了互联网插头,看到应用程序运行良好

此外,资料来源:


很抱歉给您添麻烦,问错了问题。

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


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

我可以给出一个相对URI吗,file://my.xsd 不是绝对路径,而是file://c:/something/my.xsd?我不会将file://用于相对路径;just./my.xsd(不要对relative使用scheme,这就是我的意思)。它下载。。。?“它”是谁?不同的软件表现不同。在不知道“它”是什么的情况下,我们不能告诉你你的软件是如何运行的。@MichaelKay我的问题是错误的。它可以下载,离线时也可以正常工作。