[plt-scheme] servlets and mathml

From: Jean-François Trevien (jftrevien at free.fr)
Date: Mon Dec 12 16:31:37 EST 2005

I'm trying to produce from a servlet a mathml tag that will appear in 
firefox my first try is:
(module test-mathml mzscheme
  (require (lib "servlet.ss" "web-server")
           (lib "date.ss")
           (lib "xml.ss" "xml")
           )
  (provide interface-version timeout start)
  (define interface-version 'v1)
  (define timeout +inf.0)
  (define (start initial-request)
    `(html ((xmlns "http://www.w3.org/1999/xhtml")
            (xmlns:math "http://www.w3.org/1998/Math/MathML")
            )
           (head
            (title "Mathml test"))
           (body
            (math ((xmlns "http://www.w3.org/1998/Math/MathML"))
                  (mrow
                   (msup
                    (mfenced (mrow (mi "a")(mo "+")(mi "b")))(mn "2")))
                  )))))

but the browser (firefox 1.5) ignore the math tags
I have also tried replacing the start by:
  (define (start initial-request)
    (list
     "text/xhtml"
     (string-append
      "<?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\">
]>"
      (xexpr->string
       `(html ((xmlns "http://www.w3.org/1999/xhtml")
               (xmlns:math "http://www.w3.org/1998/Math/MathML")
               )
              (head
               (title "Mathml test"))
              (body
               (math ((xmlns "http://www.w3.org/1998/Math/MathML"))
                     (mrow
                      (msup
                       (mfenced (mrow (mi "a")(mo "+")(mi "b")))(mn "2")))
                     )))))))

But the response format is not recognized error message:


  Erroneous Xexpr

An Xexpr in the servlet is malformed. The exact error is

Expected a symbol as the element name, given text/xhtml


    The Full Xexpr Is

"(text/xhtml \n\n]>a+b2)"

I use drscheme 299.400p1



Posted on the users mailing list.