- From: lpsmith at spod-central.org (Lucian Smith)
- Subject: [cellml-dev] using InputFormatToMathML
- Date: Mon, 9 Aug 2010 23:54:42 +0100
* Andrew Miller <ak.miller at auckland.ac.nz> [2010-08-09 22:32] writes:
>
On 10/08/10 08:34, Lucian Smith wrote:
>
>OK, after poking at this a bit and not getting very far, I moved on to
>
>other things (and had more success there--more on that in a different
>
>email), but now I'm back to this bit. Unfortunately, I believe the code
>
>alan linked to, while interesting, is actually the code I'm trying to call
>
>myself, so is a level or to too deep to be instructive for my own problem.
>
>
>
>So, to recap: Does anyone know to do one of the following:
>
>
>
> - convert a 'domIElement' to a 'mathml_domIMathMLElement' so I can use
>
>AddMath
>
>
You should just be able to use QueryInterface if the element is in the
>
MathML namespace.
I did try this, but it failed... [sounds of rummaging around in code
again...]
er, OK. It actually didn't fail where I thought it had failed! Sigh. It
failed in the actual 'addMath' function, with the code 'failure'.
Rummaging around in gdb, I find that it actually fails at line 422 in
sources/dom_direct/DOMImplementation.cpp:
421 if (newChild->mDocument != mDocument)
422 throw iface::dom::DOMException();
This is mysterious to me, because I created my domIDocument exactly once,
and passed it in as the argument to the 'InputFormatToMathML' function:
nsCOMPtr<domIDocument> doc;
nsCOMPtr<domIDocumentType> dt;
nsString model = ToNSString("model");
nsString none = ToNSString("");
rv = domi->CreateDocumentType(model, none, none, getter_AddRefs(dt));
rv = domi->CreateDocument(none, model, dt, getter_AddRefs(doc));
[...]
AssignMathOnceFor(mapiter->second, doc);
which calls:
AddCellMLMathTo(formula, targetvar, doc)
which calls:
rv = mmlis.InputFormatToMathML(doc, formstring, getter_AddRefs(mathml));
NS_ENSURE_SUCCESS(rv, false);
nsCOMPtr<mathml_domIMathMLElement> recast_mathml;
rv = mathml->QueryInterface(recast_mathml->GetIID(),
getter_AddRefs(recast_mathml));
NS_ENSURE_SUCCESS(rv, false);
rv = upcast_cmlcomp->AddMath(recast_mathml);
NS_ENSURE_SUCCESS(rv, false);
(the last of which is failing)
And indeed, checking the value of the original 'doc' and the one I pass to
'InputFormatToMathML', I get the same pointer.
However, it's possibly illuminating that in DOMImplementation.cpp, that
value is different?
My code:
(gdb) p doc
$20 = {<nsCOMPtr_base> = {mRawPtr = 0x81df824}, <No data fields>}
DOMImplementation.cpp:
(gdb) p mDocument
$17 = (CDA_Document *) 0x81df248
(gdb) p newChild->mDocument
$18 = (CDA_Document *) 0x81df6b0
But maybe my problem is more systemic--does the 'CreateDocument' actually
add the model to the document in question? Or are they separate, and need
to be conjoined somehow?
-Lucian
Archive powered by MHonArc 2.6.18.