- From: alan.garny at dpag.ox.ac.uk (Alan Garny)
- Subject: [cellml-dev] using InputFormatToMathML
- Date: Wed, 21 Jul 2010 10:12:28 +0100
Hi Lucian,
I am not sure whether the following is going to help you or not (I haven't
checked your exact requirements), but I thought I would nonetheless mention
some code that I wrote at some point:
[OpenCell]/DataCollector/CellMLInputServices.cpp and
[OpenCell]/DataCollector/CellMLInputServices.h, which you can find at:
http://cellml-opencell.hg.sourceforge.net/hgweb/cellml-opencell/cellml-openc
ell/file/cbed9143ab55/DataCollector.
Alan
>
-----Original Message-----
>
From: cellml-tools-developers-bounces at cellml.org [mailto:cellml-tools-
>
developers-bounces at cellml.org] On Behalf Of Lucian Smith
>
Sent: 20 July 2010 23:26
>
To: A list for the developers of CellML tools
>
Subject: Re: [cellml-dev] using InputFormatToMathML
>
>
Thanks! That was the information I needed to get InputFormatToMathML to
>
work.
>
>
However, now I'm stuck trying to add that math to a CellMLComponent. I
tried
>
upcasting the resulting domIElement to a mathml_domIMathMLElement, so I
>
could use 'AddMath', but there was no interface to do so:
>
>
nsCOMPtr<domIElement> mathml;
>
nsCString formstring = ToNSCString(formula);
>
MathMLInputServices mmlis;
>
rv = mmlis.InputFormatToMathML(doc, formstring, getter_AddRefs(mathml));
>
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);
>
>
So, is there some other way to either a) turn a domIElement into a
>
mathml_domIMathMLElement, or b) add a domIElement to a
>
cellml_apiICellMLComponent?
>
>
I also have a more theoretical question--I created a 'Model' with a
Bootstrap
>
thingy, and then created a new 'domIDocument' with the same bootstrap so
>
that InputFormatToMathML would work (as explained below).
>
But is there a domIDocument that it created already for the 'Model'? And
if so,
>
can I get it? *Should* I get it? I'm not sure why I would want to or
not.
>
>
Thanks again!
>
>
-Lucian
>
>
* Justin Marsh <j.marsh at auckland.ac.nz> [2010-07-20 04:40] writes:
>
> Hi Lucian,
>
>
>
> My apologies for the delay in replying. InputFormatToMathML does
>
> require a real domIDocument*, as this is used to generate the output
>
> domIElement*; domIElements must be resident in a domIDocument.
>
>
>
> If you have a domIDOMImplementation di, you should be able to use
>
> something like
>
>
>
> nsCOMPtr<domIDocumentType> dt;
>
> nsCOMPtr<domIDocument> doc;
>
> nsCString model("model"), none("");
>
> rv = di->CreateDocumentType(model, none, none, getter_AddRefs(dt)); rv
>
> = di->CreateDocument(none, model, dt, getter_AddRefs(doc));
>
>
>
> You can get a domIDOMImplementation object from (for example)
>
> cellml_apiICellMLBootstrap::DomImplementation
>
>
>
> Best Regards,
>
> Justin.
>
>
>
> Quoting Lucian Smith <lpsmith at spod-central.org>:
>
>
>
> >...anyone?
>
> >
>
> >* Lucian Smith <lpsmith at spod-central.org> [2010-07-15 21:55] writes:
>
> >>So, I have the following code:
>
> >>
>
> >> nsCOMPtr<domIElement> mathml;
>
> >> nsCString formstring("x = y");
>
> >> MathMLInputServices mmlis;
>
> >> rv = mmlis.InputFormatToMathML(NULL, formstring,
>
> >>getter_AddRefs(mathml));
>
> >>
>
> >>The return code is 2147942487, which if I translate to hex, I can
>
> >>find is either "NS_ERROR_ILLEGAL_VALUE" or "NS_ERROR_INVALID_ARG".
>
> >>*Which* argument, it won't tell me, but I'm guessing it's the NULL.
>
> >>
>
> >>Now, when I was translating the other way, NULL was fine:
>
> >>
>
> >> rv = mmlis.MathMLToInputFormat(input, NULL, indent, cinfix);
>
> >>
>
> >>but, I suppose, no longer.
>
> >>
>
> >>Since InputFormatToMathML is from OpenCell, not the API, I don't
>
> >>have any documentation at all, so I turn to you all and ask: am I
>
> >>right that it requires a real 'domIDocument*'? And if so, how do I go
about
>
making one?
>
> >>Do I make (I assume) a mathml_domIMathMLDocument and cast it? Is
>
> >>there a mathml_domIMathMLDocument factory somewhere?
>
> >>
>
> >>-Lucian
>
> >>_______________________________________________
>
> >>cellml-tools-developers mailing list
>
> >>cellml-tools-developers at cellml.org
>
> >>http://www.cellml.org/mailman/listinfo/cellml-tools-developers
>
> >_______________________________________________
>
> >cellml-tools-developers mailing list
>
> >cellml-tools-developers at cellml.org
>
> >http://www.cellml.org/mailman/listinfo/cellml-tools-developers
>
> >
>
>
>
>
>
>
>
> ----------------------------------------------------------------
>
> This message was sent using IMP, the Internet Messaging Program.
>
>
>
> _______________________________________________
>
> cellml-tools-developers mailing list
>
> cellml-tools-developers at cellml.org
>
> http://www.cellml.org/mailman/listinfo/cellml-tools-developers
>
_______________________________________________
>
cellml-tools-developers mailing list
>
cellml-tools-developers at cellml.org
>
http://www.cellml.org/mailman/listinfo/cellml-tools-developers
Archive powered by MHonArc 2.6.18.