468,505 Members | 1,768 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,505 developers. It's quick & easy.

Trouble with mathml (either style or source)

I'm trying to build some mathml for a paper. I've got the mathml2 dtd,
and the style sheets also from the canonical website
http://www.w3.org/Math/. But I'm having some trouble. I've input the
example from page 90 of the mathml handbook, which is a simple bounded
integral. The mathml is as follows, where I've substituted the
numerical values for the named entities:-

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE math SYSTEM "../mathml2/mathml2.dtd">
<math
xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<munderover>
<mo>&#x0222B;</mo>
<mi>a</mi>
<mi>b</mi>
</munderover>
<mi>f</mi>
<mo>&#x02061;</mo>
<mrow>
<mo>(</mo><mi>x</mi><mo>)</mo>
</mrow>
<mo>&#x02146;</mo><mi>x</mi>
</mrow>
</math>

The result of applying the mathml.xsl stylesheet, using pmathmlcss.xsl
in place of pmathml.xsl, is given below. However, this doesn't display
as the book shows it. The integral and its limits look fine, but the
function f(x) appears underneath it instead of to the right. IE 6 and
Mozilla 0.9.9 both display it the same way, so I guess there must be
something wrong with the original markup. Any idea what?

<span xmlns:m="http://www.w3.org/1998/Math/MathML" id="d0e1"
class="mrow"><span id="d0e3" class="mrow">
<table class="munderover">
<tr>
<td><span class="mi1">b</span></td>
</tr>
<tr>
<td><span id="d0e7" class="mo">∫</span></td>
</tr>
<tr>
<td><span class="mi1">a</span></td>
</tr>
</table><span class="mi1">f</span><span id="d0e20"
class="mrow"><span id="d0e22" class="mo">(</span><span
class="mi1">x</span><span id="d0e26"
class="mo">)</span></span><script>
var mrowH = d0e20.offsetHeight;

mrowStretch(d0e22,"æ","ç","ç","è");
mrowStretch(d0e26,"ö","÷","÷","ø");</script><span id="d0e30"
class="mo">ⅆ</span><span class="mi1">x</span></span></span>
Jul 20 '05 #1
4 1651
The result of applying the mathml.xsl stylesheet, using pmathmlcss.xsl
in place of pmathml.xsl,


I don't really recommend pmathmlcss except as a last resort if nothing
else is available, but if that is the case here, note that it is
designed to take as input xhtml+mathml documents not just mathml
ones. When processing the <head> of the document it adds some javascript
definitions that are used in the rendering. When you give it (just) a
mathml document it doesn't (currently, although that would be easy to
add) synthesise an <html> element or a <head> element containing the
<scripts that are needed so you end up wuth a document thatjust consists
of an html table with no surrounding document markup, and containing
references to undefined javascript functions.

If your input looks like the following then you do get a more reasonable
result.

David
<?xml version="1.0" encoding="ISO-8859-1"?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head/>
<body>
<math
xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<munderover>
<mo>&#x0222B;</mo>
<mi>a</mi>
<mi>b</mi>
</munderover>
<mi>f</mi>
<mo>&#x02061;</mo>
<mrow>
<mo>(</mo><mi>x</mi><mo>)</mo>
</mrow>
<mo>&#x02146;</mo><mi>x</mi>
</mrow>
</math>
</body>
</html>
Jul 20 '05 #2
David Carlisle <da****@nag.co.uk> wrote in message news:<yg*************@penguin.nag.co.uk>...
The result of applying the mathml.xsl stylesheet, using pmathmlcss.xsl
in place of pmathml.xsl,


I don't really recommend pmathmlcss except as a last resort if nothing
else is available, but if that is the case here, note that it is
designed to take as input xhtml+mathml documents not just mathml
ones. When processing the <head> of the document it adds some javascript
definitions that are used in the rendering. When you give it (just) a
mathml document it doesn't (currently, although that would be easy to
add) synthesise an <html> element or a <head> element containing the
<scripts that are needed so you end up wuth a document thatjust consists
of an html table with no surrounding document markup, and containing
references to undefined javascript functions.

If your input looks like the following then you do get a more reasonable
result.


-----------snip-------------

