如何将OMML转换为MML

时间:2019-05-19 06:51:31

标签: javascript xslt mathml omml

我想在客户端将OMML转换为MML。 主要问题是,当我从包含一个方程式以及一些文本的ms单词中复制时,剪贴板数据(“ text / html”)看起来像是波纹管(剪贴板内容)

从那里我可以看到像波纹管这样的数学部分

<m:oMath><m:f><m:fPr><span
   style='font-size:12.0pt;mso-ansi-font-size:12.0pt;mso-bidi-font-size:12.0pt;
   font-family:"Cambria Math","serif";mso-ascii-font-family:"Cambria Math";
   mso-hansi-font-family:"Cambria Math";font-style:italic;mso-bidi-font-style:
   normal'><m:ctrlPr></m:ctrlPr></span></m:fPr><m:num><i style='mso-bidi-font-style:
   normal'><span style='font-size:12.0pt;line-height:115%;font-family:"Cambria Math","serif";
   mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;
   mso-hansi-font-family:Calibri;mso-hansi-theme-font:minor-latin;mso-bidi-font-family:
   "Times New Roman";mso-bidi-theme-font:minor-bidi;mso-ansi-language:EN-IN;
   mso-fareast-language:EN-US;mso-bidi-language:AR-SA'><m:r>1</m:r></span></i></m:num><m:den><i
   style='mso-bidi-font-style:normal'><span style='font-size:12.0pt;line-height:
   115%;font-family:"Cambria Math","serif";mso-fareast-font-family:Calibri;
   mso-fareast-theme-font:minor-latin;mso-hansi-font-family:Calibri;mso-hansi-theme-font:
   minor-latin;mso-bidi-font-family:"Times New Roman";mso-bidi-theme-font:minor-bidi;
   mso-ansi-language:EN-IN;mso-fareast-language:EN-US;mso-bidi-language:AR-SA'><m:r>7</m:r></span></i></m:den></m:f><i
 style='mso-bidi-font-style:normal'><span style='font-size:12.0pt;line-height:
 115%;font-family:"Cambria Math","serif";mso-fareast-font-family:Calibri;
 mso-fareast-theme-font:minor-latin;mso-hansi-font-family:Calibri;mso-hansi-theme-font:
 minor-latin;mso-bidi-font-family:"Times New Roman";mso-bidi-theme-font:minor-bidi;
 mso-ansi-language:EN-IN;mso-fareast-language:EN-US;mso-bidi-language:AR-SA'><m:r>+</m:r></span></i><m:d><m:dPr><span
   style='font-size:12.0pt;mso-ansi-font-size:12.0pt;mso-bidi-font-size:12.0pt;
   font-family:"Cambria Math","serif";mso-ascii-font-family:"Cambria Math";
   mso-hansi-font-family:"Cambria Math";font-style:italic;mso-bidi-font-style:
   normal'><m:ctrlPr></m:ctrlPr></span></m:dPr><m:e><i style='mso-bidi-font-style:
   normal'><span style='font-size:12.0pt;line-height:115%;font-family:"Cambria Math","serif";
   mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;
   mso-hansi-font-family:Calibri;mso-hansi-theme-font:minor-latin;mso-bidi-font-family:
   "Times New Roman";mso-bidi-theme-font:minor-bidi;mso-ansi-language:EN-IN;
   mso-fareast-language:EN-US;mso-bidi-language:AR-SA'><m:r>999</m:r></span></i><m:f><m:fPr><span
     style='font-size:12.0pt;mso-ansi-font-size:12.0pt;mso-bidi-font-size:12.0pt;
     font-family:"Cambria Math","serif";mso-ascii-font-family:"Cambria Math";
     mso-hansi-font-family:"Cambria Math";font-style:italic;mso-bidi-font-style:
     normal'><m:ctrlPr></m:ctrlPr></span></m:fPr><m:num><i style='mso-bidi-font-style:
     normal'><span style='font-size:12.0pt;line-height:115%;font-family:"Cambria Math","serif";
     mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;
     mso-hansi-font-family:Calibri;mso-hansi-theme-font:minor-latin;mso-bidi-font-family:
     "Times New Roman";mso-bidi-theme-font:minor-bidi;mso-ansi-language:EN-IN;
     mso-fareast-language:EN-US;mso-bidi-language:AR-SA'><m:r>692</m:r></span></i></m:num><m:den><i
     style='mso-bidi-font-style:normal'><span style='font-size:12.0pt;
     line-height:115%;font-family:"Cambria Math","serif";mso-fareast-font-family:
     Calibri;mso-fareast-theme-font:minor-latin;mso-hansi-font-family:Calibri;
     mso-hansi-theme-font:minor-latin;mso-bidi-font-family:"Times New Roman";
     mso-bidi-theme-font:minor-bidi;mso-ansi-language:EN-IN;mso-fareast-language:
     EN-US;mso-bidi-language:AR-SA'><m:r>693</m:r></span></i></m:den></m:f></m:e></m:d><i
 style='mso-bidi-font-style:normal'><span style='font-size:12.0pt;line-height:
 115%;font-family:"Cambria Math","serif";mso-fareast-font-family:Calibri;
 mso-fareast-theme-font:minor-latin;mso-bidi-font-family:"Times New Roman";
 mso-bidi-theme-font:minor-bidi;mso-ansi-language:EN-IN;mso-fareast-language:
 EN-US;mso-bidi-language:AR-SA'><m:r>×</m:r></span><span style='font-size:12.0pt;
 line-height:115%;font-family:"Cambria Math","serif";mso-fareast-font-family:
 Calibri;mso-fareast-theme-font:minor-latin;mso-hansi-font-family:Calibri;
 mso-hansi-theme-font:minor-latin;mso-bidi-font-family:"Times New Roman";
 mso-bidi-theme-font:minor-bidi;mso-ansi-language:EN-IN;mso-fareast-language:
 EN-US;mso-bidi-language:AR-SA'><m:r>99</m:r></span></i></m:oMath>

