加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

PHP xmlreader:如何缓存xsd架构?

发布时间:2020-12-13 16:21:35 所属栏目:PHP教程 来源:网络整理
导读:我正在使用 PHP xmlreader来验证和解析xml数据.此xml通过XMLReader :: setSchema函数从本地文件中使用某些xsd模式,从http:// via xsd:import / include使用远程xsd模式进行验证. Eveything工作正常,但它从网络中获取xsd模式,并在每次调用时从磁盘读取. 所
我正在使用 PHP xmlreader来验证和解析xml数据.此xml通过XMLReader :: setSchema函数从本地文件中使用某些xsd模式,从http:// via xsd:import / include使用远程xsd模式进行验证. Eveything工作正常,但它从网络中获取xsd模式,并在每次调用时从磁盘读取.

所以我的问题是:

有没有一种方法可以在本地RAM中缓存远程xsd架构?
对于本地模式文件,我认为Linux中的tmpfs工作正常,但还有另一种方法来缓存本地xsd模式文件吗?

感谢VolkerK指出xmlcatalog系统.它与libxml / php xmlreader一起工作正常.在Linux中,只需编辑文件/ etc / xml / catalog(它来自xml-common,当你在Fedora中时)添加一些条目,例如:(例如):

<rewriteURI uriStartString="http://schemas.xmlsoap.org/soap/envelope/" rewritePrefix="/etc/xml/SOAP-Envolope.xsd"/>
<rewriteURI uriStartString="http://schemas.xmlsoap.org/soap/encoding/" rewritePrefix="/etc/xml/SOAP-Encoding.xsd"/>

和手动下载模式(例如http://schemas.xmlsoap.org/soap/encoding/ – > /etc/xml/SOAP-Encoding.xsd)然后php xmlreader在解析SOAP消息时就像预期的那样工作.

解决方法

php的xmlreader使用 libxml,libxml支持 xml catalouges:

What is a catalog? Basically it’s a lookup mechanism […]

It is basically used for 3 things:
[…]

  • providing a local cache mechanism allowing to load the entities associated to public identifiers or remote resources,this is a really important feature for any significant deployment of XML or SGML since it allows to avoid the aleas and delays associated to fetching remote resources.

没试过,但我想这值得试运行.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读