PHP xmlreader: How to cache xsd schema?

I use PHP xmlreader to validate and parse XML data. This xml is checked using some xsd schema from the local file using the XMLReader :: setSchema function and the remote xsd schema from http: // via xsd: import / include. Eveything works fine, but it retrieves the xsd schema from the network and reads from disk every time it is called.

So my questions are:

Is there any way to cache the remote xsd scheme in local RAM? For local schema files, I think tmpfs on Linux will work fine, but is there any other way to cache local xsd schema files?

Decision

Thanks to VolkerK for pointing out the xmlcatalog system. It works great with libxml / php xmlreader. On Linux, just edit the / etc / xml / catalog file (it comes from xml-common when you are in Fedora) add some entries, for example (for example):

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

and a manual loading scheme (for example, http://schemas.xmlsoap.org/soap/encoding/ โ†’ /etc/xml/SOAP-Encoding.xsd), then the PHP xmlreader file works as expected when parsing SOAP messages.

+4
source share
1 answer

php xmlreader uses libxml and libxml supports xml catalouges

What is a directory? This is mainly a search engine [...]
It is mainly used for 3 things:
[...]
  • provides a local cache mechanism for loading objects associated with public identifiers or remote resources, this is a really important feature for any significant XML or SGML deployment, since it avoids the ale and delays associated with retrieving remote resources.

Not tried, but I think it is worth the test.

+3
source

All Articles