diff --git a/src/Makefile.am b/src/Makefile.am
index 8262b04..27e22b9 100755
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -68,11 +68,19 @@ nobase_xmlcopyeditor_DATA = png/*.png \
po/de/messages.mo \
po/ru/messages.mo \
po/es/messages.mo \
- po/zh_CN/messages.mo \
- po/zh_TW/messages.mo \
+ po/zh_CN/messages.mo \
+ po/zh_TW/messages.mo \
po/uk_UA/messages.mo \
- po/ca/messages.mo \
- po/en_us/messages.po
+ po/ca/messages.mo \
+ 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
diff --git a/src/Makefile.in b/src/Makefile.in
index 8684bb6..5c8632c 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -310,11 +310,19 @@ nobase_xmlcopyeditor_DATA = png/*.png \
po/de/messages.mo \
po/ru/messages.mo \
po/es/messages.mo \
- po/zh_CN/messages.mo \
- po/zh_TW/messages.mo \
- po/uk_UA/messages.mo \
- po/ca/messages.mo \
- po/en_us/messages.po
+ po/zh_CN/messages.mo \
+ po/zh_TW/messages.mo \
+ po/uk_UA/messages.mo \
+ po/ca/messages.mo \
+ 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
diff --git a/src/catalog/catalog b/src/catalog/catalog
index c70d072..2974552 100644
--- a/src/catalog/catalog
+++ b/src/catalog/catalog
@@ -1,21 +1,24 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/catalogresolver.cpp b/src/catalogresolver.cpp
index 8a0f34b..a88c2dd 100755
--- a/src/catalogresolver.cpp
+++ b/src/catalogresolver.cpp
@@ -20,19 +20,16 @@
#include
#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 libxml ( new WrapLibxml ( false, catalogPath ) );
- return wl->lookupPublicId ( publicId );
+ return WrapLibxml::lookupPublicId ( publicId );
}
diff --git a/src/catalogresolver.h b/src/catalogresolver.h
index 665d3fc..3a0c3b2 100755
--- a/src/catalogresolver.h
+++ b/src/catalogresolver.h
@@ -23,15 +23,13 @@
#include
#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
diff --git a/src/catalogresolverthread.cpp b/src/catalogresolverthread.cpp
index fd850ac..0e11e34 100755
--- a/src/catalogresolverthread.cpp
+++ b/src/catalogresolverthread.cpp
@@ -24,7 +24,7 @@ void *CatalogResolverThread::Entry()
{
wxCriticalSectionLocker locker ( catalogResolverCriticalSection );
- std::auto_ptr libxml ( new WrapLibxml ( false, myCatalogPath ) );
+ std::auto_ptr libxml ( new WrapLibxml ( false ) );
*mySystemIdPtr = libxml->lookupPublicId ( *myPublicIdPtr );
}
Exit();
diff --git a/src/pathresolver.cpp b/src/pathresolver.cpp
index d5c3b9f..3634613 100755
--- a/src/pathresolver.cpp
+++ b/src/pathresolver.cpp
@@ -19,25 +19,25 @@
#include
#include "pathresolver.h"
+#include
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() )
{
diff --git a/src/threadreaper.cpp b/src/threadreaper.cpp
index 1298642..563b921 100644
--- a/src/threadreaper.cpp
+++ b/src/threadreaper.cpp
@@ -27,13 +27,7 @@ ThreadReaper::ThreadReaper ()
ThreadReaper::~ThreadReaper ()
{
- //wxCriticalSectionLocker lock ( xmlcopyeditorCriticalSection );
-
- std::vector >::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 > threads = mList;
+ mList.clear();
+
+ xmlcopyeditorCriticalSection.Leave();
+
+ // It's safe to call wxThread::Wait() now
+ std::vector >::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();
+ }
+}
diff --git a/src/threadreaper.h b/src/threadreaper.h
index 2d5c35a..22abecc 100644
--- a/src/threadreaper.h
+++ b/src/threadreaper.h
@@ -34,6 +34,8 @@ public:
static ThreadReaper &get();
void add ( wxThread *thread );
+ // Kills all threads in the list.
+ void clear();
protected:
std::vector > mList;
diff --git a/src/validationthread.cpp b/src/validationthread.cpp
index 24ad894..79e0416 100644
--- a/src/validationthread.cpp
+++ b/src/validationthread.cpp
@@ -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 validator ( new WrapXerces(
- myCatalogPath,
- myCatalogUtilityPath ) );
+ std::auto_ptr validator ( new WrapXerces() );
if ( TestDestroy() )
{
diff --git a/src/validationthread.h b/src/validationthread.h
index 2e51ec2..543fbba 100644
--- a/src/validationthread.h
+++ b/src/validationthread.h
@@ -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 myPosition;
wxString myMessage;
diff --git a/src/wraplibxml.cpp b/src/wraplibxml.cpp
index 22f483f..320ed2b 100755
--- a/src/wraplibxml.cpp
+++ b/src/wraplibxml.cpp
@@ -26,62 +26,70 @@
#endif
#include
+#include
+#include
-void WrapLibxml::Init() throw()
+class Initializer
{
- static class Initializer
+public:
+ Initializer ( const std::string &catalogPath ) throw ()
{
- public:
- Initializer () throw ()
+ xmlSetGenericErrorFunc ( xmlGenericErrorContext,
+ &Initializer::OnXmlGenericError );
+
+ LIBXML_TEST_VERSION
+
+ xmlInitializeCatalog();
+ xmlLoadCatalog ( catalogPath.c_str() );
+
+ initGenericErrorDefaultFunc ( NULL );
+ }
+
+ ~Initializer ()
+ {
+ xsltCleanupGlobals();
+ xmlCatalogCleanup();
+ xmlCleanupParser();
+ }
+
+ static void XMLCDECL OnXmlGenericError (void *ctx, const char *msg, ...) throw()
+ {
+ va_list args;
+
+ size_t size = 128;
+ std::string buffer;
+ int chars;
+ for (;;)
{
- xmlSetGenericErrorFunc ( xmlGenericErrorContext, &Initializer::OnXmlGenericError );
+ buffer.resize ( size );
+ if ( buffer.size() < size )
+ throw std::runtime_error ( "Out of memory" );
- LIBXML_TEST_VERSION
- xmlInitializeCatalog();
+ va_start(args, msg);
+ chars = vsnprintf( (char *) buffer.c_str(), size, msg, args);
+ va_end(args);
- initGenericErrorDefaultFunc ( NULL );
- }
- ~Initializer ()
- {
- xsltCleanupGlobals();
- xmlCatalogCleanup();
- xmlCleanupParser();
- }
-
- static void XMLCDECL OnXmlGenericError (void *ctx, const char *msg, ...) throw()
- {
- va_list args;
-
- size_t size = 128;
- std::string buffer;
- int chars;
- for (;;)
+ if ( chars >= 0 && ( size_t ) chars < size )
{
- buffer.resize ( size );
- if ( buffer.size() < size )
- throw std::runtime_error ( "Out of memory" );
-
- va_start(args, msg);
- chars = vsnprintf( (char *) buffer.c_str(), size, msg, args);
- va_end(args);
-
- if ( chars >= 0 && ( size_t ) chars < size )
- {
- buffer.resize ( chars );
- throw std::runtime_error ( buffer );
- }
- if ( chars >= 0 )
- size = chars + 1;
- else
- throw std::runtime_error (
- std::string ( "Can't format message: " ) + msg );
+ buffer.resize ( chars );
+ throw std::runtime_error ( buffer );
}
+ if ( chars >= 0 )
+ size = chars + 1;
+ else
+ throw std::runtime_error (
+ 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;
+ wxString url ( s, wxConvUTF8 );
+ wxFileName file = wxFileSystem::URLToFileName ( url );
+ if ( file.IsFileReadable() )
+ ret = file.GetFullPath().mb_str ( wxConvLocal );
+ else
+ ret = s;
- it = strstr ( s, "file://" );
- if ( it )
- {
- s = it + 6;
- }
+ xmlFree ( s );
- ret = s;
-
- xmlFree ( original );
return ret;
}
diff --git a/src/wraplibxml.h b/src/wraplibxml.h
index 3259d72..4c24292 100755
--- a/src/wraplibxml.h
+++ b/src/wraplibxml.h
@@ -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
diff --git a/src/wrapxerces.cpp b/src/wrapxerces.cpp
index cac7687..971e23d 100755
--- a/src/wrapxerces.cpp
+++ b/src/wrapxerces.cpp
@@ -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;
}
diff --git a/src/wrapxerces.h b/src/wrapxerces.h
index 9a164a0..0b468f0 100755
--- a/src/wrapxerces.h
+++ b/src/wrapxerces.h
@@ -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 );
diff --git a/src/xercescatalogresolver.cpp b/src/xercescatalogresolver.cpp
index 27af756..4c59734 100755
--- a/src/xercescatalogresolver.cpp
+++ b/src/xercescatalogresolver.cpp
@@ -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,15 +69,12 @@ 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 );
-
+
if ( resolved.empty() )
return NULL;
@@ -87,5 +84,4 @@ InputSource *XercesCatalogResolver::resolveEntity (
XMLString::release ( &wideResolved );
return source;
-#endif
}
diff --git a/src/xercescatalogresolver.h b/src/xercescatalogresolver.h
index e6180bf..df5560d 100755
--- a/src/xercescatalogresolver.h
+++ b/src/xercescatalogresolver.h
@@ -5,42 +5,23 @@
#include
#include
#include
-
-#ifndef __WXMSW__
+#include
#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
diff --git a/src/xmlcopyeditor.cpp b/src/xmlcopyeditor.cpp
index 7b8e4a0..91b6daa 100755
--- a/src/xmlcopyeditor.cpp
+++ b/src/xmlcopyeditor.cpp
@@ -61,6 +61,7 @@
#include
#include
#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 &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 wl ( new WrapLibxml ( libxmlNetAccess, catalogPath ) );
+ auto_ptr 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 wl ( new WrapLibxml ( libxmlNetAccess, catalogPath ) );
+ auto_ptr 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 validator (
- new WrapXerces( catalogPath, catalogUtilityPath )
- );
+ std::auto_ptr 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 wl ( new WrapLibxml ( libxmlNetAccess, catalogPath ) );
+ auto_ptr 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 wl ( new WrapLibxml ( libxmlNetAccess, catalogPath ) );
+ auto_ptr 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 wl ( new WrapLibxml ( libxmlNetAccess, catalogPath ) );
+ auto_ptr 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" );
diff --git a/src/xmlcopyeditor.h b/src/xmlcopyeditor.h
index 62f90a5..fa228a5 100755
--- a/src/xmlcopyeditor.h
+++ b/src/xmlcopyeditor.h
@@ -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 controlCoordinates;
std::map > >
diff --git a/src/xmlctrl.cpp b/src/xmlctrl.cpp
index 695b3dd..13c6cb3 100755
--- a/src/xmlctrl.cpp
+++ b/src/xmlctrl.cpp
@@ -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 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
diff --git a/src/xmlctrl.h b/src/xmlctrl.h
index 54dd649..22a3626 100755
--- a/src/xmlctrl.h
+++ b/src/xmlctrl.h
@@ -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 > elementMap;
std::set entitySet;
std::map elementStructureMap;
- std::string catalogPath, catalogUtilityPath, basePath, auxPath;
+ std::string basePath, auxPath;
XmlCtrlProperties properties;
wxString getLastAttributeName ( int pos );
int getAttributeStartPos ( int pos );
diff --git a/src/xmldoc.cpp b/src/xmldoc.cpp
index da74eab..13d94ba 100755
--- a/src/xmldoc.cpp
+++ b/src/xmldoc.cpp
@@ -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,
diff --git a/src/xmldoc.h b/src/xmldoc.h
index dfdff86..d0a9bae 100755
--- a/src/xmldoc.h
+++ b/src/xmldoc.h
@@ -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,
diff --git a/src/xmlpromptgenerator.cpp b/src/xmlpromptgenerator.cpp
index 13e2ef9..edbd920 100755
--- a/src/xmlpromptgenerator.cpp
+++ b/src/xmlpromptgenerator.cpp
@@ -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;
diff --git a/src/xmlpromptgenerator.h b/src/xmlpromptgenerator.h
index 30289e3..ebbaa19 100755
--- a/src/xmlpromptgenerator.h
+++ b/src/xmlpromptgenerator.h
@@ -38,7 +38,7 @@ struct PromptGeneratorData : public ParserData
std::map > requiredAttributeMap;
std::map elementStructureMap;
std::set 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();
diff --git a/src/xmlschemagenerator.cpp b/src/xmlschemagenerator.cpp
index 7371e16..42d4c1e 100644
--- a/src/xmlschemagenerator.cpp
+++ b/src/xmlschemagenerator.cpp
@@ -25,6 +25,7 @@
#include
#include
#include
+#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 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 ) );