Discussion:
What can be used to update a MathML page in Mozilla browsers?
(too old to reply)
DKM
2005-05-16 02:34:19 UTC
Permalink
I need an equivalent for the following:

document.getElementById('equation').update(); from Mathplayer

to use it in Mozilla based browser.

When I change any text node, the page updates just fine in FireFox.
However, if I change an entire math element, as in the following:

eqElement = document.getElementById("equation");
a2Element = document.createElement("msup");
baseElement = document.createElement("mi");
powerElement = document.createElement("mo");
baseElementText = document.createTextNode("a");
powerElementText = document.createTextNode("2");
baseElement.appendChild(baseElementText);
powerElement.appendChild(powerElementText);
a2Element.appendChild(baseElement);
a2Element.appendChild(powerElement);
eqElement.appendChild(a2Element);


it does not update the page.

It does not update in Internet Explorer running Mathplayer either.
However, if I follow up the above code with the following:

document.getElementById('equation').update();

it works just fine.

The file is a XML file with the following declaration:

<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN"
"http://www.w3.org/TR/MathML2/dtd/xhtml-math11-f.dtd"
[<!ENTITY mathml "http://www.w3.org/1998/Math/MathML">
]>
<html xmlns="http://www.w3.org/1999/xhtml">

I will appreciate it if someone can she some light on this.

Thanks in advance.

D. K. Mishra
Roger B. Sidje
2005-05-16 02:56:31 UTC
Permalink
You need to use the MathML namespace (createElementNS).

var mmlns = "http://www.w3.org/1998/Math/MathML";
a2Element = document.createElementNS(mmlns, "msup");
...etc

The update happens in real-time (without an explicit .update()).
See, e.g., http://www.newmexico.mackichan.com/MathML/mmled.xml
---
RBS
Post by DKM
document.getElementById('equation').update(); from Mathplayer
to use it in Mozilla based browser.
When I change any text node, the page updates just fine in FireFox.
eqElement = document.getElementById("equation");
a2Element = document.createElement("msup");
baseElement = document.createElement("mi");
powerElement = document.createElement("mo");
baseElementText = document.createTextNode("a");
powerElementText = document.createTextNode("2");
baseElement.appendChild(baseElementText);
powerElement.appendChild(powerElementText);
a2Element.appendChild(baseElement);
a2Element.appendChild(powerElement);
eqElement.appendChild(a2Element);
it does not update the page.
It does not update in Internet Explorer running Mathplayer either.
document.getElementById('equation').update();
it works just fine.
<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN"
"http://www.w3.org/TR/MathML2/dtd/xhtml-math11-f.dtd"
[<!ENTITY mathml "http://www.w3.org/1998/Math/MathML">
]>
<html xmlns="http://www.w3.org/1999/xhtml">
I will appreciate it if someone can she some light on this.
Thanks in advance.
D. K. Mishra
_______________________________________________
Mozilla-mathml mailing list
http://mail.mozilla.org/listinfo/mozilla-mathml
DKM
2005-05-16 10:56:05 UTC
Permalink
Post by Roger B. Sidje
You need to use the MathML namespace (createElementNS).
var mmlns = "http://www.w3.org/1998/Math/MathML";
a2Element = document.createElementNS(mmlns, "msup");
...etc
The update happens in real-time (without an explicit .update()).
See, e.g., http://www.newmexico.mackichan.com/MathML/mmled.xml
---
RBS
But, I have already the namespace for <math> as below:

<math id="equation" xmlns="http://www.w3.org/1998/Math/MathML">
</math>

I wanted to populate the above <math> element as follows:

<math id="equation xmlns="http://www.w3.org/1998/Math/MathML">
<msup>
<mi>a</mi>
<mn>2</mn>
</msup>
</math>

by the following code:

eqElement = document.getElementById("equation");
a2Element = document.createElement("msup");
baseElement = document.createElement("mi");
powerElement = document.createElement("mo");
baseElementText = document.createTextNode("a");
powerElementText = document.createTextNode("2");
baseElement.appendChild(baseElementText);
powerElement.appendChild(powerElementText);
a2Element.appendChild(baseElement);
a2Element.appendChild(powerElement);
eqElement.appendChild(a2Element);

It works fine with the following:

<math id="equation" xmlns="http://www.w3.org/1998/Math/MathML">
<msup>
<mi>a</mi>
<mn>2</mn>
</msup>
</math>

