diff --git a/biosimulators_utils/model_lang/cellml/cellml_1_1.xsd b/biosimulators_utils/model_lang/cellml/cellml_1_1.xsd new file mode 100644 index 00000000..b3f124e0 --- /dev/null +++ b/biosimulators_utils/model_lang/cellml/cellml_1_1.xsd @@ -0,0 +1,410 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/biosimulators_utils/model_lang/cellml/cellml_1_1_original.xsd b/biosimulators_utils/model_lang/cellml/cellml_1_1_original.xsd new file mode 100644 index 00000000..a256419b --- /dev/null +++ b/biosimulators_utils/model_lang/cellml/cellml_1_1_original.xsd @@ -0,0 +1,409 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/biosimulators_utils/model_lang/cellml/common/common-attribs.xsd b/biosimulators_utils/model_lang/cellml/common/common-attribs.xsd new file mode 100644 index 00000000..2a3011f6 --- /dev/null +++ b/biosimulators_utils/model_lang/cellml/common/common-attribs.xsd @@ -0,0 +1,41 @@ + + + + + + + This is the common attributes module for MathML. + Author: Stéphane Dalmas, INRIA. + + + + + + + + + + + + + + + + + + + + + diff --git a/biosimulators_utils/model_lang/cellml/common/math.xsd b/biosimulators_utils/model_lang/cellml/common/math.xsd new file mode 100644 index 00000000..c8e12147 --- /dev/null +++ b/biosimulators_utils/model_lang/cellml/common/math.xsd @@ -0,0 +1,130 @@ + + + + + + + This is an XML Schema module defining the "math" element of MathML. + Author: Stéphane Dalmas, INRIA. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/biosimulators_utils/model_lang/cellml/common/xlink-href.xsd b/biosimulators_utils/model_lang/cellml/common/xlink-href.xsd new file mode 100644 index 00000000..a386bc9f --- /dev/null +++ b/biosimulators_utils/model_lang/cellml/common/xlink-href.xsd @@ -0,0 +1,20 @@ + + + + This schema provides the XLink href attribute for use in the MathML2 + schema. Written by Max Froumentin, W3C. + + + + + + + + diff --git a/biosimulators_utils/model_lang/cellml/content/arith.xsd b/biosimulators_utils/model_lang/cellml/content/arith.xsd new file mode 100644 index 00000000..fdb508f7 --- /dev/null +++ b/biosimulators_utils/model_lang/cellml/content/arith.xsd @@ -0,0 +1,90 @@ + + + + + + + This is an XML Schema module for the "arithmetic" operators of content + MathML. + Author: Stéphane Dalmas, INRIA. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/biosimulators_utils/model_lang/cellml/content/calculus.xsd b/biosimulators_utils/model_lang/cellml/content/calculus.xsd new file mode 100644 index 00000000..1b8fdb0e --- /dev/null +++ b/biosimulators_utils/model_lang/cellml/content/calculus.xsd @@ -0,0 +1,146 @@ + + + + + + + This is an XML Schema module for the calculs operators of content + MathML. + Author: Stéphane Dalmas, INRIA. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/biosimulators_utils/model_lang/cellml/content/common-attrib.xsd b/biosimulators_utils/model_lang/cellml/content/common-attrib.xsd new file mode 100644 index 00000000..b0d599f4 --- /dev/null +++ b/biosimulators_utils/model_lang/cellml/content/common-attrib.xsd @@ -0,0 +1,30 @@ + + + + + + + This is the XML schema module defining common attributes for the + content part of MathML. + Authors: Stéphane Dalmas, INRIA. + + + + + + + + + + + diff --git a/biosimulators_utils/model_lang/cellml/content/constants.xsd b/biosimulators_utils/model_lang/cellml/content/constants.xsd new file mode 100644 index 00000000..a22548e2 --- /dev/null +++ b/biosimulators_utils/model_lang/cellml/content/constants.xsd @@ -0,0 +1,83 @@ + + + + + This is the XML Schema module for the basic constants of MathML content. + Author: Stéphane Dalmas. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/biosimulators_utils/model_lang/cellml/content/constructs.xsd b/biosimulators_utils/model_lang/cellml/content/constructs.xsd new file mode 100644 index 00000000..4cfc21af --- /dev/null +++ b/biosimulators_utils/model_lang/cellml/content/constructs.xsd @@ -0,0 +1,260 @@ + + + + + + + + This is an XML Schema module for the basic constructs of content MathML. + Author: Stéphane Dalmas, INRIA. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/biosimulators_utils/model_lang/cellml/content/elementary-functions.xsd b/biosimulators_utils/model_lang/cellml/content/elementary-functions.xsd new file mode 100644 index 00000000..b106f0d1 --- /dev/null +++ b/biosimulators_utils/model_lang/cellml/content/elementary-functions.xsd @@ -0,0 +1,117 @@ + + + + + + This is an XML Schema module for the elementary functions in content + MathML. + Author: Stéphane Dalmas, INRIA. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/biosimulators_utils/model_lang/cellml/content/functions.xsd b/biosimulators_utils/model_lang/cellml/content/functions.xsd new file mode 100644 index 00000000..11a5768d --- /dev/null +++ b/biosimulators_utils/model_lang/cellml/content/functions.xsd @@ -0,0 +1,73 @@ + + + + + + This is an XML Schema module for operators dealing with functions in content + MathML. + Author: Stéphane Dalmas, INRIA. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/biosimulators_utils/model_lang/cellml/content/linear-algebra.xsd b/biosimulators_utils/model_lang/cellml/content/linear-algebra.xsd new file mode 100644 index 00000000..eb62bcb6 --- /dev/null +++ b/biosimulators_utils/model_lang/cellml/content/linear-algebra.xsd @@ -0,0 +1,173 @@ + + + + + + + This is an XML Schema module for the linear algebra part of content MathML. + Author: Stéphane Dalmas, INRIA. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/biosimulators_utils/model_lang/cellml/content/logic.xsd b/biosimulators_utils/model_lang/cellml/content/logic.xsd new file mode 100644 index 00000000..6dac2abe --- /dev/null +++ b/biosimulators_utils/model_lang/cellml/content/logic.xsd @@ -0,0 +1,53 @@ + + + + + This is an XML Schema module for the logic operators of content MathML. + Author: Stéphane Dalmas, INRIA. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/biosimulators_utils/model_lang/cellml/content/relations.xsd b/biosimulators_utils/model_lang/cellml/content/relations.xsd new file mode 100644 index 00000000..87496e5c --- /dev/null +++ b/biosimulators_utils/model_lang/cellml/content/relations.xsd @@ -0,0 +1,55 @@ + + + + + This is an XML Schema module for the relational operators of content MathML. + Author: Stéphane Dalmas, INRIA. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/biosimulators_utils/model_lang/cellml/content/semantics.xsd b/biosimulators_utils/model_lang/cellml/content/semantics.xsd new file mode 100644 index 00000000..d337ee76 --- /dev/null +++ b/biosimulators_utils/model_lang/cellml/content/semantics.xsd @@ -0,0 +1,85 @@ + + + + + + + This is an XML Schema module for the "sematics" element of content MathML. + Author: Stéphane Dalmas, INRIA. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/biosimulators_utils/model_lang/cellml/content/sets.xsd b/biosimulators_utils/model_lang/cellml/content/sets.xsd new file mode 100644 index 00000000..7a7f7f68 --- /dev/null +++ b/biosimulators_utils/model_lang/cellml/content/sets.xsd @@ -0,0 +1,236 @@ + + + + + + + This is an XML Schema module for the part of content MathML dealing with + sets and lists. + Author: Stéphane Dalmas, INRIA. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/biosimulators_utils/model_lang/cellml/content/statistics.xsd b/biosimulators_utils/model_lang/cellml/content/statistics.xsd new file mode 100644 index 00000000..cf0f20e3 --- /dev/null +++ b/biosimulators_utils/model_lang/cellml/content/statistics.xsd @@ -0,0 +1,136 @@ + + + + + + + This is an XML Schema module for the statistical operators of content MathML. + Author: Stéphane Dalmas, INRIA. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/biosimulators_utils/model_lang/cellml/content/tokens.xsd b/biosimulators_utils/model_lang/cellml/content/tokens.xsd new file mode 100644 index 00000000..7e7f9b81 --- /dev/null +++ b/biosimulators_utils/model_lang/cellml/content/tokens.xsd @@ -0,0 +1,120 @@ + + + + + + + This is the XML schema module for the token elements of the + content part of MathML. + Author: Stéphane Dalmas, INRIA. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/biosimulators_utils/model_lang/cellml/content/vector-calculus.xsd b/biosimulators_utils/model_lang/cellml/content/vector-calculus.xsd new file mode 100644 index 00000000..3e5dd9ce --- /dev/null +++ b/biosimulators_utils/model_lang/cellml/content/vector-calculus.xsd @@ -0,0 +1,88 @@ + + + + + + + This is an XML Schema module for the vector calculs operators of content + MathML. + Author: Stéphane Dalmas, INRIA. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/biosimulators_utils/model_lang/cellml/mathml2.xsd b/biosimulators_utils/model_lang/cellml/mathml2.xsd new file mode 100644 index 00000000..2bd76bfb --- /dev/null +++ b/biosimulators_utils/model_lang/cellml/mathml2.xsd @@ -0,0 +1,59 @@ + + + + + + This is an XML Schema for MathML. + Author: Stéphane Dalmas, INRIA. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/biosimulators_utils/model_lang/cellml/presentation/action.xsd b/biosimulators_utils/model_lang/cellml/presentation/action.xsd new file mode 100644 index 00000000..96336985 --- /dev/null +++ b/biosimulators_utils/model_lang/cellml/presentation/action.xsd @@ -0,0 +1,44 @@ + + + + + + + This is the XML Schema module for the MathML "maction" element. + Author: Stéphane Dalmas, INRIA. + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/biosimulators_utils/model_lang/cellml/presentation/characters.xsd b/biosimulators_utils/model_lang/cellml/presentation/characters.xsd new file mode 100644 index 00000000..32b4d3f7 --- /dev/null +++ b/biosimulators_utils/model_lang/cellml/presentation/characters.xsd @@ -0,0 +1,37 @@ + + + + + + + This is the XML Schema module for the MathML "mglyph" element. + Author: Stéphane Dalmas, INRIA. + + + + + + + + + + + + + + + + + + + diff --git a/biosimulators_utils/model_lang/cellml/presentation/common-attribs.xsd b/biosimulators_utils/model_lang/cellml/presentation/common-attribs.xsd new file mode 100644 index 00000000..2dff7e33 --- /dev/null +++ b/biosimulators_utils/model_lang/cellml/presentation/common-attribs.xsd @@ -0,0 +1,113 @@ + + + + + + + This schema module defines sets of attributes common to several elements + of presentation MathML. + Author: Stéphane Dalmas, INRIA. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/biosimulators_utils/model_lang/cellml/presentation/common-types.xsd b/biosimulators_utils/model_lang/cellml/presentation/common-types.xsd new file mode 100644 index 00000000..a44c3bfc --- /dev/null +++ b/biosimulators_utils/model_lang/cellml/presentation/common-types.xsd @@ -0,0 +1,103 @@ + + + + + + + This is an XML Schema module containing some type definitions for MathML. + Author: Stéphane Dalmas, INRIA. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/biosimulators_utils/model_lang/cellml/presentation/error.xsd b/biosimulators_utils/model_lang/cellml/presentation/error.xsd new file mode 100644 index 00000000..01b5b960 --- /dev/null +++ b/biosimulators_utils/model_lang/cellml/presentation/error.xsd @@ -0,0 +1,40 @@ + + + + + + + This is the XML Schema module for the MathML "merror" element. + Author: Stéphane Dalmas, INRIA. + + + + + + + + + + + + + + + + + + + + + + diff --git a/biosimulators_utils/model_lang/cellml/presentation/layout.xsd b/biosimulators_utils/model_lang/cellml/presentation/layout.xsd new file mode 100644 index 00000000..80b005ef --- /dev/null +++ b/biosimulators_utils/model_lang/cellml/presentation/layout.xsd @@ -0,0 +1,195 @@ + + + + + + This is the XML schema module for the layout elements of the + presentation part of MathML. + Author: Stéphane Dalmas, INRIA. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/biosimulators_utils/model_lang/cellml/presentation/scripts.xsd b/biosimulators_utils/model_lang/cellml/presentation/scripts.xsd new file mode 100644 index 00000000..cf7eea15 --- /dev/null +++ b/biosimulators_utils/model_lang/cellml/presentation/scripts.xsd @@ -0,0 +1,186 @@ + + + + + + + This is an XML Schema module for the presentation elements of MathML + dealing with subscripts and superscripts. + Author: Stéphane Dalmas, INRIA. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/biosimulators_utils/model_lang/cellml/presentation/space.xsd b/biosimulators_utils/model_lang/cellml/presentation/space.xsd new file mode 100644 index 00000000..24373538 --- /dev/null +++ b/biosimulators_utils/model_lang/cellml/presentation/space.xsd @@ -0,0 +1,52 @@ + + + + + + + This is the XML Schema module for the MathML "mspace" element. + Author: Stéphane Dalmas, INRIA. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/biosimulators_utils/model_lang/cellml/presentation/style.xsd b/biosimulators_utils/model_lang/cellml/presentation/style.xsd new file mode 100644 index 00000000..a0181218 --- /dev/null +++ b/biosimulators_utils/model_lang/cellml/presentation/style.xsd @@ -0,0 +1,69 @@ + + + + + + + This is an XML Schema for the "mstyle" element of MathML. + Author: Stéphane Dalmas, INRIA. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/biosimulators_utils/model_lang/cellml/presentation/table.xsd b/biosimulators_utils/model_lang/cellml/presentation/table.xsd new file mode 100644 index 00000000..968f7bc8 --- /dev/null +++ b/biosimulators_utils/model_lang/cellml/presentation/table.xsd @@ -0,0 +1,216 @@ + + + + + + + This is an XML Schema module for tables in MathML presentation. + Author: Stéphane Dalmas, INRIA. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/biosimulators_utils/model_lang/cellml/presentation/tokens.xsd b/biosimulators_utils/model_lang/cellml/presentation/tokens.xsd new file mode 100644 index 00000000..56d156c6 --- /dev/null +++ b/biosimulators_utils/model_lang/cellml/presentation/tokens.xsd @@ -0,0 +1,124 @@ + + + + + + + This is the XML schema module for the token elements of the + presentation part of MathML. + Author: Stéphane Dalmas, INRIA. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/biosimulators_utils/model_lang/cellml/validation.py b/biosimulators_utils/model_lang/cellml/validation.py index 7907ebaf..bac5045f 100644 --- a/biosimulators_utils/model_lang/cellml/validation.py +++ b/biosimulators_utils/model_lang/cellml/validation.py @@ -69,6 +69,23 @@ def validate_model(filename, name=None, resolve_imports=True, config=None): return (errors, warnings, (model, root)) +def validate_doc_against_schema(doc, schema): + errors = [] + warnings = [] + if not schema.validate(doc): + for error in schema.error_log.filter_levels([lxml.etree.ErrorLevels.ERROR, lxml.etree.ErrorLevels.FATAL]): + errors.append([ + '{}.{}: {}'.format(error.line, error.column, error.message) + ]) + + for warning in schema.error_log.filter_levels(lxml.etree.ErrorLevels.WARNING): + warnings.append([ + '{}.{}: {}'.format(warning.line, warning.column, warning.message) + ]) + + return errors, warnings + + def validate_model_version_1_0(filename, doc, resolve_imports=True, config=None): """ Check that a file is a valid CellML 2.0 model @@ -98,24 +115,12 @@ def validate_model_version_1_0(filename, doc, resolve_imports=True, config=None) # biosimulators_utils/model_lang/cellml/mathml2.rng # ``` - errors = [] - warnings = [] - schema_filename = pkg_resources.resource_filename('biosimulators_utils', os.path.join("model_lang", "cellml", "cellml1.0.rng")) schema_doc = lxml.etree.parse(schema_filename) schema = lxml.etree.RelaxNG(schema_doc) - if not schema.validate(doc): - for error in schema.error_log.filter_levels([lxml.etree.ErrorLevels.ERROR, lxml.etree.ErrorLevels.FATAL]): - errors.append([ - '{}.{}: {}'.format(error.line, error.column, error.message) - ]) - - for warning in schema.error_log.filter_levels(lxml.etree.ErrorLevels.WARNING): - warnings.append([ - '{}.{}: {}'.format(warning.line, warning.column, warning.message) - ]) + errors, warnings = validate_doc_against_schema(doc, schema) return (errors, warnings, None) @@ -128,7 +133,6 @@ def validate_model_version_1_1(filename, doc, resolve_imports=True, config=None) doc (:obj:`lxml.etree._ElementTree`): XML document for file resolve_imports (:obj:`bool`, optional): whether to resolve imports config (:obj:`Config`, optional): whether to fail on missing includes - Returns: :obj:`tuple`: @@ -136,10 +140,28 @@ def validate_model_version_1_1(filename, doc, resolve_imports=True, config=None) * nested :obj:`list` of :obj:`str`: nested list of errors (e.g., required ids missing or ids not unique) * :obj:`None` """ - errors = [] - warnings = [] + # ``cellml_1_1_original.xsd`` was obtained from https://www.cellml.org/tools/cellml_1_1_schema + # `cellml_1_1.xsd`` was created by were directly downloading all referenced namspaces from + # https://www.cellml.org/tools/cellml_1_1_schema/common, + # https://www.cellml.org/tools/cellml_1_1_schema/content, + # https://www.cellml.org/tools/cellml_1_1_schema/presentation + # The original ``cellml_1_1.xsd`` was modified to change the http sources to local sources. + # Additionally, the following two lines were removed from the ``cellml_1_1_original.xsd``: 113, 309 + # These lines added the following to the definitions of "Component" and "Role": + # This caused lxml to fail to parse the schema due to it being nondeterministic. + # In its place, + # was added to allow using RDF syntax in the schema. The RDF is not validated. + # Finally, in common/common-attribs.xsd the type of the attribute "id" was changed from "ID" to "string". + # This was done to allow using numbers as ids for equations as described in the CellML primer. + + schema_filename = pkg_resources.resource_filename('biosimulators_utils', + os.path.join("model_lang", "cellml", "cellml_1_1.xsd")) + + xml_schema_doc = lxml.etree.parse(schema_filename) + + schema = lxml.etree.XMLSchema(xml_schema_doc) - warnings.append(['Validation is not available for CellML 1.1 files.']) + errors, warnings = validate_doc_against_schema(doc, schema) return (errors, warnings, None) diff --git a/setup.py b/setup.py index 08a404a0..9361ab41 100644 --- a/setup.py +++ b/setup.py @@ -21,6 +21,8 @@ name: [ os.path.join('utils', 'identifiers_org.json'), os.path.join('model_lang', 'cellml', '*.rng'), + os.path.join('model_lang', 'cellml', '*.xsd'), + os.path.join('model_lang', 'cellml', '**', '*.xsd'), os.path.join('viz', 'vega', '**', '*.json'), ], }