Check your XML catalogs ….

  • Christian Stocker

Just wasted some time on an annoying behavior of libxml/PHP5.0/xinclude (you can blame different parts for that :) )

If we (Bitflux in Flux CMS) have repetitive content in our projects, we do an xinclude for not having redundant data. Works fine. Until today, when I realized that some pages need a few seconds to show up, which was beyond anything we were used to… After investigating a little bit, it was clear, that the xincludes where to blame. And there it was the DOCTYPE declaration in the included file…. What xinclude does is getting the DTD from the remote server declared there. And now it was no surprise anymore, that it's that slow. The solution is: Use catalogs…

To prevent that you have to make an /etc/xml/catalog file with the following content:

<?xml version="1.0"?>
<!DOCTYPE catalog PUBLIC "-//OASIS//DTD XML Catalogs V1.0//EN"
 <catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
  <public publicId="-//W3C//DTD Xhtml 1.0 Transitional//EN" uri="file://etc/xml/xhtml1-transitional.dtd"/>
  <public publicId="-//W3C//DTD Xhtml 1.0 Strict//EN" uri="file://etc/xml/xhtml1-strict.dtd"/>

Get xhtml1-transitional.dtd et al. from the and put it in the same directory. Restart apache and everything is fast again. In PHP 5.1, there's an option to prevent that from the beginning (no resolving of external dtds even in xinclude), but with PHP 5.0, this is the only real solution. The (not so) funny thing is, that I discovered that flaw and Rob and me fixed it for PHP 5.1, but I forgot obviously… argh :)

And here's an old post with almost the same problem from me.

Qu’en pensez-vous?