problème de formule en Mathml sur un script PHP

littledrummer
Invité n'ayant pas de compte PHPfrance

27 avr. 2011, 21:52

bonjour,

j'aimerai utiliser Mathml pour incruster des equation mathématiques sur mes page web.

pour obtenir mon code Mathml j'utilise un convertisseur online a partir de code Latex.
j'obtiens donc un code comme ça:

Code : Tout sélectionner

<!-- begin MathToWeb --> <!-- (your LaTeX) $F(p,q)=\sum_{m=0}^{M-1}\sum_{n=0}^{N-1}f(m,n)e^{j\pi (m+n)}e^{-j\pi 2p\frac{m}{M}}e^{-j\pi 2q\frac{n}{N}}$ --> <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> <mi>F</mi> <mrow> <mo maxsize="1.00em">(</mo> <mi>p</mi> <mo>,</mo> <mi>q</mi> <mo maxsize="1.00em">)</mo> </mrow> <mo>=</mo> <mstyle displaystyle="true"> <munderover> <mo>&sum;</mo> <mrow> <mi>m</mi> <mo>=</mo> <mn>0</mn> </mrow> <mrow> <mi>M</mi> <mo>-</mo> <mn>1</mn> </mrow> </munderover> </mstyle> <mstyle displaystyle="true"> <munderover> <mo>&sum;</mo> <mrow> <mi>n</mi> <mo>=</mo> <mn>0</mn> </mrow> <mrow> <mi>N</mi> <mo>-</mo> <mn>1</mn> </mrow> </munderover> </mstyle> <mi>f</mi> <mrow> <mo maxsize="1.00em">(</mo> <mi>m</mi> <mo>,</mo> <mi>n</mi> <mo maxsize="1.00em">)</mo> </mrow> <msup> <mi>e</mi> <mrow> <mi>j</mi> <mi>&pi;</mi> <mrow> <mo maxsize="1.00em">(</mo> <mi>m</mi> <mo>+</mo> <mi>n</mi> <mo maxsize="1.00em">)</mo> </mrow> </mrow> </msup> <msup> <mi>e</mi> <mrow> <mo>-</mo> <mi>j</mi> <mi>&pi;</mi> <mn>2</mn> <mi>p</mi> <mfrac linethickness="1"> <mi>m</mi> <mi>M</mi> </mfrac> </mrow> </msup> <msup> <mi>e</mi> <mrow> <mo>-</mo> <mi>j</mi> <mi>&pi;</mi> <mn>2</mn> <mi>q</mi> <mfrac linethickness="1"> <mi>n</mi> <mi>N</mi> </mfrac> </mrow> </msup> </mrow> </math> <!-- end MathToWeb -->

ensuite j'essaie d'intégrer ce code sur ma page en PHP.

je met donc se code dans ma page. Et l'affichage ne me donne pas du tout la formule attendu.
j'obtiens:
F ( p , q ) = ∑ m = 0 M - 1 ∑ n = 0 N - 1 f ( m , n ) e j π ( m + n ) e - j π 2 p m M e - j π 2 q n N

j'ai essayé plusieurs solution proposé sur la toile mais je n'est pas trouvé la bonne apparemment.

j'ai essayé les déclaration suivante en début de page:

Code : Tout sélectionner

<?xml version="1.0" encoding="utf-8" standalone="no"?> <?xml-stylesheet type="text/xsl" href="mathml.xsl"?> <?xml-stylesheet type="text/xsl" href="pmathml.xsl"?> <?xml-stylesheet type="text/xsl" href="http://www.w3.org/Math/XSL/mathml.xsl"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN" "http://www.w3.org/TR/MathML2/dtd/xhtml-math11-f.dtd">

j'ai l'impression qu'il ne comprend pas le code MAthml et qu'il le lit comme un simple text. Mes déclarations ne doivent pas être bonne

voila, si une âme charitable passe par là, je pourrais enfin m'en sortir.

Avatar du membre
Modérateur PHPfrance
Modérateur PHPfrance | 10684 Messages

27 avr. 2011, 22:46

Effectivement, php ne comprend pas le code MAthml et le lit comme un simple texte... Au mieux, c'est ton navigateur qui va l'interpréter pour l'afficher sous forme de formules mathématiques (donc ça peut fortement dépendre du navigateur utilisé)

En principe, il te suffit normalement de commencer ta page html avec
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="http://www.w3.org/Math/XSL/mathml.xsl"?>
<html xmlns="http://www.w3.org/1999/xhtml">
...
Et de placer ton code en xml directement dans le body de ta page...

Apparemment tu dois aussi pouvoir le faire en incluant simplement le script et le css suivant dans ton head :
<link rel="stylesheet" href="https://display-mathml.googlecode.com/hg/display-mathml.css?r=stable" />
<script src="https://display-mathml.googlecode.com/hg/display-mathml.js?r=stable"></script>
Voir l'exemple ici : http://www.madogiwa.org/display-mathml/example.html
Ce n'est pas en améliorant la bougie que l'on a inventé l'ampoule...

littledrumer
Invité n'ayant pas de compte PHPfrance

30 avr. 2011, 16:32

merci ça fonctionne maintenant .