A list for the developers of CellML tools

Text archives Help


[cellml-dev] MathElement -> MathApplyElement


Chronological Thread 
  • From: lpsmith at spod-central.org (Lucian Smith)
  • Subject: [cellml-dev] MathElement -> MathApplyElement
  • Date: Wed, 16 Dec 2009 00:52:36 +0000

* Andrew Miller <ak.miller at auckland.ac.nz> [2009-12-15 01:26] writes:
> 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.

I hadn't changed the subject line and replied an earlier post, so it
probably got lost there. No problem!

> 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.

Got it! And now everything works like I want it to! Amazing. Thanks
again!

> 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.

adrian_chandler_hodgkin_1970.cellml has a piecewise rule in it, but it
still uses an 'apply' element at the root, so that still works. Is that
not what you mean? And if so, does OpenCell support translating it to
infix, and if so, how?


I'm also slightly confused--I'm getting MathMLMathElement children by
using 'GetChildNodes', and then looping through them with Item. So I have
the code:

while(mathel != NULL) {
nsCOMPtr<domINodeList> nodes;
rv = mathel->GetChildNodes(getter_AddRefs(nodes));
PRUint32 length;
rv = nodes->GetLength(&length);
for (PRUint32 i=0; i<length; i++) {
nsCOMPtr<domINode> node;
rv = nodes->Item(i, getter_AddRefs(node));
nsCOMPtr<mathml_domIMathMLApplyElement> input(do_QueryInterface(node,
&rv));
if (input != NULL) {
nsCString indent;
indent = "";
nsCString cinfix;
MathMLInputServices mmlis;
rv = mmlis.MathMLToInputFormat(input, NULL, indent, cinfix);
cout << i << ": " << cinfix.get() << endl;
}
else {
cout << "Child node " << i << " of 'math' element not an 'apply'
element" << endl;
}
}
rv = mli->Next(getter_AddRefs(mathel));
}

And when it gets to this XML:

<math xmlns="http://www.w3.org/1998/Math/MathML";
cmeta:id="IStim_external_eq">
<apply id="IStim_external_eq">
<eq/>
<ci>IStimC</ci>
<ci>Istim</ci>
</apply>
</math>


It outputs:

Child node 0 of 'math' element not an 'apply' element
1: IStimC = {id: "IStim_external_eq"} Istim
Child node 2 of 'math' element not an 'apply' element

I think I've worked out that child node 2 is the "</apply>", but what is
child node 0?

-Lucian




Archive powered by MHonArc 2.6.18.

Top of page