Made sure our catalog is used

According to "7.1.2. Resolution of External Identifiers" from http://www.oasis-open.org/committees/entity/spec-2001-08-06.html, our catalog may not be used if the system catalog, which is specified in a delegateSystem entry, is out of date, such as the catalog for resolving public ID "-//OASIS//DTD DocBook XML V5.0//EN"
This commit is contained in:
Zane U. Ji 2013-10-27 22:10:08 +08:00
parent e39638ea3b
commit d9a84f61d2
1 changed files with 20 additions and 4 deletions

View File

@ -29,6 +29,8 @@
#include <wx/filesys.h> #include <wx/filesys.h>
#include <wx/uri.h> #include <wx/uri.h>
static xmlCatalogPtr catalog = NULL;
class Initializer class Initializer
{ {
public: public:
@ -40,13 +42,16 @@ public:
LIBXML_TEST_VERSION LIBXML_TEST_VERSION
xmlInitializeCatalog(); xmlInitializeCatalog();
xmlLoadCatalog ( catalogPath.mb_str() ); ::catalog = xmlLoadACatalog ( catalogPath.mb_str() );
initGenericErrorDefaultFunc ( NULL ); initGenericErrorDefaultFunc ( NULL );
} }
~Initializer () ~Initializer ()
{ {
xmlFreeCatalog ( ::catalog );
::catalog = NULL;
xsltCleanupGlobals(); xsltCleanupGlobals();
xmlCatalogCleanup(); xmlCatalogCleanup();
xmlCleanupParser(); xmlCleanupParser();
@ -566,9 +571,20 @@ wxString WrapLibxml::catalogResolve
, const wxString &systemId , const wxString &systemId
) )
{ {
char *s = ( char * ) xmlCatalogResolve ( // According to 7.1.2. Resolution of External Identifiers
( const xmlChar * ) ( const char *) publicId.mb_str ( wxConvUTF8 ), // from http://www.oasis-open.org/committees/entity/spec-2001-08-06.html,
( const xmlChar * ) ( const char *) systemId.mb_str ( wxConvUTF8 ) ); // our catalog may not be used if the system catalog, which is specified
// in a delegateSystem entry, is out of date, such as the catalog for
// resolving public ID "-//OASIS//DTD DocBook XML V5.0//EN"
char *s = ( char * ) xmlACatalogResolve ( ::catalog,
( const xmlChar * ) ( const char *) publicId.utf8_str(),
( const xmlChar * ) ( const char *) systemId.utf8_str() );
#ifndef __WXMSW__
if ( s == NULL )
s = ( char * ) xmlCatalogResolve (
( const xmlChar * ) ( const char *) publicId.utf8_str(),
( const xmlChar * ) ( const char *) systemId.utf8_str() );
#endif
if ( s == NULL ) if ( s == NULL )
return wxEmptyString; return wxEmptyString;