通过php处理XML目录 [英] Handle XML Catalogs by php

查看:108
本文介绍了通过php处理XML目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含多个文件的XSD(XML Schema)。系统根目录下有一个catalog.xml,它是一个XML目录。它包含用于正确处理xsd文件所需的SYSTEM和URI目录定义。



现在我的问题:我如何在php中验证xml与这些模式?如果我只是使用 DOMDocument-> Schemavalidate()并给它正确的xsd,则目录定义将不会解决,并且php会抛出如下错误:

 警告:DOMDocument :: schemaValidate():I / O警告:无法加载外部实体urn:oasis:names:tc:dita:xsd:highlightDomain.xsd :1.2

在catalog.xml中如何解析这个表达式,但是找不到一个使用php处理的方法。

解决方案

DOM使用下面的libxml。 LibXML应该能够使用目录文件,当它们放在 / etc / xml /目录。在Windows IIRC上相同的路径。



随意提升我的功能请求,使路径可以从PHP配置:




I have an XSD (XML Schema) wich contains multiple files. There's a catalog.xml in the root of the system, wich is an XML Catalog. It contains SYSTEM and URI catalog definitions wich are needed to use to properly process the xsd files.

Now my question: How can I validate xml against these schemas in php? If I simply use DOMDocument->Schemavalidate() and give it the correct xsd, the catalog definitions will not be resolved, and the php throws an error like this:

Warning: DOMDocument::schemaValidate(): I/O warning : failed to load external entity "urn:oasis:names:tc:dita:xsd:highlightDomain.xsd:1.2"

It's in the catalog.xml how to resolve this expression, but I couldn't find a way to handle that with php.

解决方案

DOM uses libxml underneath. LibXML should be able to use Catalog files when they are placed in /etc/xml/catalog. Same path on windows IIRC.

Feel free to upvote my feature request to make the path configurable from PHP:

这篇关于通过php处理XML目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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