Skip to content

Commit b096544

Browse files
authored
Be stricter when it comes to detecting SED-ML files.
2 parents 15ca7eb + b47ef20 commit b096544

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/support/sedml/sedmlfile.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -217,14 +217,15 @@ SedmlFilePtr SedmlFile::create(const FilePtr &pFile)
217217
if (!fileContents.empty() && (fileContents[0] != '\0')) {
218218
auto *document = libsedml::readSedMLFromString(toString(fileContents).c_str());
219219

220-
// A non-SED-ML file results in our SED-ML document having at least one error, the first of which being of id
221-
// libsedml::SedNotSchemaConformant (e.g., a CellML file, i.e. an XML file, but not a SED-ML one) or
222-
// libsbml::XMLContentEmpty (e.g., a COMBINE archive, i.e. not an XML file). So, we use these facts to determine
223-
// whether our current SED-ML document is indeed a SED-ML file.
220+
// A non-SED-ML file results in our SED-ML document having at least one error. That error may be the result of a
221+
// malformed XML file (e.g., an HTML file is an XML-like file but not actually an XML file or a COMBINE archive
222+
// which is just not an XML file) or a valid XML file but not a SED-ML file (e.g., a CellML file is an XML file
223+
// but not a SED-ML file). So, we use these facts to determine whether our current SED-ML document is indeed a
224+
// SED-ML file.
224225

225226
if ((document->getNumErrors() == 0)
226-
|| ((document->getError(0)->getErrorId() != libsedml::SedNotSchemaConformant)
227-
&& (document->getError(0)->getErrorId() != libsbml::XMLContentEmpty))) {
227+
|| ((document->getError(0)->getErrorId() > libsbml::XMLErrorCodesUpperBound)
228+
&& (document->getError(0)->getErrorId() != libsedml::SedNotSchemaConformant))) {
228229
return SedmlFilePtr {new SedmlFile {pFile, document}};
229230
}
230231

0 commit comments

Comments
 (0)