Thanks, that's much better. At least I have a better understanding of
what's going on. What I'm actually trying to do is as follows. I have
some text in which I wish to include some mathematical notation. The
text is an xml document, with its own DTD which I created from scratch
(at least part of the task is an xml learning exercise on my part),
and a corresponding styesheet. I'm not using xhtml since as far as I
can see this has all the lack of expression of structure that html had
(it seems to be just an xml conformant version of html, expressing
only presentation). I wish to embed a mathml stylesheet in my
stylesheet, the mathmnl dtd in my dtd, and get both the ordinary text
and the maths to display correctly in some browser. I don't mind
whether that browser is mozilla or IE, and if necessary I can upgrade
mozilla to get better mathml support. My stylesheet outputs html in
which I was hoping the mathml would embed. But the situation I ended
up with was I could either get my document displaying correctly apart
from the maths part, or entirely incorrectly with the exception of the
maths part which was correct. My suspicion is that the way forward is
to go entirely to xml, and let mozila intrepret it. But I can't yet
see how to get the rest of the format (which was added by my
stylesheet and expressed in terms of <H1>, <p> etc) to work properly
in this case.
Jul 20 '05 #3
jg*@pobox.com (Jon Thackray) writes:
Thanks, that's much better. At least I have a better understanding of
what's going on. What I'm actually trying to do is as follows. I have
some text in which I wish to include some mathematical notation. The
text is an xml document, with its own DTD which I created from scratch
(at least part of the task is an xml learning exercise on my part),
and a corresponding styesheet. I'm not using xhtml since as far as I
can see this has all the lack of expression of structure that html had
(it seems to be just an xml conformant version of html, expressing
only presentation). I wish to embed a mathml stylesheet in my
stylesheet, the mathmnl dtd in my dtd, and get both the ordinary text
and the maths to display correctly in some browser. I don't mind
whether that browser is mozilla or IE, and if necessary I can upgrade
mozilla to get better mathml support. My stylesheet outputs html in
which I was hoping the mathml would embed. But the situation I ended
up with was I could either get my document displaying correctly apart
from the maths part, or entirely incorrectly with the exception of the
maths part which was correct. My suspicion is that the way forward is
to go entirely to xml, and let mozila intrepret it. But I can't yet
see how to get the rest of the format (which was added by my
stylesheet and expressed in terms of <H1>, <p> etc) to work properly
in this case.


You will get _much_ better rendering if you just let mozilla render the
mathml directly (and IE render it via MathPlayer) the conversion to
javascript and css done by pmathmlcss is designed to make the
mathematics more or less legible but will never produce anything
approaching typographically acceptable output. (Actually it is possible
to get virtually TeX quality rendering of mathematics using css and
javascript but pmathmlcss is designed to work in "real time" styling the
document on the client so does a more or less naive translation
especially as it was developed some years ago when mozilla's xslt
transformer was still in beta and rather unstable so there was a real
incentive to keep the stylesheet simple.

You just want to make "the rest of your format" be xhtml not html, ie
have the right namespace, and be lowercase h1 not H1 etc.

Have a look at for example at the OpenMath spec:

http://www.openmath.org/standard/om20

it starts off life as a docbook+mathml document and is styled to
xhtml+mathml (and separately to pdf). Source documents, generated final
forms and stylesheets are all available from the above.

David
Jul 20 '05 #4
David Carlisle <da****@nag.co.uk> wrote in message news:<yg*************@penguin.nag.co.uk>...
jg*@pobox.com (Jon Thackray) writes:
snip
You will get _much_ better rendering if you just let mozilla render the
mathml directly (and IE render it via MathPlayer) the conversion to
javascript and css done by pmathmlcss is designed to make the
mathematics more or less legible but will never produce anything
approaching typographically acceptable output. (Actually it is possible
to get virtually TeX quality rendering of mathematics using css and
javascript but pmathmlcss is designed to work in "real time" styling the
document on the client so does a more or less naive translation
especially as it was developed some years ago when mozilla's xslt
transformer was still in beta and rather unstable so there was a real
incentive to keep the stylesheet simple.

You just want to make "the rest of your format" be xhtml not html, ie
have the right namespace, and be lowercase h1 not H1 etc.

Have a look at for example at the OpenMath spec:

http://www.openmath.org/standard/om20

it starts off life as a docbook+mathml document and is styled to
xhtml+mathml (and separately to pdf). Source documents, generated final
forms and stylesheets are all available from the above.


Hmm, I'm still struggling with this, so I guess I must be missing
something. I've now set the output method to be xhtml (which saxon
objects to, but xalan seems happy with). If I write the output to an
file with an xml extension, mozilla renders the maths bit properly,
but ignores all the rest of the document formatting (all the h1s etc),
whereas if I simply change the extension to be html, mozilla now takes
note of all the formatting, but renders the maths incorrectly (it just
renders it as though it had ignored the mathml tags). I have added an
xmlns attribute ("http://www.w3.org/1999/xhtml")to the output html
tag, but this doesn't seem to help. How do I get it to take note of
both the normal xhtml format, and the mathml markup?
Jul 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by Penn Markham | last post: by
2 posts views Thread by Joachim Spoerhase | last post: by
reply views Thread by Soren Kuula | last post: by
2 posts views Thread by Florian Huber | last post: by
2 posts views Thread by Jon Thackray | last post: by
3 posts views Thread by Fred | last post: by
reply views Thread by NPC403 | last post: by
3 posts views Thread by gieforce | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.