So, given the following:

<math id="equation" xmlns="http://www.w3.org/1998/Math/MathML">
</math>

I should be able to create element without thename space attributes and
append to the 'equation' element. But, it does not seem to work.

I will definitely look at what you are suggesting and see if that
works.

Thanks in advance.

D. K. Mishra
Post by Roger B. Sidje
Post by DKM
document.getElementById('equation').update(); from Mathplayer
to use it in Mozilla based browser.
When I change any text node, the page updates just fine in FireFox.
eqElement = document.getElementById("equation");
a2Element = document.createElement("msup");
baseElement = document.createElement("mi");
powerElement = document.createElement("mo");
baseElementText = document.createTextNode("a");
powerElementText = document.createTextNode("2");
baseElement.appendChild(baseElementText);
powerElement.appendChild(powerElementText);
a2Element.appendChild(baseElement);
a2Element.appendChild(powerElement);
eqElement.appendChild(a2Element);
it does not update the page.
It does not update in Internet Explorer running Mathplayer either.
document.getElementById('equation').update();
it works just fine.
<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN"
"http://www.w3.org/TR/MathML2/dtd/xhtml-math11-f.dtd"
Post by Roger B. Sidje
Post by DKM
[<!ENTITY mathml
"http://www.w3.org/1998/Math/MathML">
Post by Roger B. Sidje
Post by DKM
]>
<html xmlns="http://www.w3.org/1999/xhtml">
I will appreciate it if someone can she some light on this.
Thanks in advance.
D. K. Mishra
_______________________________________________
Mozilla-mathml mailing list
http://mail.mozilla.org/listinfo/mozilla-mathml
David Carlisle
2005-05-16 11:16:56 UTC
Permalink
I should be able to create element without thename space attributes and
append to the 'equation' element. But, it does not seem to work.


No, you want to generate msup in the mathml namespace not in
no-namespace.

Your quoted fragment


<math id="equation" xmlns="http://www.w3.org/1998/Math/MathML">
<msup>
<mi>a</mi>
<mn>2</mn>
</msup>
</math>

is equivalent (acording to the namespace rec and namespace aware API)
to

<math id="equation" xmlns="http://www.w3.org/1998/Math/MathML">
<msup xmlns="http://www.w3.org/1998/Math/MathML">
<mi xmlns="http://www.w3.org/1998/Math/MathML">a</mi>
<mn xmlns="http://www.w3.org/1998/Math/MathML">2</mn>
</msup>
</math>

If you gnerate a child of math in no-namespace then that is equivalent to


<math id="equation" xmlns="http://www.w3.org/1998/Math/MathML">
<msup xmlns="">
<mi xmlns="">a</mi>
<mn xmlns="">2</mn>
</msup>
</math>

which wouldn't render in Mozilla and wouldn't validate to the MathML
Schema (or DTD).

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________
DKM
2005-05-16 13:07:48 UTC
Permalink
Post by DKM
I should be able to create element without thename space attributes and
append to the 'equation' element. But, it does not seem to work.
No, you want to generate msup in the mathml namespace not in
no-namespace.
Okay. I made some correction as suggested by you and Roger.

First, i changed the following

<html xmlns="http://www.w3.org/1999/xhtml">

to

<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:m="http://www.w3.org/1998/Math/MathML">

Then I changed

<math id="equation" xmlns="http://www.w3.org/1999/xhtml">
<msub>
<mi>b</mi>
<mn>2</mn>
</msub>
</math>

to

<m:math id="equation">
<m:msub>
<m:mi>b</m:mi>
<m:mn>2</m:mn>
</m:msub>
</m:math>

It displays fine as math.

Now I applied the script

eqElement = document.getElementById("equat­ion");
a2Element = document.createElement("m:msup")­;
baseElement = document.createElement("m:mi");
powerElement = document.createElement("m:mo");
baseElementText = document.createTextNode("a");
powerElementText = document.createTextNode("2");
baseElement.appendChild(baseEl­ementText);
powerElement.appendChild(power­ElementText);
a2Element.appendChild(baseElem­ent);
a2Element.appendChild(powerEle­ment);
eqElement.appendChild(a2Elemen­t);

And, still it did not work. It displays b squared followed by a2 not a
squared.

