使用相对路径使用DTD或XSD进行本地XML验证? [英] Local XML validation with DTD or XSD using a relative path?

查看:202
本文介绍了使用相对路径使用DTD或XSD进行本地XML验证?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以使用文档类型描述(DTD)或XML模式(xsd)定义和验证XML文件,如下所示:

An XML file can be defined and validated with an Document Type Description (DTD) or XML Schema (xsd) as follows:

<?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" >

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE annotation SYSTEM "http://www.xyz.de/system.dtd">

两种方法都定义了找到DTD或XSD的URL。有没有办法给出相对或局部路径?因此,我可以将它们与XML文件一起存储,而不是依赖于服务器吗?

Both ways define a URL where the DTD or XSD is found. Is there a way to give a relative or local path? So I can store them allong with the XML files instead of relying on a server?

推荐答案

这很容易。只需输入文件的相对位置,例如

It's easy. Just put the relative location of the file like

<?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" >

这篇关于使用相对路径使用DTD或XSD进行本地XML验证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