Skip to content

Commit

Permalink
Merge pull request #346 from ngageoint/remove-force-default-schema-pa…
Browse files Browse the repository at this point in the history
…th-check

check if the default schema path exists
  • Loading branch information
chvink authored Sep 8, 2020
2 parents af090e5 + dd3160a commit 28166d3
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions six/modules/c++/six/source/XMLControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,16 @@ void XMLControl::loadSchemaPaths(std::vector<std::string>& schemaPaths)
{
if (schemaPaths.empty())
{
const sys::OS os;

std::string envPath;
sys::OS().getEnvIfSet(six::SCHEMA_PATH, envPath);
os.getEnvIfSet(six::SCHEMA_PATH, envPath);
str::trim(envPath);
if (!envPath.empty())
{
schemaPaths.push_back(envPath);
}
else
else if (os.exists(DEFAULT_SCHEMA_PATH))
{
schemaPaths.push_back(DEFAULT_SCHEMA_PATH);
}
Expand All @@ -69,6 +71,15 @@ void XMLControl::validate(const xml::lite::Document* doc,
std::vector<std::string> paths(schemaPaths);
loadSchemaPaths(paths);

if (schemaPaths.empty() && log)
{
std::ostringstream oss;
oss << "Coudn't validate XML - no schemas paths provided "
<< " and " << six::SCHEMA_PATH << " not set.";

log->warn(oss.str());
}

sys::OS os;
// If the paths we have don't exist, throw
for (size_t ii = 0; ii < paths.size(); ++ii)
Expand Down Expand Up @@ -104,9 +115,12 @@ void XMLControl::validate(const xml::lite::Document* doc,
// log any error found and throw
if (!errors.empty())
{
for (size_t i = 0; i < errors.size(); ++i)
if (log)
{
log->critical(errors[i].toString());
for (size_t i = 0; i < errors.size(); ++i)
{
log->critical(errors[i].toString());
}
}

//! this is a unique error thrown only in this location --
Expand Down

0 comments on commit 28166d3

Please sign in to comment.