The other gentleman, Roger, said I should do
document.createElementNS(ns,sub) and such. But, I did not find any such
methoss for document in DOM. I did find setAttibutNS. I tried creating
elements and setting namespace attributes using setAttributesNS, but
that too did not work.

I am at a loss.

Thanks again for the help and hope to hear if there isany other hack
for this.

D.K. Mishra
Post by DKM
Your quoted fragment
<math id="equation" xmlns="http://www.w3.org/1998/Math/MathML">
<msup>
<mi>a</mi>
<mn>2</mn>
</msup>
</math>
is equivalent (acording to the namespace rec and namespace aware API)
to
<math id="equation" xmlns="http://www.w3.org/1998/Math/MathML">
<msup xmlns="http://www.w3.org/1998/Math/MathML">
<mi xmlns="http://www.w3.org/1998/Math/MathML">a</mi>
<mn xmlns="http://www.w3.org/1998/Math/MathML">2</mn>
</msup>
</math>
If you gnerate a child of math in no-namespace then that is
equivalent to
Post by DKM
<math id="equation" xmlns="http://www.w3.org/1998/Math/MathML">
<msup xmlns="">
<mi xmlns="">a</mi>
<mn xmlns="">2</mn>
</msup>
</math>
which wouldn't render in Mozilla and wouldn't validate to the MathML
Schema (or DTD).
David
________________________________________________________________________
Post by DKM
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a
proactive
Post by DKM
http://www.star.net.uk
________________________________________________________________________
DKM
2005-05-16 15:38:35 UTC
Permalink
Post by DKM
I should be able to create element without thename space attributes and
append to the 'equation' element. But, it does not seem to work.
No, you want to generate msup in the mathml namespace not in
no-namespace.
Thank you and also thanks to Roger for the above suggestion, I have it
working now. Sorry about my earlier response where I said
createElementNS is not part of document methods. I said that because my
editor was using IE as the browser and throwing errors on
createElementNS. But, it works fine with FireFox 1.0.3.

If you don't mind, are you a mathematician or programmer or both?

Thank you for your time and help.

D.K. Mishra
Post by DKM
Your quoted fragment
<math id="equation" xmlns="http://www.w3.org/1998/Math/MathML">
<msup>
<mi>a</mi>
<mn>2</mn>
</msup>
</math>
is equivalent (acording to the namespace rec and namespace aware API)
to
<math id="equation" xmlns="http://www.w3.org/1998/Math/MathML">
<msup xmlns="http://www.w3.org/1998/Math/MathML">
<mi xmlns="http://www.w3.org/1998/Math/MathML">a</mi>
<mn xmlns="http://www.w3.org/1998/Math/MathML">2</mn>
</msup>
</math>
If you gnerate a child of math in no-namespace then that is
equivalent to
Post by DKM
<math id="equation" xmlns="http://www.w3.org/1998/Math/MathML">
<msup xmlns="">
<mi xmlns="">a</mi>
<mn xmlns="">2</mn>
</msup>
</math>
which wouldn't render in Mozilla and wouldn't validate to the MathML
Schema (or DTD).
David
________________________________________________________________________
Post by DKM
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a
proactive
Post by DKM
http://www.star.net.uk
________________________________________________________________________
David Carlisle
2005-05-16 15:52:11 UTC
Permalink
If you don't mind, are you a mathematician or programmer or both?

Why the question?:-)

I used to be a research mathematician, these days I'm more of an XML
person (not sure if that makes me a programmer) In particular I'm an
editor of the MathML 2 spec, and co-chair of the W3C Math IG, which is
why I'm on this list.

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________
DKM
2005-05-16 16:40:32 UTC
Permalink
Post by DKM
If you don't mind, are you a mathematician or programmer or both?
Why the question?:-)
I used to be a research mathematician, these days I'm more of an XML
person (not sure if that makes me a programmer) In particular I'm an
editor of the MathML 2 spec, and co-chair of the W3C Math IG, which is
why I'm on this list.
David
I was just curious. I can't imagine any non-mathematician getting
involved in MathML. Given your math background, you are in a very good
position in any W3C group that is working towords MathML. I have read a
quite a bit of your helpful tips by you and also Roger in this
newsgroup's archives. I was also aware of your math stylesheets and
have tried them too. But, I prefer Mathplayer in IE and ofcourse the
native MathML support in Mozilla based browsers. I am new to XML, XHTML
and also to MathML. My knowledge is limited to what I have learnt in
last month or two. But, I am catching up fast. I will be taking up SVG
and see how that serves in serving math on the web. SVG should be
helpful in presenting geometry and such.