是OMML 带有名称空间xmlns:m =“ http://schemas.microsoft.com/office/2004/12/omml”

我像下面这样格式化

<m:oMath xmlns:m="http://schemas.microsoft.com/office/2004/12/omml">
<m:f>
<m:fPr>
<span>
    <m:ctrlPr>
</m:ctrlPr>
</span>
</m:fPr>
<m:num>
<i>
    <span>
        <m:r>
        1
    </m:r>
</span>
</i>
</m:num>
<m:den>
<i
>
<span >
    <m:r>
    7</m:r>
</span>
</i>
</m:den>
</m:f>
<i
>
<span >
    <m:r>
    +</m:r>
</span>
</i>
<m:d>
<m:dPr>
<span
>
<m:ctrlPr>
</m:ctrlPr>
</span>
</m:dPr>
<m:e>
<i >
    <span >
        <m:r>
        999</m:r>
    </span>
</i>
<m:f>
<m:fPr>
<span
>
<m:ctrlPr>
</m:ctrlPr>
</span>
</m:fPr>
<m:num>
<i >
    <span >
        <m:r>
        692</m:r>
    </span>
</i>
</m:num>
<m:den>
<i
>
<span >
    <m:r>
    693</m:r>
</span>
</i>
</m:den>
</m:f>
</m:e>
</m:d>
<i
>
<span >
    <m:r>
    ×</m:r>
</span>
<span >
    <m:r>
    99</m:r>
</span>
</i>
</m:oMath>

现在我需要将其转换为MathML,以便可以使用任何MathMl查看器在Web上显示它

当用户从ms word中复制某些内容并且用户应该看到最终结果(转换后的数学结果)时,我立即需要使用

我正在使用tinyMCE编辑器,该编辑器具有一个名为powerpaste的插件,可以将数学转换为图像,但是我不希望图像,并且该插件也存在一些错误。

我希望数学以MathML格式存储

我发现XSLT文件可以转换XML,并且还得到了OMML2MML.XSL文件,但是似乎XSL尚未转换OMML(我只尝试了在线转换器)。

我认为名称空间http://schemas.microsoft.com/office/2004/12/omml不再存在 或xsl文件错误 或者我在做一些愚蠢的事情。

需要帮助

剪贴板内容

<html xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:w="urn:schemas-microsoft-com:office:word"
xmlns:m="http://schemas.microsoft.com/office/2004/12/omml"
xmlns="http://www.w3.org/TR/REC-html40">

<head></head>

