A list for the developers of CellML tools

Text archives Help


[cellml-dev] MathElement -> MathApplyElement


Chronological Thread 
  • From: ak.miller at auckland.ac.nz (Andrew Miller)
  • Subject: [cellml-dev] MathElement -> MathApplyElement
  • Date: Tue, 15 Dec 2009 14:25:15 +1300

Lucian Smith wrote:
> So, I asked the list this, but nobody responded, and I'm still having the
> same issue and everything else seems to be working, so I thought I'd ask
> you:
Hi Lucian,

I didn't see any e-mail with that subject on the cellml-tools-developers
list - but anyway, I'm forwarding this there as well.

You cannot simply QueryInterface a MathMLMathElement to an apply element
to get the apply element child - the XML structure looks like this:

<component>
<math>
<apply>
...
You have the 'math' element (MathMLMathElement), and are trying to treat
it as an 'apply' element. There could be more than one apply element, so
if you want to see them all, you need to use the MathML API to iterate
over them from the MathMLMathElement.

Note that the CCGS now supports some models which have a piecewise as
the child of the math element (to support reset rules, where different
equations apply at different times), so it won't necessarily always be
an apply element that you find.

Best wishes,
Andrew



>
>> I am trying to call the cellml-to-infix bit from
>> OpenCell with the following code:
>>
>> nsCOMPtr<cellml_apiIMathContainer> mc(do_QueryInterface(component));
>> nsCOMPtr<cellml_apiIMathList> mathlist;
>> rv = mc->GetMath(getter_AddRefs(mathlist));
>> nsCOMPtr<cellml_apiIMathMLElementIterator> mli;
>> rv = mathlist->Iterate(getter_AddRefs(mli));
>> nsCOMPtr<mathml_domIMathMLElement> mathel;
>> rv = mli->Next(getter_AddRefs(mathel));
>> while(mathel != NULL) {
>> nsCString indent;
>> indent = "";
>> nsCString infix;
>> nsCOMPtr<mathml_domIMathMLApplyElement>
>> input(do_QueryInterface(mathel, &rv));
>> if (input != NULL) {
>> MathMLInputServices mmlis;
>> rv = mmlis.MathMLToInputFormat(input, NULL, indent, infix);
>> //Here's where we translate the MathML to Infix and figure out
>> whether it was
>> // an assignment rule or a rate rule.
>> cout << infix.get();
>> }
>> rv = mli->Next(getter_AddRefs(mathel));
>> }
>>
>> My thought was that the 'mathel' in question would be the root of the math
>> element in the model, and would necessarily be an 'apply' element. As
>> such, the 'do_QueryInterface' line would (in essence) cast the MathElement
>> to a MathApplyElement, which the mmlis needed. However, 'input' is always
>> NULL, and if I check rv, I get the code "NS_NOINTERFACE". I can imagine a
>> few different things that might be going wrong here--maybe the root math
>> element is *not* actually the 'apply' bit, or maybe what I think is
>> casting is not actually casting, or maybe I forgot to include something
>> somewhere like the components/ directory or... something else is going
>> wrong. Any ideas? Thank you all again!
>
> It's the 'nsCOMPtr<mathml_domIMathMLApplyElement>
> input(do_QueryInterface(mathel, &rv));' line that fails to convert the
> MathMLElement to a MathMLApplyElement. Any ideas? Is this the wrong
> thing to try to do?
>
> -Lucian





Archive powered by MHonArc 2.6.18.

Top of page