Req #53950 [Asn->Opn]: Add a way to configure where libxml searches for Catalog Files
| From: | kalle@php.net | Date: | Tue, 24 Oct 2017 06:14:55 +0000 |
| Subject: | Req #53950 [Asn->Opn]: Add a way to configure where libxml searches for Catalog Files | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-211985@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=53950&edit=1
ID: 53950
Updated by: kalle@php.net
Reported by: gordon at onlinehome dot de
Summary: Add a way to configure where libxml searches for
Catalog Files
-Status: Assigned
+Status: Open
Type: Feature/Change Request
Package: *XML functions
Operating System: any
PHP Version: Irrelevant
-Assigned To: rrichards
+Assigned To:
Block user comment: N
Private report: N
Previous Comments:
------------------------------------------------------------------------
[2013-01-18 21:32:01] hanskrentel at yahoo dot de
setenv("XML_CATALOG_FILES=/path/to/catalog.xml");
should normally work (depending which dialect that as) if it's set before PHP
starts and loads the extension and the path to the catalog XML file does not
contain any spaces (which has a special meaning).
See as well:
http://www.cafeconleche.org/books/effectivexml/chapters/47.html
http://www.chlab.ch/blog/archives/php/soap/cache-soap-envelope-schema-schema-
validation
http://wp.me/pLEEp-nlj
To change things at runtime, make use of libxml_set_external_entity_loader and
implement a catalog parser your own. You then can use catalogs as you wish at
runtime.
------------------------------------------------------------------------
[2011-12-06 17:34:01] Marko dot Voss at fiz-Karlsruhe dot de
> The user can change the default catalog behaviour by redirecting queries to its own set of
> catalogs. This can be done by setting the XML_CATALOG_FILES environment variable to a list of
> catalogs, an empty one should deactivate loading the default /etc/xml/catalog default catalog.
If I understand this right, you can use this code to set your own catalog:
setenv("XML_CATALOG_FILES=/path/to/catalog.xml");
I tried that, because I have to use xml catalog somehow, without overwriting the http stream
wrapper, which is a non-threadsafe way to do this. However, the catalog.xml I specified using setenv
seems not to be used by libxml2.
------------------------------------------------------------------------
[2011-02-08 19:27:00] rrichards@php.net
Assign to self as I asked him to open this
------------------------------------------------------------------------
[2011-02-08 19:18:43] cataphract@php.net
> This, by itself, makes it inviable to write a PHP function that allows
> replacing the default catalog unless some (probably expensive, since a
> catalog file must be read) on request startup/shutdown is used.
The unless part doesn't actually make sense in the multi-threading versions of PHP.
------------------------------------------------------------------------
[2011-02-08 19:14:49] cataphract@php.net
I know very little of libxml2, but as far as I infer from http://xmlsoft.org/catalog.html and from the code in
catalog.c, there is no way to specify a global catalog in a thread-local manner. This, by itself,
makes it inviable to write a PHP function that allows replacing the default catalog unless some
(probably expensive, since a catalog file must be read) on request startup/shutdown is used.
libxml2 supports per-document catalogs, but from what I see, your document must contain an
oasis-xml-catalog processing instruction, like this:
<?xml version="1.0"?>
<?oasis-xml-catalog catalog="http://example.com/catalog.xml"?>
<!DOCTYPE doc PUBLIC "-//Example//DTD Document V1.0//EN"
"http://www.example.com/schema/doc.dtd">
There is another alternative, which is using an external entity loader (see http://xmlsoft.org/html/libxml-parser.html#xmlSetExternalEntityLoader
), but this is less convenient, though probably we could also expose some functions to deal with
catalogs for use in the user-supplied callback.
I could implement this, but I'm hopping someone else with more libxml2 knowledge could tell if
my analysis is correct.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=53950
--
Edit this bug report at https://bugs.php.net/bug.php?id=53950&edit=1