<body lang=EN-IN style='tab-interval:36.0pt'>
<!--StartFragment--><!--[if gte msEquation 12]><m:oMath><m:f><m:fPr><span
   style='font-size:12.0pt;mso-ansi-font-size:12.0pt;mso-bidi-font-size:12.0pt;
   font-family:"Cambria Math","serif";mso-ascii-font-family:"Cambria Math";
   mso-hansi-font-family:"Cambria Math";font-style:italic;mso-bidi-font-style:
   normal'><m:ctrlPr></m:ctrlPr></span></m:fPr><m:num><i style='mso-bidi-font-style:
   normal'><span style='font-size:12.0pt;line-height:115%;font-family:"Cambria Math","serif";
   mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;
   mso-hansi-font-family:Calibri;mso-hansi-theme-font:minor-latin;mso-bidi-font-family:
   "Times New Roman";mso-bidi-theme-font:minor-bidi;mso-ansi-language:EN-IN;
   mso-fareast-language:EN-US;mso-bidi-language:AR-SA'><m:r>1</m:r></span></i></m:num><m:den><i
   style='mso-bidi-font-style:normal'><span style='font-size:12.0pt;line-height:
   115%;font-family:"Cambria Math","serif";mso-fareast-font-family:Calibri;
   mso-fareast-theme-font:minor-latin;mso-hansi-font-family:Calibri;mso-hansi-theme-font:
   minor-latin;mso-bidi-font-family:"Times New Roman";mso-bidi-theme-font:minor-bidi;
   mso-ansi-language:EN-IN;mso-fareast-language:EN-US;mso-bidi-language:AR-SA'><m:r>7</m:r></span></i></m:den></m:f><i
 style='mso-bidi-font-style:normal'><span style='font-size:12.0pt;line-height:
 115%;font-family:"Cambria Math","serif";mso-fareast-font-family:Calibri;
 mso-fareast-theme-font:minor-latin;mso-hansi-font-family:Calibri;mso-hansi-theme-font:
 minor-latin;mso-bidi-font-family:"Times New Roman";mso-bidi-theme-font:minor-bidi;
 mso-ansi-language:EN-IN;mso-fareast-language:EN-US;mso-bidi-language:AR-SA'><m:r>+</m:r></span></i><m:d><m:dPr><span
   style='font-size:12.0pt;mso-ansi-font-size:12.0pt;mso-bidi-font-size:12.0pt;
   font-family:"Cambria Math","serif";mso-ascii-font-family:"Cambria Math";
   mso-hansi-font-family:"Cambria Math";font-style:italic;mso-bidi-font-style:
   normal'><m:ctrlPr></m:ctrlPr></span></m:dPr><m:e><i style='mso-bidi-font-style:
   normal'><span style='font-size:12.0pt;line-height:115%;font-family:"Cambria Math","serif";
   mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;
   mso-hansi-font-family:Calibri;mso-hansi-theme-font:minor-latin;mso-bidi-font-family:
   "Times New Roman";mso-bidi-theme-font:minor-bidi;mso-ansi-language:EN-IN;
   mso-fareast-language:EN-US;mso-bidi-language:AR-SA'><m:r>999</m:r></span></i><m:f><m:fPr><span
     style='font-size:12.0pt;mso-ansi-font-size:12.0pt;mso-bidi-font-size:12.0pt;
     font-family:"Cambria Math","serif";mso-ascii-font-family:"Cambria Math";
     mso-hansi-font-family:"Cambria Math";font-style:italic;mso-bidi-font-style:
     normal'><m:ctrlPr></m:ctrlPr></span></m:fPr><m:num><i style='mso-bidi-font-style:
     normal'><span style='font-size:12.0pt;line-height:115%;font-family:"Cambria Math","serif";
     mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;
     mso-hansi-font-family:Calibri;mso-hansi-theme-font:minor-latin;mso-bidi-font-family:
     "Times New Roman";mso-bidi-theme-font:minor-bidi;mso-ansi-language:EN-IN;
     mso-fareast-language:EN-US;mso-bidi-language:AR-SA'><m:r>692</m:r></span></i></m:num><m:den><i
     style='mso-bidi-font-style:normal'><span style='font-size:12.0pt;
     line-height:115%;font-family:"Cambria Math","serif";mso-fareast-font-family:
     Calibri;mso-fareast-theme-font:minor-latin;mso-hansi-font-family:Calibri;
     mso-hansi-theme-font:minor-latin;mso-bidi-font-family:"Times New Roman";
     mso-bidi-theme-font:minor-bidi;mso-ansi-language:EN-IN;mso-fareast-language:
     EN-US;mso-bidi-language:AR-SA'><m:r>693</m:r></span></i></m:den></m:f></m:e></m:d><i
 style='mso-bidi-font-style:normal'><span style='font-size:12.0pt;line-height:
 115%;font-family:"Cambria Math","serif";mso-fareast-font-family:Calibri;
 mso-fareast-theme-font:minor-latin;mso-bidi-font-family:"Times New Roman";
 mso-bidi-theme-font:minor-bidi;mso-ansi-language:EN-IN;mso-fareast-language:
 EN-US;mso-bidi-language:AR-SA'><m:r>×</m:r></span><span style='font-size:12.0pt;
 line-height:115%;font-family:"Cambria Math","serif";mso-fareast-font-family:
 Calibri;mso-fareast-theme-font:minor-latin;mso-hansi-font-family:Calibri;
 mso-hansi-theme-font:minor-latin;mso-bidi-font-family:"Times New Roman";
 mso-bidi-theme-font:minor-bidi;mso-ansi-language:EN-IN;mso-fareast-language:
 EN-US;mso-bidi-language:AR-SA'><m:r>99</m:r></span></i></m:oMath><![endif]--><![if !msEquation]><span
