Skip to content

Commit 1617a73

Browse files
committed
Allow l1v5 namespace.
1 parent 447cc05 commit 1617a73

File tree

5 files changed

+63
-4
lines changed

5 files changed

+63
-4
lines changed

src/sedml/SedBase.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2233,7 +2233,7 @@ SedBase::read (LIBSBML_CPP_NAMESPACE_QUALIFIER XMLInputStream& stream)
22332233
if (i > -1)
22342234
{
22352235
std::string uri = xmlns->getURI(i);
2236-
if (uri == SEDML_XMLNS_L1V1 || uri == SEDML_XMLNS_L1V2 || uri == SEDML_XMLNS_L1V3 || uri == SEDML_XMLNS_L1V4)
2236+
if (uri == SEDML_XMLNS_L1V1 || uri == SEDML_XMLNS_L1V2 || uri == SEDML_XMLNS_L1V3 || uri == SEDML_XMLNS_L1V4 || uri == SEDML_XMLNS_L1V5)
22372237
{
22382238
error = false;
22392239
}

src/sedml/SedDocument.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3204,8 +3204,12 @@ SedDocument::writeXMLNS(LIBSBML_CPP_NAMESPACE_QUALIFIER XMLOutputStream&
32043204
xmlns.add(SEDML_XMLNS_L1V2);
32053205
else if (getVersion() == 3)
32063206
xmlns.add(SEDML_XMLNS_L1V3);
3207-
else
3207+
else if (getVersion() == 4)
32083208
xmlns.add(SEDML_XMLNS_L1V4);
3209+
else if (getVersion() == 5)
3210+
xmlns.add(SEDML_XMLNS_L1V5);
3211+
else
3212+
xmlns.add(SEDML_XMLNS_L1V5);
32093213

32103214
mSedNamespaces->setNamespaces(&xmlns);
32113215
thisNs = const_cast<LIBSBML_CPP_NAMESPACE_QUALIFIER XMLNamespaces *>(getNamespaces());
@@ -3218,8 +3222,12 @@ SedDocument::writeXMLNS(LIBSBML_CPP_NAMESPACE_QUALIFIER XMLOutputStream&
32183222
thisNs->add(SEDML_XMLNS_L1V2);
32193223
else if (getVersion() == 3)
32203224
thisNs->add(SEDML_XMLNS_L1V3);
3221-
else
3225+
else if (getVersion() == 4)
32223226
thisNs->add(SEDML_XMLNS_L1V4);
3227+
else if (getVersion() == 5)
3228+
thisNs->add(SEDML_XMLNS_L1V5);
3229+
else
3230+
thisNs->add(SEDML_XMLNS_L1V5);
32233231
}
32243232
else
32253233
{

src/sedml/SedNamespaces.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ SedNamespaces::initSedNamespace()
7676
case 4:
7777
mNamespaces->add(SEDML_XMLNS_L1V4);
7878
break;
79+
case 5:
80+
mNamespaces->add(SEDML_XMLNS_L1V5);
81+
break;
7982
}
8083
break;
8184
}
@@ -129,6 +132,7 @@ SedNamespaces::getSupportedNamespaces()
129132
result->add(new SedNamespaces(1,2));
130133
result->add(new SedNamespaces(1,3));
131134
result->add(new SedNamespaces(1,4));
135+
result->add(new SedNamespaces(1,5));
132136
return result;
133137
}
134138

@@ -201,6 +205,9 @@ SedNamespaces::getSedNamespaceURI(unsigned int level,
201205
case 4:
202206
uri = SEDML_XMLNS_L1V4;
203207
break;
208+
case 5:
209+
uri = SEDML_XMLNS_L1V5;
210+
break;
204211
}
205212
break;
206213
}
@@ -358,6 +365,12 @@ SedNamespaces::isValidCombination()
358365
declaredURI.assign(SEDML_XMLNS_L1V4);
359366
}
360367

