eac*_*tor 4 xml xsd dtd xml-validation xsd-validation
可以使用文档类型描述(DTD)或XML架构(xsd)定义和验证XML文件,如下所示:
<?xml version='1.0' encoding='UTF-8'?>
<annotation xmlns="http://www.xyz.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.xyz.com
file:system.xsd" >
Run Code Online (Sandbox Code Playgroud)
要么
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE annotation SYSTEM "http://www.xyz.de/system.dtd">
Run Code Online (Sandbox Code Playgroud)
两种方式都定义了找到DTD或XSD的URL.有没有办法给出相对或本地路径?所以我可以将它们与XML文件一起存储,而不是依赖于服务器?
小智 13
这很简单.只需将文件的相对位置设置为
<?xml version='1.0' encoding='UTF-8'?>
<annotation xmlns="http://www.xyz.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.xyz.com ./system.xsd" >
Run Code Online (Sandbox Code Playgroud)