具有模式标头和目录查找的XML验证 [英] Xml validation with schema header and Catalog lookup

查看:57
本文介绍了具有模式标头和目录查找的XML验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在不显式指定架构文件的情况下验证xml(使用libxml)文件? xsd文件位于xml文件的标题中.相应的xsd文件URL应该使用Catalog.xml位于本地文件系统中.

How to validate xml (using libxml) file without specifying the schema file explicitly? xsd file is in the header of the xml file. The corresponding xsd file URL should be located in the local file system using a Catalog.xml.

推荐答案

目前看来不可能(libxml 2.8.0).这取自libxml页面( xmlschemas ):

Looks like it is not possible at the moment (libxml 2.8.0). This is taken from libxml page (xmlschemas):

接口到XML Schemas处理和模式有效性检查,它 现在还不完整.

interface to the XML Schemas handling and schema validity checking, it is incomplete right now.

作为一种解决方法,可以使用具有很多import元素的组合架构.可以指定多余的名称空间.最后,组合的架构必须显式传递给验证器.

As a workaround one may use a combined schema with lots of import elements. Superfluous namespaces may be specified. Finally the combined schema must be passed to the validator explicitly.

命名空间可以使用目录正确解析,除非import中的schemaLocation指定有效的直接位置.

Namespaces imported with xsd:import are resolved correctly using catalogs, unless schemaLocation in import specifies valid direct location.

<import namespace="http://example.com"
          schemaLocation="example.xsd">

如果example.xsd在当前目录中不存在,则使用目录文件进行解析.

If example.xsd does not exist in current directory, it is resolved using catalog files.

这篇关于具有模式标头和目录查找的XML验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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