368+
if (xmlns->hasURI(SEDML_XMLNS_L1V5))
369+
{
370+
++numNS;
371+
declaredURI.assign(SEDML_XMLNS_L1V5);
372+
}
373+
361374
// checks if the SED-ML Namespace is explicitly defined.
362375
for (int i=0; i < xmlns->getLength(); i++)
363376
{
@@ -420,6 +433,17 @@ SedNamespaces::isValidCombination()
420433
}
421434
}
422435
break;
436+
case 5:
437+
// the namespaces contains the sedml namespaces
438+
// check it is the correct ns for the level/version
439+
if (sedmlDeclared)
440+
{
441+
if (declaredURI != string(SEDML_XMLNS_L1V5))
442+
{
443+
valid = false;
444+
}
445+
}
446+
break;
423447
default:
424448
valid = false;
425449
break;

src/sedml/SedNamespaces.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,12 @@
4949
namespace LIBSEDML_CPP_NAMESPACE
5050
{
5151
const unsigned int SEDML_DEFAULT_LEVEL = 1;
52-
const unsigned int SEDML_DEFAULT_VERSION = 3;
52+
const unsigned int SEDML_DEFAULT_VERSION = 5;
5353
const char* const SEDML_XMLNS_L1V1 = "http://sed-ml.org/";
5454
const char* const SEDML_XMLNS_L1V2 = "http://sed-ml.org/sed-ml/level1/version2";
5555
const char* const SEDML_XMLNS_L1V3 = "http://sed-ml.org/sed-ml/level1/version3";
5656
const char* const SEDML_XMLNS_L1V4 = "http://sed-ml.org/sed-ml/level1/version4";
57+
const char* const SEDML_XMLNS_L1V5 = "http://sed-ml.org/sed-ml/level1/version5";
5758
}
5859
#else
5960
static const unsigned int SEDML_DEFAULT_LEVEL = 1;
@@ -62,6 +63,7 @@ static const char* const SEDML_XMLNS_L1V1 = "http://sed-ml.org/";
6263
static const char* const SEDML_XMLNS_L1V2 = "http://sed-ml.org/sed-ml/level1/version2";
6364
static const char* const SEDML_XMLNS_L1V3 = "http://sed-ml.org/sed-ml/level1/version3";
6465
static const char* const SEDML_XMLNS_L1V4 = "http://sed-ml.org/sed-ml/level1/version4";
66+
static const char* const SEDML_XMLNS_L1V5 = "http://sed-ml.org/sed-ml/level1/version5";
6567
#endif
6668

6769
#ifdef __cplusplus

tests/TestIssues.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,31 @@ TEST_CASE("Reading / Writing L1V4", "[sedml]")
144144
delete doc;
145145
}
146146

147+
TEST_CASE("Reading / Writing L1V5", "[sedml]")
148+
{
149+
std::string fileName = getTestFile("/test-data/noble_1962_local.sedml");
150+
SedDocument* doc = readSedMLFromFile(fileName.c_str());
151+
REQUIRE (doc->getNumErrors(LIBSEDML_SEV_ERROR) == 0);
152+
153+
154+
// convert to l1v5
155+
doc->setLevel(1); doc->setVersion(5);
156+
157+
// write to string
158+
SedWriter sw;
159+
std::string l1v5 = sw.writeSedMLToStdString(doc);
160+
REQUIRE(l1v5.find("version=\"5\"") != std::string::npos);
161+
162+
// don't need doc anymore
163+
delete doc;
164+
165+
// read back
166+
doc = readSedMLFromString(l1v5.c_str());
167+
REQUIRE(doc->getNumErrors(LIBSEDML_SEV_ERROR) == 0);
168+
169+
delete doc;
170+
}
171+
147172
TEST_CASE("Reading L1V4 curve should not require logY", "[sedml]")
148173
{
149174
std::string fileName = getTestFile("/test-data/issue_63.sedml");

0 commit comments

Comments
 (0)