style='font-size:11.0pt;line-height:115%;font-family:"Calibri","sans-serif";
mso-ascii-theme-font:minor-latin;mso-fareast-font-family:Calibri;mso-fareast-theme-font:
minor-latin;mso-hansi-theme-font:minor-latin;mso-bidi-font-family:"Times New Roman";
mso-bidi-theme-font:minor-bidi;position:relative;top:9.0pt;mso-text-raise:-9.0pt;
mso-ansi-language:EN-IN;mso-fareast-language:EN-US;mso-bidi-language:AR-SA'><!--[if gte vml 1]><v:shapetype
 id="_x0000_t75" coordsize="21600,21600" o:spt="75" o:preferrelative="t"
 path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f">
 <v:stroke joinstyle="miter"/>
 <v:formulas>
  <v:f eqn="if lineDrawn pixelLineWidth 0"/>
  <v:f eqn="sum @0 1 0"/>
  <v:f eqn="sum 0 0 @1"/>
  <v:f eqn="prod @2 1 2"/>
  <v:f eqn="prod @3 21600 pixelWidth"/>
  <v:f eqn="prod @3 21600 pixelHeight"/>
  <v:f eqn="sum @0 0 1"/>
  <v:f eqn="prod @6 1 2"/>
  <v:f eqn="prod @7 21600 pixelWidth"/>
  <v:f eqn="sum @8 21600 0"/>
  <v:f eqn="prod @7 21600 pixelHeight"/>
  <v:f eqn="sum @10 21600 0"/>
 </v:formulas>
 <v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"/>
 <o:lock v:ext="edit" aspectratio="t"/>
</v:shapetype><v:shape id="_x0000_i1025" type="#_x0000_t75" style='width:94.5pt;
 height:24pt'>
 <v:imagedata src="file:///C:\Users\Joydeep\AppData\Local\Temp\msohtmlclip1\01\clip_image001.png"
  o:title="" chromakey="white"/>
</v:shape><![endif]--><![if !vml]><img width=126 height=32
src="file:///C:\Users\Joydeep\AppData\Local\Temp\msohtmlclip1\01\clip_image002.gif"
v:shapes="_x0000_i1025"><![endif]></span><![endif]><span style='font-size:12.0pt;
line-height:115%;font-family:"Calibri","sans-serif";mso-ascii-theme-font:minor-latin;
mso-fareast-font-family:"Times New Roman";mso-fareast-theme-font:minor-fareast;
mso-hansi-theme-font:minor-latin;mso-bidi-font-family:"Times New Roman";
mso-bidi-theme-font:minor-bidi;mso-ansi-language:EN-IN;mso-fareast-language:
EN-US;mso-bidi-language:AR-SA'><span style='mso-spacerun:yes'> </span>is equal
to.</span><!--EndFragment-->
</body>

</html>

0 个答案:

没有答案