xml-copy-editor-code/src/xercescatalogresolver.cpp

34 lines
1005 B
C++
Raw Normal View History

2009-11-06 18:06:12 +01:00
#include "xercescatalogresolver.h"
#include <xercesc/sax2/SAX2XMLReader.hpp>
#include <xercesc/framework/LocalFileInputSource.hpp>
#ifdef __WXMSW__
#include "wx/wx.h"
#include "replace.h"
#endif
2013-10-26 15:15:42 +02:00
#include "wrapxerces.h"
2009-11-06 18:06:12 +01:00
InputSource *XercesCatalogResolver::resolveEntity (
2013-10-26 15:15:42 +02:00
const XMLCh* const publicId,
2009-11-06 18:06:12 +01:00
const XMLCh* const systemId )
{
2013-10-26 15:15:42 +02:00
wxString pubId, sysId, resolved;
pubId = WrapXerces::toString ( publicId );
sysId = WrapXerces::toString ( systemId );
resolved = catalogResolve ( pubId, sysId );
if ( !resolved.empty() )
return new LocalFileInputSource (
2013-10-26 15:15:42 +02:00
( const XMLCh * ) WrapXerces::toString ( resolved ).GetData() );
2009-11-06 18:06:12 +01:00
// Xerces-C++ can't open a file URL when there are multi-byte characters.
// Parse the file URL here instead.
wxFileName file = WrapLibxml::URLToFileName ( systemId );
if ( file.IsFileReadable() )
return new LocalFileInputSource (
( const XMLCh * ) WrapXerces::toString ( file.GetFullPath() ).GetData() );
return NULL;
2009-11-06 18:06:12 +01:00
}