cellml / libcellml

Repository for libCellML development.
https://libcellml.org
Apache License 2.0
17 stars 21 forks source link

Request: allow import of CellML 1.0 and 1.1 models #969

Open luciansmith opened 3 years ago

luciansmith commented 3 years ago

Once libCellML is stable, I would like to use it to replace my old CellML API code in Antimony to allow CellML translation to and from Antimony and SBML.

As such, it would be great if it could import CellML 1.0 and 1.1 models, as I'm not going to have the bandwidth to write an additional translator, especially one that ferrets out all the referenced models and translates them as well. I could still use the library without it, but it would have severely reduced functionality, since all existing models are CellML 1.x

Thank you!

agarny commented 3 years ago

Hi @luciansmith, libCellML has always been targeted at CellML 2.0, so I can't see it ever allowing the import of CellML 1.0/1.1 models. libOpenCOR, on the other hand, will allow such an import. I am just starting work on it though... even though this will be one of the first things that I will do, obviously.

luciansmith commented 3 years ago

I don't want CellML 1.x objects; I just want to import and upconvert the document and get 2.0 objects. The spec library is definitely the place to share the ability to convert documents.

luciansmith commented 3 years ago

(The context for this is that David mentioned that there was an XSLT that upconverted 1.x to 2.0, and that since libcellml already links libxml2, it might be able to do this in the background if people needed it. Which I do!)

agarny commented 3 years ago

(The context for this is that David mentioned that there was an XSLT that upconverted 1.x to 2.0, and that since libcellml already links libxml2, it might be able to do this in the background if people needed it. Which I do!)

Indeed, it would be very easy to do. @hsorby and @nickerso, views?

hsorby commented 3 years ago

Yes, this is possible. The problem we face is the XSLT is version 2 and the support from libraries is not great. I have not looked at this recently with libXml2 but I think libXml2 doesn't fully support version 2 of XSLT. I currently use Saxon to do the conversion which does work. I will have to investigate this again as I cannot remember the exact details of what does and doesn't work.

luciansmith commented 3 years ago

Which is probably yet another good argument to why I shouldn't be working on converting these documents myself ;-)

hsorby commented 1 year ago

In the next release (tentatively 0.4.0) we will support importing CellML 1.0 and CellML 1.1 models. This is possible by creating a Parser and setting the strict mode to false. The simplest way to do this is create a Parser passing the strict flag directly to the object constructor.

For Python this would be done like so:

import libcellml
p = libcellml.Parser(False)

A strict parser will not parse CellML 1.0 or CellML 1.1 models (the current behaviour).