Re: [xslt] Win2K,xsltproc ignores catalog



On Mon, 17 Feb 2003, Igor Zlatkovic wrote:
> Time to consult the wisdom of the debugger :-)

Well, the debugger has spoken.

The backbone of the problem is a Windows path, of course.

In order for the myriad of possible processings to succeed, it is important
that xmlDoc.URL always contains the path in the URI notation on Windows.
The moment it contains the native filesystem notation, things like
xmlBuildURI will fail at some point.

In order to ensure this, the function xmlNormalizeWindowsPath is called in
xmlCreateFileParserCtxt, and that covers most cases.

The function xmlParseCatalogFile does the job differently. It creates the
input buffer based on the file name. The function
xmlCreateInputBufferFilename will normalise Windows path internally, but
that helps not. xmlParseCatalogFile will create the new input stream based
on the unnormalised file name and that unnormalised thing ends up in
xmlDoc.URL at the end. If now the catalog referred to by xmlDoc.URL contains
relative URIs, libxml will not find these resources.

I believe that this should be fixed, because xmlParseCatalogFile is a
function which can very well be directly called by some command-line utility
and have the native path passed on from the command-line.

The patch to catalog.c which fixes this is below. Any thoughts?

Ciao,
Igor


===================================================================
RCS file: /cvs/gnome/gnome-xml/catalog.c,v
retrieving revision 1.42
diff -c -r1.42 catalog.c
*** catalog.c   4 Feb 2003 19:28:49 -0000       1.42
--- catalog.c   17 Feb 2003 17:46:03 -0000
***************
*** 760,765 ****
--- 760,766 ----
      xmlDocPtr ret;
      xmlParserCtxtPtr ctxt;
      char *directory = NULL;
+     char *normalized;
      xmlParserInputPtr inputStream;
      xmlParserInputBufferPtr buf;

***************
*** 771,789 ****
        return(NULL);
      }

!     buf = xmlParserInputBufferCreateFilename(filename,
XML_CHAR_ENCODING_NONE);
      if (buf == NULL) {
        xmlFreeParserCtxt(ctxt);
        return(NULL);
      }

      inputStream = xmlNewInputStream(ctxt);
      if (inputStream == NULL) {
        xmlFreeParserCtxt(ctxt);
        return(NULL);
      }

!     inputStream->filename = xmlMemStrdup(filename);
      inputStream->buf = buf;
      inputStream->base = inputStream->buf->buffer->content;
      inputStream->cur = inputStream->buf->buffer->content;
--- 772,796 ----
        return(NULL);
      }

!     normalized = xmlNormalizeWindowsPath(filename);
!     if (normalized == NULL)
!       normalized = xmlMemStrdup(filename);
!
!     buf = xmlParserInputBufferCreateFilename(normalized,
XML_CHAR_ENCODING_NONE);
      if (buf == NULL) {
        xmlFreeParserCtxt(ctxt);
+       xmlMemFree(normalized);
        return(NULL);
      }

      inputStream = xmlNewInputStream(ctxt);
      if (inputStream == NULL) {
        xmlFreeParserCtxt(ctxt);
+       xmlMemFree(normalized);
        return(NULL);
      }

!     inputStream->filename = normalized;
      inputStream->buf = buf;
      inputStream->base = inputStream->buf->buffer->content;
      inputStream->cur = inputStream->buf->buffer->content;




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