[xml] xmlIO questions


Problem with xmlInputCallbackInitialized.
As far as I understand, xmlInputCallbackInitialized is a static flag to detect that the default callbacks have been installed.
And xmlRegisterDefaultInputCallbacks set this flag to 1.
That's OK.
But xmlRegisterInputCallbacks also set this flag to 1, so that I register myself a callbaack, the defaults will not be installed.
Is it intentional and why?
xmlOutputCallbackInitialized has the same behavior.

Problems with URLs.
I do not understand some features of xmlLoadExternalEntity.
If xmlLoadExternalEntity is called with "file:///test.xml" or "file://localhost/test.xml ", it finds that xmlNoNetExists is not 0 and directly calls xmlCurrentExternalEntityLoader. Now if the URL is "file:/test.xml" then xmlNoNetExists=0 and after some trials it will open the file. Up to me these URL are rather equivalent (RFC 3986: For example, the "file" URI scheme is defined so that no authority, an empty host, and "localhost" all mean the end-user's machine, whereas the "http"
scheme considers a missing authority or empty host invalid.).
The test
        if (!xmlStrncasecmp(BAD_CAST filename, BAD_CAST "file:/", 6)
is done in xmlFileOpen_real but absent in various places.

More strange, if the URL is "file:///test%20a.xml", xmlNoNetExists is 0, and the behavior is similar to "file:/test.xml"
All these have some boundaries effects.
In particular libxml2 fails to open "file:/test.xml.gz"

If I call xmlReadFile with the URL "file:///test.xml;format=1", xmlLoadExternalEntity consider this URL as correct (fine!) but
xmlFileOpen will fail at
        unescaped = xmlURIUnescapeString(filename, 0, NULL);
        if (unescaped != NULL) {
            retval = xmlFileOpen_real(unescaped);

because the function xmlURIUnescapeString is not aware of the special characters ?, #, and ;. Is this deliberate or could xmlFileOpen (and its companions) call a different function?

Best regards,

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