2121
2222#include < dynadjust/dnaimport/dnainterop.hpp>
2323
24- // #include <include/io/DynaML-schema.hxx>
25-
2624using namespace dynadjust ::epsg;
2725
2826MsrTally g_map_tally;
@@ -400,18 +398,6 @@ void dna_import::ParseXML(const std::string& fileName, vdnaStnPtr* vStations, PU
400398 _filespecifiedreferenceframe = false ;
401399 _filespecifiedepoch = false ;
402400
403- // Check if DynaML.xsd exists in the current directory
404- // This prevents the XML parser from hanging when the schema file is missing
405- if (!std::filesystem::exists (" DynaML.xsd" ))
406- {
407- import_file_mutex.unlock ();
408- std::stringstream ss;
409- ss << " ParseXML(): DynaML.xsd schema file not found in the current directory." << std::endl;
410- ss << " The XML parser requires this file to validate XML input files." << std::endl;
411- ss << " Please ensure DynaML.xsd is present in the working directory." ;
412- SignalExceptionParse (ss.str (), 0 );
413- }
414-
415401 try
416402 {
417403 // Instantiate individual parsers.
@@ -473,7 +459,7 @@ void dna_import::ParseXML(const std::string& fileName, vdnaStnPtr* vStations, PU
473459 ::xml_schema::document doc_p (DnaXmlFormat_p, " DnaXmlFormat" );
474460
475461 DnaXmlFormat_p.pre ();
476- doc_p.parse (*ifsInputFILE_);
462+ doc_p.parse (*ifsInputFILE_, ::xml_schema::flags::dont_validate );
477463 DnaXmlFormat_p.post_DnaXmlFormat (vStations, vMeasurements);
478464
479465 // unlock after parsing
@@ -553,6 +539,7 @@ void dna_import::ParseXML(const std::string& fileName, vdnaStnPtr* vStations, PU
553539 {
554540 std::stringstream ss;
555541 ss << " The default input file reference frame \" " << referenceframe_p.str () << " \" is not recognised." ;
542+ import_file_mutex.unlock ();
556543 SignalExceptionParse (static_cast <std::string>(ss.str ()), 0 );
557544 }
558545
@@ -580,6 +567,7 @@ void dna_import::ParseXML(const std::string& fileName, vdnaStnPtr* vStations, PU
580567 }
581568 std::stringstream ss;
582569 ss << " ParseXML(): An std::ios_base failure was encountered while parsing " << fileName << " ." << std::endl << " " << f.what ();
570+ import_file_mutex.unlock ();
583571 SignalExceptionParse (static_cast <std::string>(ss.str ()), 0 );
584572 }
585573 catch (const std::system_error& e)
@@ -598,20 +586,22 @@ void dna_import::ParseXML(const std::string& fileName, vdnaStnPtr* vStations, PU
598586 }
599587 std::stringstream ss;
600588 ss << " ParseXML(): An std::ios_base failure was encountered while parsing " << fileName << " ." << std::endl << " " << e.what ();
589+ import_file_mutex.unlock ();
601590 SignalExceptionParse (static_cast <std::string>(ss.str ()), 0 );
602591 }
603- catch (const XMLInteropException& e)
592+ catch (const XMLInteropException& e)
604593 {
605594 std::stringstream ss;
606595 ss << " ParseXML(): An exception was encountered while parsing " << fileName << " ." << std::endl << " " << e.what ();
596+ import_file_mutex.unlock ();
607597 SignalExceptionParse (static_cast <std::string>(ss.str ()), 0 );
608598 }
609599 catch (const ::xml_schema::parsing& e)
610600 {
611601 std::stringstream ss (" " );
612602 ss << e.what ();
613603
614- ::xsd::cxx::parser::diagnostics<char >::const_iterator _it;
604+ ::xsd::cxx::parser::diagnostics<char >::const_iterator _it;
615605 for (_it=e.diagnostics ().begin (); _it!=e.diagnostics ().end (); _it++)
616606 {
617607 ss << std::endl;
@@ -620,19 +610,29 @@ void dna_import::ParseXML(const std::string& fileName, vdnaStnPtr* vStations, PU
620610 ss << " , severity " << _it->severity () << std::endl;
621611 ss << " - " << _it->message ();
622612 }
613+ import_file_mutex.unlock ();
623614 SignalExceptionParse (ss.str (), 0 );
624615 }
625616 catch (const ::xml_schema::exception& e)
626617 {
627618 std::stringstream ss;
628619 ss << " ParseXML(): An xml_schema exception was encountered while parsing " << fileName << " ." << std::endl << " " << e.what ();
620+ import_file_mutex.unlock ();
629621 SignalExceptionParse (static_cast <std::string>(ss.str ()), 0 );
630622 }
623+ catch (const std::exception& e)
624+ {
625+ std::stringstream ss;
626+ ss << " ParseXML(): An error was encountered while parsing " << fileName << " ." << std::endl << " " << e.what ();
627+ import_file_mutex.unlock ();
628+ SignalExceptionParse (ss.str (), 0 );
629+ }
631630 catch (...)
632631 {
633632 std::stringstream ss;
634633 ss << " ParseXML(): An unknown error was encountered while parsing " << fileName << " ." << std::endl;
635- SignalExceptionParse (ss.str (), 0 );
634+ import_file_mutex.unlock ();
635+ SignalExceptionParse (ss.str (), 0 );
636636 }
637637
638638 if (parseStatus_ != PARSE_SUCCESS)
0 commit comments