A list for the developers of CellML tools

Text archives Help


[cellml-dev] using InputFormatToMathML


Chronological Thread 
  • From: ak.miller at auckland.ac.nz (Andrew Miller)
  • Subject: [cellml-dev] using InputFormatToMathML
  • Date: Wed, 11 Aug 2010 13:52:21 +1200

On 11/08/10 12:06, Lucian Smith wrote:
> * Andrew Miller<ak.miller at auckland.ac.nz> [2010-08-10 00:28] writes:
>>
>> Create a cellml_api::CellMLBootstrap (platform specific - I'm sure you
>> already know the XPCOM specific method). Call it cb.
>> model<- cb.createModel(widestring "1.1")
>> modelDE<- model.QueryInterface(interface cellml_api::CellMLDOMElement)
>> docEl<- modelDE.domElement
>> doc<- docEl.ownerDocument
>
> Success! Thank you! I had actually tried (and failed) to find something
> that would give me the document from an element--the fact that it's on
> Node, which is *not* a base class of anything else in the API is pretty
> annoying, and the solution above, while it works, is remarkably arcane.
> Where would someone even start looking in the documentation to discover
> this? Maybe it's an artifact of using the OpenCell bits. Anyway...

It has nothing to do with OpenCell; the reason the CellML API does not
have dom::Node as a base class, which was my preferred design, is that
various people didn't want to force implementers of the API to base the
entire API on the DOM, even though our implementation does this.

It later proved inconvenient to have such a strong separation between
the DOM and CellML API, so we added an optional interface to get from
CellML API objects to DOM objects, via CellMLDOMElement. If you want to
go from the model to an underlying DOM representation for a CellML
namespace element, CellMLDOMElement is the way to go.

>
> Speaking of the OpenCell bits, I have found that if the string I send
> InputFormatToMathML is wrong (if I send it 'x^2' instead of 'pow(x,2)',
> for example), it still returns 'success', but then sets the XML element to
> 'error'. This is pretty surprising! And also illegal CellML. I'm ending
> up with:
>
> <math xmlns="http://www.w3.org/1998/Math/MathML";>
> <error xmlns="http://www.cellml.org/tools/mathml-input/error#"; column="17"
> problem="syntax error"/>
> </math>

This is used internally by OpenCell - the intention is to allow OpenCell
to highlight where the error is to the user, but otherwise continue,
rather than failing outright. Checking for "error" elements is the best
way to identify the location of the errors.

>
> Is there any way besides checking to see if the root element name is
> 'error' to check for success? If the only two options are to get 'apply'
> or 'error' I can work with that; just want to be sure that's the intended
> design.

It was never really intended to be used outside of the specific use case
OpenCell puts it to.

We'll have to come up with a slightly better API design when we move the
code out of OpenCell and into the CellML API.

Best wishes,
Andrew




Archive powered by MHonArc 2.6.18.

Top of page