Re: [xml] catalogs, include and import



As it turns out, you're right about catalog support requiring /etc/xml/catalog to exist. On Windows, the path appears to be simply "etc\xml".

The strace output shows this (notice the lack of a leading "/" or "\" in the NtOpenFile call!)

When I make a `pwd`\etc\xml and put a catalog file in it, the test program works.

That doesn't seem like the "right" behavior. I wonder if "etc\xml" is hardcoded.

I'm ccing the list on this one.

-M

422 744 592 NtOpenFile (0x100001, {24, 28, 0x40, 0, 0, "etc\xml\"}, 1243400, 3, 16417, ... ) == STATUS_OBJECT_PATH_NOT_FOUND 423 744 592 NtFsControlFile (28, 0, 0, 0, 1243740, 589864, 0, 0, 0, 0, ... ) == 0x0 424 744 592 NtFsControlFile (28, 0, 0, 0, 1241808, 589864, 0, 0, 0, 0, ... ) == 0x0 425 744 592 NtOpenFile (0x100001, {24, 28, 0x40, 0, 0, "etc\xml\"}, 1243400, 3, 16417, ... ) == STATUS_OBJECT_PATH_NOT_FOUND 426 744 592 NtFsControlFile (28, 0, 0, 0, 1243740, 589864, 0, 0, 0, 0, ... ) == 0x0 427 744 592 NtFsControlFile (28, 0, 0, 0, 1241892, 589864, 0, 0, 0, 0, ... ) == 0x0



William M. Brack wrote:
Yuck - Windoze corruption!  I'm doing all the xml /xslt stuff strictly on
Linux.

But, anyway .... some progress!  I did this:-

root billrouter work # cat catalog.c
#include        <libxml/parser.h>
#include        <libxml/catalog.h>
#include        <libxslt/xsltInternals.h>
#include        <stdio.h>

int main(int nargs, char **argv) {
int ret;
xsltStylesheetPtr sheetPtr;

    xmlInitParser();
    xmlSubstituteEntitiesDefault(1);
    xmlInitializeCatalog();

    ret = xmlCatalogAdd((const xmlChar *)"rewriteSystem",
        (const xmlChar *)"http://me/";,
        (const xmlChar *)"file://");

    if (ret != 0) {
        printf("xmlCatalogAdd returned %d\n",ret);
        exit(-1);
    }

    sheetPtr = xsltParseStylesheetFile("testcat.xsl");
    if (sheetPtr==NULL) {
        printf("xsltParseStylesheetFile returned a NULL!\n");
        exit(-1);
    }

    return 0;
}

plus created a stylesheet:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>

<xsl:import href="http://me/include.xsl"/>

</xsl:stylesheet>

then ran the program and got this, which (I hope) is something like the
sign of failure that you experience:-

root billrouter work # ./test
xmlNanoHTTPConnectHost:  Failed to resolve host 'me' - Authoritive host
not found
xmlNanoHTTPConnectHost:  Failed to resolve host 'me' - Authoritive host
not found
warning: failed to load external entity "http://me/include.xsl";
compilation error: file testcat.xsl element import
xsl:import : unable to load http://me/include.xsl

Then, I noticed that the directory /etc/xml didn't exist (or,
alternatively, was empty [same effect]), so I created the directory and
then put in an empty "catalog" file by running the utility "xmlcatalog":

root billrouter work # xmlcatalog --create > /etc/xml/catalog

and then re-ran my version of your program:-

root billrouter work # ./test
warning: failed to load external entity "file://include.xsl"
compilation error: file testcat.xsl element import
xsl:import : unable to load http://me/include.xsl

Wow - look at that!!!  The substitution of file:// has been accomplished!

So - could it be that you are having the same problem?  You don't have a
default /etc/xml/catalog file (or would it be \etc\xml\catalog???), and
that's causing it to fail?  If so, do you have the xmlcatalog utility
program?

Incidentally, I consider the fact that it fails when /etc/xml/catalog is
not present to be a bug, but I'll have to confirm that with Daniel.  If he
agrees, I'll fix it for the next release.

Hope that helps - now, I've got to get to bed (it's 23:15 here!).

Bye,

Bill









[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]