Made XercesCatalogResolver work. Don't load catalog over and over again. It isn't thread-safe according to the document.
Fixed a compiling problem with wxWidgets 2.9
This commit is contained in:
parent
e455fd0da3
commit
b4aa69c2ca
|
@ -72,7 +72,15 @@ nobase_xmlcopyeditor_DATA = png/*.png \
|
|||
po/zh_TW/messages.mo \
|
||||
po/uk_UA/messages.mo \
|
||||
po/ca/messages.mo \
|
||||
po/en_us/messages.po
|
||||
po/en_us/messages.po \
|
||||
catalog/catalog \
|
||||
dtd/*.* dtd/dita/* \
|
||||
dtd/docbook/4.4/*.* \
|
||||
dtd/docbook/4.4/ent/* \
|
||||
dtd/docbook/5.0b/* \
|
||||
dtd/tei/p4/* \
|
||||
dtd/tei/p5/* \
|
||||
xsl/openlearn2daisyhtml/*
|
||||
|
||||
pixmap_DATA = xmlcopyeditor.png
|
||||
|
||||
|
|
|
@ -314,7 +314,15 @@ nobase_xmlcopyeditor_DATA = png/*.png \
|
|||
po/zh_TW/messages.mo \
|
||||
po/uk_UA/messages.mo \
|
||||
po/ca/messages.mo \
|
||||
po/en_us/messages.po
|
||||
po/en_us/messages.po \
|
||||
catalog/catalog \
|
||||
dtd/*.* dtd/dita/* \
|
||||
dtd/docbook/4.4/*.* \
|
||||
dtd/docbook/4.4/ent/* \
|
||||
dtd/docbook/5.0b/* \
|
||||
dtd/tei/p4/* \
|
||||
dtd/tei/p5/* \
|
||||
xsl/openlearn2daisyhtml/*
|
||||
|
||||
pixmap_DATA = xmlcopyeditor.png
|
||||
applications_DATA = xmlcopyeditor.desktop
|
||||
|
|
|
@ -1,21 +1,24 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
|
||||
<public publicId="-//W3C//DTD XHTML 1.0 Transitional//EN" uri="file:///C:/Program%20Files/XML%20Copy%20Editor/dtd/xhtml1-transitional.dtd"/>
|
||||
<public publicId="-//W3C//DTD XHTML 1.0 Strict//EN" uri="file:///C:/Program%20Files/XML%20Copy%20Editor/dtd/xhtml1-strict.dtd"/>
|
||||
<public publicId="-//W3C//DTD XHTML 1.0 Frameset//EN" uri="file:///C:/Program%20Files/XML%20Copy%20Editor/dtd/xhtml1-frameset.dtd"/>
|
||||
<public publicId="-//OASIS//DTD DocBook XML 5.0b3//EN" uri="file:///C:/Program%20Files/XML%20Copy%20Editor/dtd/docbook/5.0b/docbook.dtd"/>
|
||||
<public publicId="-//OASIS//DTD DocBook XML 4.4//EN" uri="file:///C:/Program%20Files/XML%20Copy%20Editor/dtd/docbook/4.4/docbookx.dtd"/>
|
||||
<public publicId="-//TEI P4//DTD Main Document Type//EN" uri="file:///C:/Program%20Files/XML%20Copy%20Editor/dtd/tei/p4/tei2.dtd"/>
|
||||
<public publicId="-//TEI P5//DTD Main Document Type//EN" uri="file:///C:/Program%20Files/XML%20Copy%20Editor/dtd/tei/p5/tei_all.dtd"/>
|
||||
<public publicId="-//OASIS//DTD DITA Map//EN" uri="file:///C:/Program%20Files/XML%20Copy%20Editor/dtd/dita/map.dtd"/>
|
||||
<public publicId="-//OASIS//DTD DITA Task//EN" uri="file:///C:/Program%20Files/XML%20Copy%20Editor/dtd/dita/task.dtd"/>
|
||||
<public publicId="-//OASIS//DTD DITA Topic//EN" uri="file:///C:/Program%20Files/XML%20Copy%20Editor/dtd/dita/topic.dtd"/>
|
||||
<public publicId="-//OASIS//DTD DITA Concept//EN" uri="file:///C:/Program%20Files/XML%20Copy%20Editor/dtd/dita/concept.dtd"/>
|
||||
<public publicId="-//OpenLaszlo//DTD Main Document Type//EN" uri="file:///C:/Program%20Files/XML%20Copy%20Editor/dtd/lzx.dtd"/>
|
||||
<public publicId="urn:newsml:iptc.org:20021018:NewsMLv1.2:1" uri="file:///C:/Program%20Files/XML%20Copy%20Editor/dtd/NewsML_1.2.dtd"/>
|
||||
<public publicId="-//TopicMaps.Org//DTD XML Topic Map (XTM) 1.0//EN" uri="file:///C:/Program%20Files/XML%20Copy%20Editor/dtd/xtm1.dtd"/>
|
||||
<public publicId="ISO/IEC 13250-3:2005//DTD XML Topic Maps (XTM) 2.0//EN" uri="file:///C:/Program%20Files/XML%20Copy%20Editor/dtd/xtm2.dtd"/>
|
||||
<public publicId="-//OpenLearn//DTD" uri="file:///C:/Program%20Files/XML%20Copy%20Editor/dtd/OUGenericFull.dtd"/>
|
||||
<public publicId="-//Moodle Glossary//DTD" uri="file:///C:/Program%20Files/XML%20Copy%20Editor/dtd/moodle_glossary.dtd"/>
|
||||
<public publicId="-//Moodle XML//DTD" uri="file:///C:/Program%20Files/XML%20Copy%20Editor/dtd/moodle_xml.dtd"/>
|
||||
<public publicId="-//W3C//DTD XHTML 1.0 Transitional//EN" uri="../dtd/xhtml1-transitional.dtd"/>
|
||||
<public publicId="-//W3C//DTD XHTML 1.0 Strict//EN" uri="../dtd/xhtml1-strict.dtd"/>
|
||||
<public publicId="-//W3C//DTD XHTML 1.0 Frameset//EN" uri="../dtd/xhtml1-frameset.dtd"/>
|
||||
<public publicId="-//W3C//ENTITIES Latin 1 for XHTML//EN" uri="../dtd/xhtml-lat1.ent"/>
|
||||
<public publicId="-//W3C//ENTITIES Symbols for XHTML//EN" uri="../dtd/xhtml-symbol.ent"/>
|
||||
<public publicId="-//W3C//ENTITIES Special for XHTML//EN" uri="../dtd/xhtml-special.ent"/>
|
||||
<public publicId="-//OASIS//DTD DocBook XML 5.0b3//EN" uri="../dtd/docbook/5.0b/docbook.dtd"/>
|
||||
<public publicId="-//OASIS//DTD DocBook XML 4.4//EN" uri="../dtd/docbook/4.4/docbookx.dtd"/>
|
||||
<public publicId="-//TEI P4//DTD Main Document Type//EN" uri="../dtd/tei/p4/tei2.dtd"/>
|
||||
<public publicId="-//TEI P5//DTD Main Document Type//EN" uri="../dtd/tei/p5/tei_all.dtd"/>
|
||||
<public publicId="-//OASIS//DTD DITA Map//EN" uri="../dtd/dita/map.dtd"/>
|
||||
<public publicId="-//OASIS//DTD DITA Task//EN" uri="../dtd/dita/task.dtd"/>
|
||||
<public publicId="-//OASIS//DTD DITA Topic//EN" uri="../dtd/dita/topic.dtd"/>
|
||||
<public publicId="-//OASIS//DTD DITA Concept//EN" uri="../dtd/dita/concept.dtd"/>
|
||||
<public publicId="-//OpenLaszlo//DTD Main Document Type//EN" uri="../dtd/lzx.dtd"/>
|
||||
<public publicId="urn:newsml:iptc.org:20021018:NewsMLv1.2:1" uri="../dtd/NewsML_1.2.dtd"/>
|
||||
<public publicId="-//TopicMaps.Org//DTD XML Topic Map (XTM) 1.0//EN" uri="../dtd/xtm1.dtd"/>
|
||||
<public publicId="ISO/IEC 13250-3:2005//DTD XML Topic Maps (XTM) 2.0//EN" uri="../dtd/xtm2.dtd"/>
|
||||
<public publicId="-//OpenLearn//DTD" uri="../dtd/OUGenericFull.dtd"/>
|
||||
<public publicId="-//Moodle Glossary//DTD" uri="../dtd/moodle_glossary.dtd"/>
|
||||
<public publicId="-//Moodle XML//DTD" uri="../dtd/moodle_xml.dtd"/>
|
||||
</catalog>
|
||||
|
|
|
@ -20,19 +20,16 @@
|
|||
#include <memory>
|
||||
#include "catalogresolver.h"
|
||||
|
||||
CatalogResolver::CatalogResolver( const std::string& catalogPath )
|
||||
CatalogResolver::CatalogResolver()
|
||||
{
|
||||
wl = new WrapLibxml ( false, catalogPath );
|
||||
}
|
||||
|
||||
CatalogResolver::~CatalogResolver()
|
||||
{
|
||||
delete wl;
|
||||
}
|
||||
|
||||
std::string CatalogResolver::lookupPublicId (
|
||||
const std::string& publicId)
|
||||
std::string CatalogResolver::lookupPublicId ( const std::string &publicId )
|
||||
{
|
||||
//std::auto_ptr<WrapLibxml> libxml ( new WrapLibxml ( false, catalogPath ) );
|
||||
return wl->lookupPublicId ( publicId );
|
||||
return WrapLibxml::lookupPublicId ( publicId );
|
||||
}
|
||||
|
|
|
@ -23,15 +23,13 @@
|
|||
#include <string>
|
||||
#include "wraplibxml.h"
|
||||
|
||||
class CatalogResolver
|
||||
class CatalogResolver : protected WrapLibxml
|
||||
{
|
||||
public:
|
||||
CatalogResolver( const std::string& catalogPath );
|
||||
CatalogResolver();
|
||||
~CatalogResolver();
|
||||
std::string lookupPublicId (
|
||||
const std::string& publicId);
|
||||
private:
|
||||
WrapLibxml *wl;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -24,7 +24,7 @@ void *CatalogResolverThread::Entry()
|
|||
{
|
||||
wxCriticalSectionLocker locker ( catalogResolverCriticalSection );
|
||||
|
||||
std::auto_ptr<WrapLibxml> libxml ( new WrapLibxml ( false, myCatalogPath ) );
|
||||
std::auto_ptr<WrapLibxml> libxml ( new WrapLibxml ( false ) );
|
||||
*mySystemIdPtr = libxml->lookupPublicId ( *myPublicIdPtr );
|
||||
}
|
||||
Exit();
|
||||
|
|
|
@ -19,25 +19,25 @@
|
|||
|
||||
#include <wx/filename.h>
|
||||
#include "pathresolver.h"
|
||||
#include <wx/stdpaths.h>
|
||||
|
||||
wxString PathResolver::run ( const wxString& path, const wxString& anchor )
|
||||
{
|
||||
if ( path.empty() ) // no hope for empty paths
|
||||
return wxEmptyString;
|
||||
|
||||
wxString myPath, myAnchor;
|
||||
myPath = path;
|
||||
myAnchor = anchor;
|
||||
wxFileName pathObject ( myPath );
|
||||
if ( pathObject.IsAbsolute() ||
|
||||
myPath.Contains ( _T ( "http://" ) ) )
|
||||
return myPath;
|
||||
wxFileName pathObject ( path );
|
||||
if ( pathObject.IsAbsolute() || path.Contains ( _T ( "http://" ) ) )
|
||||
return path;
|
||||
|
||||
// check anchor
|
||||
wxString myAnchor;
|
||||
myAnchor = anchor;
|
||||
wxFileName anchorObject ( myAnchor );
|
||||
if ( myAnchor.empty() )
|
||||
{
|
||||
myAnchor = wxFileName::GetCwd();
|
||||
//myAnchor = wxFileName::GetCwd();
|
||||
myAnchor = wxStandardPaths::Get().GetDataDir();
|
||||
}
|
||||
else if ( !anchorObject.IsDir() )
|
||||
{
|
||||
|
|
|
@ -27,13 +27,7 @@ ThreadReaper::ThreadReaper ()
|
|||
|
||||
ThreadReaper::~ThreadReaper ()
|
||||
{
|
||||
//wxCriticalSectionLocker lock ( xmlcopyeditorCriticalSection );
|
||||
|
||||
std::vector<boost::shared_ptr<wxThread> >::iterator itr;
|
||||
for ( itr = mList.begin(); itr != mList.end(); itr++)
|
||||
{
|
||||
(**itr).Kill();
|
||||
}
|
||||
clear();
|
||||
}
|
||||
|
||||
ThreadReaper &ThreadReaper::get()
|
||||
|
@ -59,3 +53,25 @@ void ThreadReaper::add ( wxThread *thread )
|
|||
itr = mList.erase ( itr );
|
||||
}
|
||||
}
|
||||
|
||||
void ThreadReaper::clear()
|
||||
{
|
||||
xmlcopyeditorCriticalSection.Enter();
|
||||
|
||||
std::vector<boost::shared_ptr<wxThread> > threads = mList;
|
||||
mList.clear();
|
||||
|
||||
xmlcopyeditorCriticalSection.Leave();
|
||||
|
||||
// It's safe to call wxThread::Wait() now
|
||||
std::vector<boost::shared_ptr<wxThread> >::iterator itr;
|
||||
for ( itr = threads.begin(); itr != threads.end(); itr++)
|
||||
{
|
||||
// This will cause the whole program to abort in linux with early
|
||||
// versions of wxWidgets. A easy way to fix this is to rethrow
|
||||
// abi::__forced_unwind& exceptions and avoid calling pthread_exit
|
||||
// in such a condition.
|
||||
(**itr).Kill();
|
||||
(**itr).Wait();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,6 +34,8 @@ public:
|
|||
static ThreadReaper &get();
|
||||
|
||||
void add ( wxThread *thread );
|
||||
// Kills all threads in the list.
|
||||
void clear();
|
||||
|
||||
protected:
|
||||
std::vector<boost::shared_ptr<wxThread> > mList;
|
||||
|
|
|
@ -13,9 +13,7 @@ DEFINE_EVENT_TYPE(wxEVT_COMMAND_VALIDATION_COMPLETED);
|
|||
ValidationThread::ValidationThread (
|
||||
wxEvtHandler *handler,
|
||||
const char *buffer,
|
||||
const char *system,
|
||||
const char *catalogPath,
|
||||
const char *catalogUtilityPath )
|
||||
const char *system )
|
||||
: wxThread ( wxTHREAD_JOINABLE )
|
||||
, mStopping ( false )
|
||||
{
|
||||
|
@ -27,16 +25,12 @@ ValidationThread::ValidationThread (
|
|||
myEventHandler = handler;
|
||||
myBuffer = buffer;
|
||||
mySystem = system;
|
||||
myCatalogPath = catalogPath;
|
||||
myCatalogUtilityPath = catalogUtilityPath;
|
||||
myIsSucceeded = false;
|
||||
}
|
||||
|
||||
void *ValidationThread::Entry()
|
||||
{
|
||||
std::auto_ptr<WrapXerces> validator ( new WrapXerces(
|
||||
myCatalogPath,
|
||||
myCatalogUtilityPath ) );
|
||||
std::auto_ptr<WrapXerces> validator ( new WrapXerces() );
|
||||
|
||||
if ( TestDestroy() )
|
||||
{
|
||||
|
|
|
@ -14,9 +14,7 @@ public:
|
|||
ValidationThread (
|
||||
wxEvtHandler *handler,
|
||||
const char *buffer,
|
||||
const char *system,
|
||||
const char *catalogPath,
|
||||
const char *catalogUtilityPath );
|
||||
const char *system );
|
||||
virtual void *Entry();
|
||||
void setBuffer ( const char *buffer, const char *system );
|
||||
bool isSucceeded () { return myIsSucceeded; }
|
||||
|
@ -31,7 +29,7 @@ public:
|
|||
|
||||
protected:
|
||||
wxEvtHandler *myEventHandler;
|
||||
std::string myBuffer, mySystem, myCatalogPath, myCatalogUtilityPath;
|
||||
std::string myBuffer, mySystem;
|
||||
bool myIsSucceeded;
|
||||
std::pair<int, int> myPosition;
|
||||
wxString myMessage;
|
||||
|
|
|
@ -26,21 +26,25 @@
|
|||
#endif
|
||||
|
||||
#include <wx/wx.h>
|
||||
#include <wx/filesys.h>
|
||||
#include <wx/uri.h>
|
||||
|
||||
void WrapLibxml::Init() throw()
|
||||
class Initializer
|
||||
{
|
||||
static class Initializer
|
||||
public:
|
||||
Initializer ( const std::string &catalogPath ) throw ()
|
||||
{
|
||||
public:
|
||||
Initializer () throw ()
|
||||
{
|
||||
xmlSetGenericErrorFunc ( xmlGenericErrorContext, &Initializer::OnXmlGenericError );
|
||||
xmlSetGenericErrorFunc ( xmlGenericErrorContext,
|
||||
&Initializer::OnXmlGenericError );
|
||||
|
||||
LIBXML_TEST_VERSION
|
||||
|
||||
xmlInitializeCatalog();
|
||||
xmlLoadCatalog ( catalogPath.c_str() );
|
||||
|
||||
initGenericErrorDefaultFunc ( NULL );
|
||||
}
|
||||
|
||||
~Initializer ()
|
||||
{
|
||||
xsltCleanupGlobals();
|
||||
|
@ -77,11 +81,15 @@ void WrapLibxml::Init() throw()
|
|||
std::string ( "Can't format message: " ) + msg );
|
||||
}
|
||||
}
|
||||
} dummy;
|
||||
};
|
||||
|
||||
void WrapLibxml::Init ( const std::string &catalogPath ) throw()
|
||||
{
|
||||
static Initializer dummy ( catalogPath );
|
||||
}
|
||||
|
||||
WrapLibxml::WrapLibxml ( bool netAccessParameter, const std::string& catalogPathParameter )
|
||||
: netAccess ( netAccessParameter ), catalogPath ( catalogPathParameter )
|
||||
WrapLibxml::WrapLibxml ( bool netAccessParameter )
|
||||
: netAccess ( netAccessParameter )
|
||||
{
|
||||
WrapLibxml::Init();
|
||||
}
|
||||
|
@ -106,7 +114,6 @@ bool WrapLibxml::validate ( const std::string& fileName )
|
|||
|
||||
bool returnValue = false;
|
||||
|
||||
loadCatalog();
|
||||
docPtr = xmlCtxtReadFile (
|
||||
ctxt,
|
||||
fileName.c_str(),
|
||||
|
@ -239,8 +246,6 @@ bool WrapLibxml::parse (
|
|||
return false;
|
||||
}
|
||||
|
||||
loadCatalog();
|
||||
|
||||
int flags = XML_PARSE_DTDLOAD;
|
||||
if ( resolveEntities )
|
||||
flags |= XML_PARSE_NOENT;
|
||||
|
@ -301,7 +306,6 @@ bool WrapLibxml::xpath ( const std::string& path, const std::string& fileName )
|
|||
return false;
|
||||
}
|
||||
|
||||
loadCatalog();
|
||||
docPtr = xmlCtxtReadFile (
|
||||
ctxt,
|
||||
fileName.c_str(),
|
||||
|
@ -384,7 +388,6 @@ bool WrapLibxml::xslt (
|
|||
return false;
|
||||
}
|
||||
|
||||
loadCatalog();
|
||||
doc = xmlParseFile ( fileName.c_str() );
|
||||
if ( !doc )
|
||||
{
|
||||
|
@ -432,7 +435,6 @@ bool WrapLibxml::bufferWellFormed ( const std::string& buffer )
|
|||
if ( !ctxt )
|
||||
return false;
|
||||
|
||||
loadCatalog();
|
||||
xmlDocPtr docPtr = xmlCtxtReadMemory (
|
||||
ctxt,
|
||||
buffer.c_str(),
|
||||
|
@ -459,8 +461,6 @@ int WrapLibxml::saveEncoding (
|
|||
|
||||
xmlSubstituteEntitiesDefault ( 0 );
|
||||
|
||||
loadCatalog();
|
||||
|
||||
xmlKeepBlanksDefault ( 1 ); // prevents single-line output
|
||||
|
||||
xmlDocPtr docPtr = xmlCtxtReadMemory (
|
||||
|
@ -496,9 +496,6 @@ int WrapLibxml::saveEncodingFromFile (
|
|||
return -1;
|
||||
|
||||
xmlSubstituteEntitiesDefault ( 0 );
|
||||
|
||||
loadCatalog();
|
||||
|
||||
xmlKeepBlanksDefault ( 1 ); // prevents single-line output
|
||||
|
||||
xmlDocPtr docPtr = xmlCtxtReadFile (
|
||||
|
@ -564,32 +561,21 @@ std::string WrapLibxml::getOutput()
|
|||
return output;
|
||||
}
|
||||
|
||||
void WrapLibxml::loadCatalog()
|
||||
{
|
||||
#ifdef __WXMSW__
|
||||
xmlLoadCatalog ( catalogPath.c_str() );
|
||||
#endif
|
||||
}
|
||||
|
||||
std::string WrapLibxml::lookupPublicId ( const std::string& id )
|
||||
{
|
||||
loadCatalog();
|
||||
std::string ret;
|
||||
char *s = ( char * ) xmlCatalogResolvePublic ( ( const xmlChar * ) id.c_str() );
|
||||
if ( !s )
|
||||
if ( s == NULL )
|
||||
return ret;
|
||||
|
||||
char *original, *it;
|
||||
original = s;
|
||||
|
||||
it = strstr ( s, "file://" );
|
||||
if ( it )
|
||||
{
|
||||
s = it + 6;
|
||||
}
|
||||
|
||||
wxString url ( s, wxConvUTF8 );
|
||||
wxFileName file = wxFileSystem::URLToFileName ( url );
|
||||
if ( file.IsFileReadable() )
|
||||
ret = file.GetFullPath().mb_str ( wxConvLocal );
|
||||
else
|
||||
ret = s;
|
||||
|
||||
xmlFree ( original );
|
||||
xmlFree ( s );
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -38,10 +38,9 @@
|
|||
class WrapLibxml
|
||||
{
|
||||
public:
|
||||
static void Init() throw();
|
||||
WrapLibxml (
|
||||
bool netAccessParameter = false,
|
||||
const std::string& catalogPathParameter = "catalog" );
|
||||
static void Init ( const std::string &catalogPath = "catalog" ) throw();
|
||||
|
||||
WrapLibxml ( bool netAccessParameter = false );
|
||||
virtual ~WrapLibxml();
|
||||
bool validate ( const std::string& fileName );
|
||||
bool validateRelaxNG (
|
||||
|
@ -71,9 +70,8 @@ class WrapLibxml
|
|||
std::string lookupPublicId ( const std::string& id );
|
||||
private:
|
||||
bool netAccess;
|
||||
std::string catalogPath, output, nonParserError;
|
||||
std::string output, nonParserError;
|
||||
int errorLine;
|
||||
void loadCatalog();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -46,12 +46,12 @@ void WrapXerces::Init() throw()
|
|||
} dummy;
|
||||
}
|
||||
|
||||
WrapXerces::WrapXerces( std::string catalogPath, std::string catalogUtilityPath )
|
||||
WrapXerces::WrapXerces()
|
||||
{
|
||||
WrapXerces::Init();
|
||||
|
||||
errorPosition = std::make_pair ( 1, 1 );
|
||||
catalogResolver = new XercesCatalogResolver( catalogPath, catalogUtilityPath );
|
||||
catalogResolver = new XercesCatalogResolver();
|
||||
}
|
||||
|
||||
WrapXerces::~WrapXerces()
|
||||
|
@ -165,6 +165,8 @@ bool WrapXerces::validateMemory (
|
|||
}
|
||||
catch ( ... )
|
||||
{
|
||||
if ( thread != NULL && thread->TestDestroy() )
|
||||
throw;
|
||||
lastError = wxEmptyString;
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -37,9 +37,8 @@ class WrapXerces
|
|||
{
|
||||
public:
|
||||
static void Init() throw ();
|
||||
WrapXerces( std::string catalogPath = "",
|
||||
std::string catalogUtilityPath = "" );
|
||||
~WrapXerces();
|
||||
WrapXerces();
|
||||
virtual ~WrapXerces();
|
||||
bool validate ( const std::string& fileName );
|
||||
bool validateMemory ( const char *buffer, size_t len,
|
||||
const char *system, wxThread *thread = NULL );
|
||||
|
|
|
@ -13,7 +13,7 @@ InputSource *XercesCatalogResolver::resolveEntity (
|
|||
{
|
||||
/* the following _should_ work but doesn't always, so drop it for now
|
||||
#ifndef __WXMSW__
|
||||
resolved = cr->lookupPublicId ( narrowPublicId );
|
||||
resolved = lookupPublicId ( narrowPublicId );
|
||||
#else
|
||||
return NULL;
|
||||
std::string stdPublicId = narrowPublicId;
|
||||
|
@ -69,12 +69,9 @@ InputSource *XercesCatalogResolver::resolveEntity (
|
|||
#endif
|
||||
*/
|
||||
|
||||
#ifdef __WXMSW__
|
||||
return NULL;
|
||||
#else
|
||||
char *narrowPublicId = XMLString::transcode ( publicID );
|
||||
std::string resolved;
|
||||
resolved = cr->lookupPublicId ( narrowPublicId );
|
||||
resolved = lookupPublicId ( narrowPublicId );
|
||||
|
||||
XMLString::release ( &narrowPublicId );
|
||||
|
||||
|
@ -87,5 +84,4 @@ InputSource *XercesCatalogResolver::resolveEntity (
|
|||
XMLString::release ( &wideResolved );
|
||||
|
||||
return source;
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -5,42 +5,23 @@
|
|||
#include <string>
|
||||
#include <xercesc/sax/EntityResolver.hpp>
|
||||
#include <xercesc/sax/InputSource.hpp>
|
||||
|
||||
#ifndef __WXMSW__
|
||||
#include <xercesc/sax/Locator.hpp>
|
||||
#include "catalogresolver.h"
|
||||
#endif
|
||||
|
||||
using namespace xercesc;
|
||||
|
||||
class XercesCatalogResolver : public EntityResolver
|
||||
class XercesCatalogResolver : public EntityResolver, public CatalogResolver
|
||||
{
|
||||
public:
|
||||
XercesCatalogResolver( std::string catalogPath = "",
|
||||
std::string catalogUtilityPath = "" )
|
||||
XercesCatalogResolver()
|
||||
{
|
||||
#ifndef __WXMSW__
|
||||
cr = new CatalogResolver ( catalogPath );
|
||||
#else
|
||||
myCatalogPath = catalogPath;
|
||||
myCatalogUtilityPath = catalogUtilityPath;
|
||||
#endif
|
||||
}
|
||||
~XercesCatalogResolver()
|
||||
{
|
||||
#ifndef __WXMSW__
|
||||
delete cr;
|
||||
#endif
|
||||
}
|
||||
InputSource *resolveEntity (
|
||||
virtual InputSource *resolveEntity (
|
||||
const XMLCh * const publicID,
|
||||
const XMLCh* const systemId );
|
||||
private:
|
||||
#ifndef __WXMSW__
|
||||
CatalogResolver *cr;
|
||||
#else
|
||||
std::string myCatalogPath;
|
||||
std::string myCatalogUtilityPath;
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -61,6 +61,7 @@
|
|||
#include <wx/tokenzr.h>
|
||||
#include <wx/dir.h>
|
||||
#include "xmlschemagenerator.h"
|
||||
#include "threadreaper.h"
|
||||
|
||||
#define ngettext wxGetTranslation
|
||||
|
||||
|
@ -218,6 +219,8 @@ MyApp::MyApp() : checker ( NULL ), server ( NULL ), connection ( NULL ),
|
|||
|
||||
MyApp::~MyApp()
|
||||
{
|
||||
ThreadReaper::get().clear();
|
||||
|
||||
delete checker;
|
||||
delete server;
|
||||
delete connection;
|
||||
|
@ -395,9 +398,6 @@ bool MyApp::OnInit()
|
|||
wxImage::AddHandler ( new wxPNGHandler );
|
||||
wxSystemOptions::SetOption ( _T ( "msw.remap" ), 0 );
|
||||
|
||||
// Initialize libxml
|
||||
WrapLibxml::Init();
|
||||
|
||||
// Initialize Xerces-C++
|
||||
WrapXerces::Init();
|
||||
|
||||
|
@ -599,9 +599,9 @@ const std::set<const wxLanguageInfo *> &MyApp::getAvailableTranslations (
|
|||
wxTranslations *t = wxTranslations::Get();
|
||||
if ( t != NULL )
|
||||
{
|
||||
translations = t->GetAvailableTranslations ( *catalog );
|
||||
wxArrayString::const_iterator trans = translations.begin();
|
||||
for ( ; trans != translations.end(); trans++ )
|
||||
wxArrayString all = t->GetAvailableTranslations ( *catalog );
|
||||
wxArrayString::const_iterator trans = all.begin();
|
||||
for ( ; trans != all.end(); trans++ )
|
||||
{
|
||||
info = wxLocale::FindLanguageInfo ( *trans );
|
||||
if ( info != NULL )
|
||||
|
@ -908,6 +908,9 @@ MyFrame::MyFrame (
|
|||
updatePaths();
|
||||
loadBitmaps();
|
||||
|
||||
// Initialize libxml
|
||||
WrapLibxml::Init ( catalogPath );
|
||||
|
||||
size_t findFlags = 0;
|
||||
findFlags |= wxFR_DOWN;
|
||||
|
||||
|
@ -2960,8 +2963,6 @@ void MyFrame::newDocument ( const std::string& s, const std::string& path, bool
|
|||
wxID_ANY,
|
||||
s.c_str(), // modified
|
||||
s.size(), // new
|
||||
catalogPath,
|
||||
catalogUtilityPath,
|
||||
path,
|
||||
auxPath );
|
||||
mainBook->AddPage ( ( wxWindow * ) doc, documentLabel );
|
||||
|
@ -3272,8 +3273,6 @@ bool MyFrame::openFile ( wxString& fileName, bool largeFile )
|
|||
wxID_ANY,
|
||||
finalBuffer,
|
||||
finalBufferLen,
|
||||
catalogPath,
|
||||
catalogUtilityPath,
|
||||
( const char * ) fileName.mb_str ( wxConvLocal ),
|
||||
auxPath );
|
||||
#ifdef __WXMSW__
|
||||
|
@ -3829,8 +3828,6 @@ void MyFrame::OnValidateDTD ( wxCommandEvent& event )
|
|||
if ( ( doc = getActiveDocument() ) == NULL )
|
||||
return;
|
||||
|
||||
updatePaths(); // needed to ensure catalog is available
|
||||
|
||||
wxString fname = doc->getFullFileName();
|
||||
|
||||
WrapTempFileName wtfn ( fname );
|
||||
|
@ -3856,7 +3853,7 @@ void MyFrame::OnValidateDTD ( wxCommandEvent& event )
|
|||
doc->clearErrorIndicators();
|
||||
statusProgress ( _ ( "DTD Validation in progress..." ) );
|
||||
|
||||
auto_ptr<WrapLibxml> wl ( new WrapLibxml ( libxmlNetAccess, catalogPath ) );
|
||||
auto_ptr<WrapLibxml> wl ( new WrapLibxml ( libxmlNetAccess ) );
|
||||
|
||||
if ( !wl->validate ( fnameLocal ) )
|
||||
{
|
||||
|
@ -3950,7 +3947,7 @@ void MyFrame::validateRelaxNG (
|
|||
doc->clearErrorIndicators();
|
||||
statusProgress ( _ ( "RELAX NG validation in progress..." ) );
|
||||
|
||||
auto_ptr<WrapLibxml> wl ( new WrapLibxml ( libxmlNetAccess, catalogPath ) );
|
||||
auto_ptr<WrapLibxml> wl ( new WrapLibxml ( libxmlNetAccess ) );
|
||||
|
||||
std::string schemaFileNameLocal = ( const char * ) schemaName.mb_str ( wxConvLocal );
|
||||
std::string fileNameLocal = ( const char * ) fileName.mb_str ( wxConvLocal );
|
||||
|
@ -4042,9 +4039,7 @@ void MyFrame::OnValidateSchema ( wxCommandEvent& event )
|
|||
statusProgress ( _ ( "Validation in progress..." ) );
|
||||
doc->clearErrorIndicators();
|
||||
|
||||
std::auto_ptr<WrapXerces> validator (
|
||||
new WrapXerces( catalogPath, catalogUtilityPath )
|
||||
);
|
||||
std::auto_ptr<WrapXerces> validator ( new WrapXerces() );
|
||||
std::string fileNameLocal = ( const char * ) fileName.mb_str ( wxConvLocal );
|
||||
if ( !validator->validate ( fileNameLocal ) )
|
||||
{
|
||||
|
@ -4131,7 +4126,7 @@ void MyFrame::OnXPath ( wxCommandEvent& event )
|
|||
rawBufferStream << rawBufferUtf8;
|
||||
rawBufferStream.close();
|
||||
|
||||
auto_ptr<WrapLibxml> wl ( new WrapLibxml ( libxmlNetAccess, catalogPath ) );
|
||||
auto_ptr<WrapLibxml> wl ( new WrapLibxml ( libxmlNetAccess ) );
|
||||
|
||||
bool success = wl->xpath ( valUtf8, tempFileName.name() );
|
||||
|
||||
|
@ -4276,7 +4271,7 @@ void MyFrame::OnXslt ( wxCommandEvent& event )
|
|||
|
||||
std::string stylefnameLocal = ( const char * ) path.mb_str ( wxConvLocal );
|
||||
|
||||
auto_ptr<WrapLibxml> wl ( new WrapLibxml ( libxmlNetAccess, catalogPath ) );
|
||||
auto_ptr<WrapLibxml> wl ( new WrapLibxml ( libxmlNetAccess ) );
|
||||
if ( !wl->xslt ( stylefnameLocal, tempFileName.name() ) )
|
||||
{
|
||||
std::string error = wl->getLastError();
|
||||
|
@ -4331,7 +4326,7 @@ void MyFrame::OnPrettyPrint ( wxCommandEvent& event )
|
|||
rawBufferStream << rawBufferUtf8;
|
||||
rawBufferStream.close();
|
||||
|
||||
auto_ptr<WrapLibxml> wl ( new WrapLibxml ( libxmlNetAccess, catalogPath ) );
|
||||
auto_ptr<WrapLibxml> wl ( new WrapLibxml ( libxmlNetAccess ) );
|
||||
bool success = wl->parse ( tempFileName.name(), true );
|
||||
|
||||
if ( !success )
|
||||
|
@ -5872,8 +5867,6 @@ void MyFrame::updatePaths()
|
|||
applicationDir + wxFileName::GetPathSeparator() + _T ( "catalog" ) +
|
||||
wxFileName::GetPathSeparator() + _T ( "catalog" );
|
||||
catalogPath = wideCatalogPath.mb_str ( wxConvLocal );
|
||||
wxString wideCatalogUtilityPath = applicationDir + wxFileName::GetPathSeparator() + _T ( "xmlcatalog" );
|
||||
catalogUtilityPath = wideCatalogUtilityPath.mb_str ( wxConvLocal );
|
||||
wxString wideXslDtdPath =
|
||||
applicationDir + wxFileName::GetPathSeparator() + _T ( "dtd" ) +
|
||||
wxFileName::GetPathSeparator() + _T ( "xslt10.dtd" );
|
||||
|
|
|
@ -376,7 +376,7 @@ class MyFrame : public wxFrame
|
|||
MyNotebook *mainBook;
|
||||
MyHtmlPane *htmlReport;
|
||||
|
||||
std::string catalogPath, catalogUtilityPath, xslDtdPath, rssDtdPath, lzxDtdPath, xtmDtdPath,
|
||||
std::string catalogPath, xslDtdPath, rssDtdPath, lzxDtdPath, xtmDtdPath,
|
||||
xliffDtdPath, aspellDataPath, aspellDictPath;
|
||||
std::pair<int, int> controlCoordinates;
|
||||
std::map<std::string, std::map<std::string, std::set<std::string> > >
|
||||
|
|
|
@ -55,20 +55,18 @@ XmlCtrl::XmlCtrl (
|
|||
wxWindowID id,
|
||||
const char *buffer, // could be NULL
|
||||
size_t bufferLen,
|
||||
const std::string& catalogPathParameter,
|
||||
const std::string& catalogUtilityPathParameter,
|
||||
const std::string& basePathParameter,
|
||||
const std::string& auxPathParameter,
|
||||
const wxPoint& position,
|
||||
const wxSize& size,
|
||||
long style ) : wxStyledTextCtrl ( parent, id, position, size, style ),
|
||||
type ( typeParameter ),
|
||||
protectTags ( protectTagsParameter ),
|
||||
visibilityState ( visibilityStateParameter ),
|
||||
catalogPath ( catalogPathParameter ),
|
||||
catalogUtilityPath ( catalogUtilityPathParameter ),
|
||||
basePath ( basePathParameter ),
|
||||
auxPath ( auxPathParameter )
|
||||
long style
|
||||
)
|
||||
: wxStyledTextCtrl ( parent, id, position, size, style )
|
||||
, type ( typeParameter )
|
||||
, protectTags ( protectTagsParameter )
|
||||
, visibilityState ( visibilityStateParameter )
|
||||
, basePath ( basePathParameter )
|
||||
, auxPath ( auxPathParameter )
|
||||
{
|
||||
validationThread = NULL;
|
||||
|
||||
|
@ -139,6 +137,8 @@ XmlCtrl::~XmlCtrl()
|
|||
if ( validationThread != NULL )
|
||||
{
|
||||
validationThread->PendingDelete();
|
||||
//validationThread->Delete();
|
||||
//delete validationThread;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1040,7 +1040,6 @@ void XmlCtrl::updatePromptMaps ( const char *buffer, size_t bufferLen )
|
|||
elementMap.clear();
|
||||
elementStructureMap.clear();
|
||||
std::auto_ptr<XmlPromptGenerator> xpg ( new XmlPromptGenerator (
|
||||
catalogPath,
|
||||
basePath,
|
||||
auxPath ) );
|
||||
xpg->parse ( buffer, bufferLen );
|
||||
|
@ -1979,9 +1978,7 @@ bool XmlCtrl::backgroundValidate (
|
|||
validationThread = new ValidationThread(
|
||||
GetEventHandler(),
|
||||
buffer,
|
||||
system,
|
||||
catalogPath.c_str(),
|
||||
catalogUtilityPath.c_str()
|
||||
system
|
||||
);
|
||||
|
||||
if ( validationThread->Create() != wxTHREAD_NO_ERROR
|
||||
|
|
|
@ -102,8 +102,6 @@ class XmlCtrl: public wxStyledTextCtrl
|
|||
wxWindowID id = wxID_ANY,
|
||||
const char *buffer = NULL,
|
||||
size_t bufferLen = 0,
|
||||
const std::string& catalogPath = "",
|
||||
const std::string& catalogUtilityPath = "",
|
||||
const std::string& basePath = "",
|
||||
const std::string& auxPath = "",
|
||||
const wxPoint &position = wxDefaultPosition,
|
||||
|
@ -163,7 +161,7 @@ class XmlCtrl: public wxStyledTextCtrl
|
|||
std::map<wxString, std::set<wxString> > elementMap;
|
||||
std::set<wxString> entitySet;
|
||||
std::map<wxString, wxString> elementStructureMap;
|
||||
std::string catalogPath, catalogUtilityPath, basePath, auxPath;
|
||||
std::string basePath, auxPath;
|
||||
XmlCtrlProperties properties;
|
||||
wxString getLastAttributeName ( int pos );
|
||||
int getAttributeStartPos ( int pos );
|
||||
|
|
|
@ -30,8 +30,6 @@ XmlDoc::XmlDoc (
|
|||
//const std::string& buffer,
|
||||
const char *buffer,
|
||||
size_t bufferLen,
|
||||
const std::string& catalogPath,
|
||||
const std::string& catalogUtilityPath,
|
||||
const std::string& basePath,
|
||||
const std::string& auxPath,
|
||||
const wxPoint &position,
|
||||
|
@ -46,8 +44,6 @@ XmlDoc::XmlDoc (
|
|||
id,
|
||||
buffer,
|
||||
bufferLen, // new
|
||||
catalogPath,
|
||||
catalogUtilityPath,
|
||||
basePath,
|
||||
auxPath,
|
||||
position,
|
||||
|
|
|
@ -38,8 +38,6 @@ class XmlDoc : public XmlCtrl
|
|||
//const std::string& buffer = DEFAULT_XML_DECLARATION_UTF8,
|
||||
const char *buffer = NULL,
|
||||
size_t bufferLen = 0,
|
||||
const std::string& catalogPath = "",
|
||||
const std::string& catalogUtilityPath = "",
|
||||
const std::string& basePath = "",
|
||||
const std::string& auxPath = "",
|
||||
const wxPoint& position = wxDefaultPosition,
|
||||
|
|
|
@ -44,13 +44,11 @@
|
|||
using namespace xercesc;
|
||||
|
||||
XmlPromptGenerator::XmlPromptGenerator (
|
||||
const std::string& catalogPath,
|
||||
const std::string& basePath,
|
||||
const std::string& auxPath ) : d ( new PromptGeneratorData() )
|
||||
{
|
||||
XML_SetUserData ( p, d.get() );
|
||||
d->p = p;
|
||||
d->catalogPath = catalogPath;
|
||||
d->basePath = basePath;
|
||||
d->auxPath = auxPath;
|
||||
d->isRootElement = true;
|
||||
|
@ -325,21 +323,10 @@ int XMLCALL XmlPromptGenerator::externalentityrefhandler (
|
|||
if ( publicId )
|
||||
stdPublicId = publicId;
|
||||
|
||||
CatalogResolver cr ( d->catalogPath );
|
||||
CatalogResolver cr;
|
||||
std::string stdSystemId = cr.lookupPublicId ( stdPublicId );
|
||||
|
||||
if ( !stdSystemId.empty() )
|
||||
{
|
||||
Replace::run ( stdSystemId, "file://", "", false );
|
||||
Replace::run ( stdSystemId, "%20", " ", false );
|
||||
|
||||
#ifdef __WXMSW__
|
||||
Replace::run ( stdSystemId, "//C:/", "C:\\", false );
|
||||
Replace::run ( stdSystemId, "/C:/", "C:\\", false );
|
||||
Replace::run ( stdSystemId, "/", "\\", false );
|
||||
#endif
|
||||
}
|
||||
else
|
||||
if ( stdSystemId.empty() )
|
||||
{
|
||||
if ( systemId )
|
||||
stdSystemId = systemId;
|
||||
|
|
|
@ -38,7 +38,7 @@ struct PromptGeneratorData : public ParserData
|
|||
std::map<wxString, std::set<wxString> > requiredAttributeMap;
|
||||
std::map<wxString, wxString> elementStructureMap;
|
||||
std::set<wxString> entitySet;
|
||||
std::string catalogPath, basePath, auxPath, rootElement;
|
||||
std::string basePath, auxPath, rootElement;
|
||||
bool isRootElement, grammarFound;
|
||||
unsigned attributeValueCutoff;
|
||||
XML_Parser p;
|
||||
|
@ -51,7 +51,6 @@ class XmlPromptGenerator : public WrapExpat
|
|||
{
|
||||
public:
|
||||
XmlPromptGenerator (
|
||||
const std::string& catalogPath = "",
|
||||
const std::string& basePath = "",
|
||||
const std::string& auxPath = "" );
|
||||
virtual ~XmlPromptGenerator();
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include <xercesc/parsers/XercesDOMParser.hpp>
|
||||
#include <xercesc/dom/DOMNamedNodeMap.hpp>
|
||||
#include <xercesc/dom/DOMAttr.hpp>
|
||||
#include "xercescatalogresolver.h"
|
||||
|
||||
const static size_t maxReservedSchemaBuffer = 1024 * 1024;
|
||||
const static size_t maxElementSchemaBuffer = 1024;
|
||||
|
@ -47,10 +48,12 @@ const wxString &XmlSchemaGenerator::generate ( Grammar::GrammarType grammarType,
|
|||
mElements.clear();
|
||||
mSchema.Clear();
|
||||
|
||||
XercesCatalogResolver catalogResolver;
|
||||
std::auto_ptr<XercesDOMParser> parser ( new XercesDOMParser() );
|
||||
parser->setDoNamespaces ( true );
|
||||
parser->setDoSchema ( true );
|
||||
parser->setValidationSchemaFullChecking ( false );
|
||||
parser->setEntityResolver ( &catalogResolver );
|
||||
|
||||
MemBufInputSource source ( ( const XMLByte * ) buffer, len,
|
||||
filepath.mb_str( wxConvLocal ) );
|
||||
|
|
Loading…
Reference in New Issue