I am using google web site to post and read messages in this newsgroup.
I suppose the messages are automatically distributed to your list.

Again thank you very much.

D.K. Mishra
________________________________________________________________________
Post by DKM
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a
proactive
Post by DKM
http://www.star.net.uk
________________________________________________________________________
DKM
2005-05-16 15:33:58 UTC
Permalink
Post by Roger B. Sidje
You need to use the MathML namespace (createElementNS).
var mmlns = "http://www.w3.org/1998/Math/MathML";
a2Element = document.createElementNS(mmlns, "msup");
...etc
The update happens in real-time (without an explicit .update()).
See, e.g., http://www.newmexico.mackichan.com/MathML/mmled.xml
---
RBS
Good news! I got it working applying your suggestion.

Earlier in another response to David, I had posted that createElementNS
does not seem like a document method. I said that because I em editing
my files in EditPlus which uses IE as its browser. It appears that IE
does not recognize createElementNS and gives an error. FireFox,
however, supports createElementNS and implements it as it supposed to.
I will ask in a different IE related group now why IE does not support
createElementNS and what hacks are there to support it.

Thank you very much in advance.

D.K. Mishra
Post by Roger B. Sidje
Post by DKM
document.getElementById('equation').update(); from Mathplayer
to use it in Mozilla based browser.
When I change any text node, the page updates just fine in FireFox.
eqElement = document.getElementById("equation");
a2Element = document.createElement("msup");
baseElement = document.createElement("mi");
powerElement = document.createElement("mo");
baseElementText = document.createTextNode("a");
powerElementText = document.createTextNode("2");
baseElement.appendChild(baseElementText);
powerElement.appendChild(powerElementText);
a2Element.appendChild(baseElement);
a2Element.appendChild(powerElement);
eqElement.appendChild(a2Element);
it does not update the page.
It does not update in Internet Explorer running Mathplayer either.
document.getElementById('equation').update();
it works just fine.
<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN"
"http://www.w3.org/TR/MathML2/dtd/xhtml-math11-f.dtd"
Post by Roger B. Sidje
Post by DKM
[<!ENTITY mathml
"http://www.w3.org/1998/Math/MathML">
Post by Roger B. Sidje
Post by DKM
]>
<html xmlns="http://www.w3.org/1999/xhtml">
I will appreciate it if someone can she some light on this.
Thanks in advance.
D. K. Mishra
_______________________________________________
Mozilla-mathml mailing list
http://mail.mozilla.org/listinfo/mozilla-mathml
DKM
2005-05-16 11:35:55 UTC
Permalink
Post by DKM
document.getElementById('equation').update(); from Mathplayer
to use it in Mozilla based browser.
When I change any text node, the page updates just fine in FireFox.
eqElement = document.getElementById("equation");
a2Element = document.createElement("msup");
baseElement = document.createElement("mi");
powerElement = document.createElement("mo");
baseElementText = document.createTextNode("a");
powerElementText = document.createTextNode("2");
baseElement.appendChild(baseElementText);
powerElement.appendChild(powerElementText);
a2Element.appendChild(baseElement);
a2Element.appendChild(powerElement);
eqElement.appendChild(a2Element);
it does not update the page.
A little correction here. It updates the math element. But, it does not
display it mathematically.

Starting from

<math id="eq1" xmlns="http://www.w3.org/1998/Math/MathML">
</math>

I get the following:

<math id="eq1" xmlns="http://www.w3.org/1998/Math/MathML">
<msup>
<mi>a</mi>
<mn>2</mn>
</msup>
</math>

Which is what I wanted. But, the browser does not display the math.

D.K. Mishra
Post by DKM
It does not update in Internet Explorer running Mathplayer either.
document.getElementById('equation').update();
it works just fine.
<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN"
"http://www.w3.org/TR/MathML2/dtd/xhtml-math11-f.dtd"
[<!ENTITY mathml
"http://www.w3.org/1998/Math/MathML">
Post by DKM
]>
<html xmlns="http://www.w3.org/1999/xhtml">
I will appreciate it if someone can she some light on this.
Thanks in advance.
D. K. Mishra
Loading...