2014-05-05 13:44:31 +02:00
|
|
|
/*
|
|
|
|
* Copyright 2005-2009 Gerald Schmidt.
|
|
|
|
*
|
|
|
|
* This file is part of Xml Copy Editor.
|
|
|
|
*
|
2014-06-09 16:19:51 +02:00
|
|
|
* Xml Copy Editor is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2014-05-05 13:44:31 +02:00
|
|
|
*
|
|
|
|
* Xml Copy Editor is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with Xml Copy Editor; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
2014-05-18 14:58:40 +02:00
|
|
|
#include "wx/wx.h"
|
2009-11-06 18:06:12 +01:00
|
|
|
#include "xercescatalogresolver.h"
|
|
|
|
#include <xercesc/sax2/SAX2XMLReader.hpp>
|
|
|
|
#include <xercesc/framework/LocalFileInputSource.hpp>
|
|
|
|
#ifdef __WXMSW__
|
|
|
|
#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 );
|
2014-04-27 14:35:09 +02:00
|
|
|
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
|
|
|
|
2014-04-27 14:35:09 +02:00
|
|
|
// Xerces-C++ can't open a file URL when there are multi-byte characters.
|
|
|
|
// Parse the file URL here instead.
|
2014-05-04 02:40:05 +02:00
|
|
|
wxFileName file = WrapLibxml::URLToFileName ( sysId );
|
2014-04-27 14:35:09 +02:00
|
|
|
if ( file.IsFileReadable() )
|
|
|
|
return new LocalFileInputSource (
|
|
|
|
( const XMLCh * ) WrapXerces::toString ( file.GetFullPath() ).GetData() );
|
|
|
|
|
|
|
|
return NULL;
|
2009-11-06 18:06:12 +01:00
|
|
|
}
|