Trouble with mathml (either style or source)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jon Thackray

    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"><s pan id="d0e3" class="mrow">
    <table class="munderov er">
    <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"><s pan id="d0e22" class="mo">(</span><span
    class="mi1">x</span><span id="d0e26"
    class="mo">)</span></span><script>
    var mrowH = d0e20.offsetHei ght;

    mrowStretch(d0e 22,"æ","ç","à §","è");
    mrowStretch(d0e 26,"ö","÷","à ·","ø");</script><span id="d0e30"
    class="mo">ⅆ</span><span class="mi1">x</span></span></span>
  • David Carlisle

    #2
    Re: Trouble with mathml (either style or source)

    [color=blue]
    > The result of applying the mathml.xsl stylesheet, using pmathmlcss.xsl
    > in place of pmathml.xsl,[/color]

    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>

    Comment

    • Jon Thackray

      #3
      Re: Trouble with mathml (either style or source)

      David Carlisle <davidc@nag.co. uk> wrote in message news:<yg4is8ndx zm.fsf@penguin. nag.co.uk>...[color=blue][color=green]
      > > The result of applying the mathml.xsl stylesheet, using pmathmlcss.xsl
      > > in place of pmathml.xsl,[/color]
      >
      > 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.[/color]

      -----------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.

      Comment

      • David Carlisle

        #4
        Re: Trouble with mathml (either style or source)

        jgt@pobox.com (Jon Thackray) writes:
        [color=blue]
        > 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.[/color]

        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:



        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

        Comment

        • Jon Thackray

          #5
          Re: Trouble with mathml (either style or source)

          David Carlisle <davidc@nag.co. uk> wrote in message news:<yg48y9icx 9j.fsf@penguin. nag.co.uk>...[color=blue]
          > jgt@pobox.com (Jon Thackray) writes:[/color]

          snip
          [color=blue]
          > 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.[/color]

          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?

          Comment

          Working...