MathML JavaScript Question

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

MathML JavaScript Question

Matt Street
Hi,
 
I created a simple example (attached) to display MathML on an xhtml page using the xsl style sheets from the w3C website. I then altered the example to display the MathML through simple javascript document.write commands. However, the page seems to refresh itself to apply the PresentationMathML at which point it removes the lines written by the javascript so they are no longer displayed.
 
Am I doing something wrong? Is this a limitation of the style sheets? Any help will be gratefully received!!!
 
Cheers
 
Matt

Tester1.xhtml (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: MathML JavaScript Question

David Carlisle


> Am I doing something wrong? Is this a limitation of the style sheets?
> Any help will be gratefully received!!!

I don't think it's really the stylesheets so much as the difference
between scripting in an xml and html dom. You don't say which browser
you are using but the details are likely to be different unless your
javascript explicitly uses code to work cross browser.

In firefox for example you don't need the stylesheet at all to display
xhtml+mathml but your test file works in the same way (not displaying
the script) I think you need to generate the elements using suitable dom
calls to create the nodes rather than using document.write() in xhtml but
cross browser javascript isn't really my speciality, others may comment.
Note also that in an xhtml script element (unlike an html script
element) < will start an element tag rather than just standing for a <
character.

so

 <script>
      document.write("<math ...</math>");
</script>

will be parsed as

a script node with three child nodes,
1) a text node
'
      document.write("'
2) a child math element node
3) and a second text node
'
");
'

If you want to pass "<math xmlns=.... " as a _string_ to a javascript
function then you'd need
 <script><![CDATA[

...
]]></script>

so that < and & were not special. (This is not needed in html as in html
script and style are declared as CDATA elements, but the CDATA element
type does not exist in XML, so in XHTML you have to explictly escape
scripts that use < or &.

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
________________________________________________________________________

Reply | Threaded
Open this post in threaded view
|

Re: MathML JavaScript Question

Matt Street
In reply to this post by Matt Street
David,
 
Thanks for the reply, unfortunately clients default browser is IE!!! I did try putting the <!CDATA[ around my javascript, unfortunately when you do that it doesn't process the MathML that I am trying to write to the screen so I end up with 5 -1 rather than 5 sqroot -1!
 
I think I will be suggesting again that the client either uses the plugins!
 
Cheers
 
Matt
Reply | Threaded
Open this post in threaded view
|

Re: MathML JavaScript Question

David Carlisle


> Thanks for the reply, unfortunately clients default browser is IE!!!

Actually I meant to say that your code as posted seems to work fine in
IE (+mathplayer) (at least when I tried it earlier today) IE always uses
html when  rendering (even if it's using client side xml tools like
xslt) as it knows nothing about xhtml, so comments about differences
when scripting in xhtml are not relevant in that case (whcih makes
writing script that works on more than one browser "interesting".

Ah If they are using IE without mathplayer (not something I've tried for
a while) then yes I suppose pmathml.xsl would defer to pmathmlcss.xsl
which would try to do some fake mathml-in-css-and-javascript rendering
for the mathml elements that are explict but it wouldn't do teh right
thing at all for the document.write script as the styleshete has to
completely re-write the elements to html divs and spans that are then
css styled, an dthis needs to happen when the page is first parsed,
before any script runs, so the math elements would be inserted too late.

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
________________________________________________________________________

Reply | Threaded
Open this post in threaded view
|

Re: MathML JavaScript Question

Matt Street
In reply to this post by Matt Street
David,
 
Once again thanks for your time, but it's looking like this isn't going to be viable and I will have to see if there is another way to do it! I have been rereading the specification and the reason why they can't use plugins is that users may access this from library terminals where they are not allowed to install the plugins!
 
Back to the drawing board. . .
 
Cheers
 
Matt
Reply | Threaded
Open this post in threaded view
|

Re: MathML JavaScript Question

Matt Street
In reply to this post by Matt Street
Neil,
 
Nice thought, but that was my original suggestion, but there plan is to deliver content to users anywhere in America, so unless we can persuade all 'public terminals' to include MathPlayer (which I would support), or for oh say IE to support it, then as I said I don't believe this will work.
 
Cheers
 
Matt
Reply | Threaded
Open this post in threaded view
|

Re: MathML JavaScript Question

polx

Matt Street wrote:
> Nice thought, but that was my original suggestion, but there plan is to deliver content to users anywhere in America, so unless we can persuade all 'public terminals' to include MathPlayer (which I would support), or for oh say IE to support it, then as I said I don't believe this will work
Nice target!

But the problem is not solvable unless someone manages to convince
MicroSoft to include MathPlayer with every MSIE (and wait one or two
more years). Do I mistake?
You should add the requirement of the fonts for Mozilla installations.

If you still want to shoot extra-broad I suppose you have no other
choice than to target for greatest common divisor which could mean
generating html working with Netscape 4's and IE 5's faulty-CS or
embedding static pictures...

paul

Reply | Threaded
Open this post in threaded view
|

Re: MathML JavaScript Question

Matt Street
In reply to this post by Matt Street
Paul,
 
Thanks for the reply, we have indeed agreed with the clients that for the time being, and the fact that the don't use this that much, then we are going to produce pictures into an HTML page. Not my preferred option, but the client is happy.
 
Matt
Reply | Threaded
Open this post in threaded view
|

Re: MathML JavaScript Question

polx

Matt,

You definitely need to indicate to your clients the bad consequences of
such...
Such as bad-baseline, inconsistent font, non-accessibility (isn't there
a law on this?), low re-use...
I think there are tool which do the conversion MathML to picture...
How would you, then, add behaviours which was your intent, then, or ?

paul



Matt Street wrote:
> Thanks for the reply, we have indeed agreed with the clients that for the time being, and the fact that the don't use this that much, then we are going to produce pictures into an HTML page. Not my preferred option, but the client is happy.
>