Open kerimoyle opened 5 years ago
FYI: Soon the math in a component will need to be a complete sub-document so this
"<math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n"
should be this
"<math xmlns=\"http://www.w3.org/1998/Math/MathML\" xmlns:cell=\"http://www.cellml.org/cellml/2.0#\">\n"
to validate without errors.
Wouldn't it be sufficient to have something like:
<?xml version='1.0' encoding='UTF-8'?>
<model name="my_model" xmlns="http://www.cellml.org/cellml/1.0#" xmlns:cellml="http://www.cellml.org/cellml/2.0#">
<component name="my_component">
...
<math xmlns="http://www.w3.org/1998/Math/MathML">
...
<cn cellml:units="dimensionless">1</cn>
...
<cn cellml:units="my_unit">1</cn>
...
</math>
</component>
</model>
This is what we have in our CellML 1.0/1.1 models.
When parsing a file then yes your example is fine but when creating a model through the API with appending math strings the math in the component will need to be a complete sub-document requiring the declaration of the cellml xml namespace (if used).
Hmm, not sure I like that. From an enduser's perspective, I would expect the API to generate the CellML XML namespace for me automatically (using cellml
by default) , and to allow me to change that value, if I want.
This means that when adding math, I wouldn't have to worry about specifying that CellML XML namespace every time. Now, the downside of my approach is that you will have to use the same CellML XML namespace for the different math bits that I will add through the API, but that's something I would be ok with, as an enduser.
There in lies the problem what is the default namespace? A namespace generator might produce something like ns1
for the namespace.
I think whichever path we take we will need to document it accurately so that endusers know exactly what is expected. I am pro enduser doing less but against black box magic.
What is wrong with going with cellml
by default and allowing the user to change it if s/he wants? Thus, when serialising the model, libCellML will by default generate something like:
<?xml version='1.0' encoding='UTF-8'?>
<model name="my_model" xmlns="http://www.cellml.org/cellml/1.0#" xmlns:cellml="http://www.cellml.org/cellml/2.0#">
...
</model>
or something like this if we decide to use my_cellml_namespace
as the namespace instead:
<?xml version='1.0' encoding='UTF-8'?>
<model name="my_model" xmlns="http://www.cellml.org/cellml/1.0#" xmlns:my_cellml_namespace="http://www.cellml.org/cellml/2.0#">
...
</model>
Nothing wrong with it we just need to get agreement on how this issue is going to be dealt with.
@hsorby is there another namespace called just "cell" or was that a typo?
"<math xmlns=\"http://www.w3.org/1998/Math/MathML\" xmlns:cell=\"http://www.cellml.org/cellml/2.0#\">\n"
... and while the discussion is good, it's missing the point of this issue ... why does including maths from the API into an encapsulated component cause a segfault? It doesn't happen if the maths is in either of the other components ... ?
This segfault doesn't happen in the improved math validation that is waiting for review so it will go away once that gets merged!
OK, great :)
See test below: