最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【记录】尝试给Docbook添加MathML的支持

Docbook crifan 3859浏览 0评论

【背景】

收到别人一个邮件,说是在使用Docbook转PDF时,

对于:

<inlineequation>
    <m:math display="inline">
      <m:mrow>
        <m:mrow>
          <m:mi>x</m:mi>
          <m:mo>+</m:mo>
          <m:mi>y</m:mi>
        </m:mrow>
        <m:mo>=</m:mo>
        <m:mn>2</m:mn>
      </m:mrow>
    </m:math>
</inlineequation> 

的Math的公示,Docbook不支持,出现下面的错误:

警告: Unknown formatting object "{http://www.w3.org/1998/Math/MathML}math" encountered (a child of fo:instream-foreign-object}. (No context info available)

七月 04, 2014 10:03:11 上午 org.apache.fop.events.LoggingEventListener processEvent

警告: Unknown formatting object "{http://www.w3.org/1998/Math/MathML}mrow" encountered (a child of math}. (No context info available)

七月 04, 2014 10:03:11 上午 org.apache.fop.events.LoggingEventListener processEvent

警告: Unknown formatting object "{http://www.w3.org/1998/Math/MathML}mtext" encountered (a child of mrow}. (No context info available)

七月 04, 2014 10:03:11 上午 org.apache.fop.events.LoggingEventListener processEvent

警告: Unknown formatting object "{http://www.w3.org/1998/Math/MathML}mspace" encountered (a child of mrow}. (No context info available)

七月 04, 2014 10:03:11 上午 org.apache.fop.events.LoggingEventListener processEvent

然后其另外也去试了试:

“在转之前用jeuclid先处理xml文件,把公式转成图片,然后再把公式这段代码直接给替换成图片,然后在转成PDF”

 

【折腾过程】

1.然后去搜了很多相关的资料:

Docbook, MathML and PDF

MathML

The DocBook MathML Document Type

http://docbook.org/xml/mathml/1.0/dbmathml.dtd

mml:*

 

DocBook Specifications

-》

DocBook MathML Module

 

W3C MathML implementations page

W3C MathML implementations page

lf201, Applications: 编辑DocBook XML文档

-》》》》

发现:

http://www.w3.org/1998/Math/MathML/

是可以打开的->有效的namespace

http://www.sagehill.net/docbookxsl/MathML.html

->

http://www.w3.org/Math/DTD/mathml2

是打不开的

->无效的namespace?

 

但是:

http://www.w3.org/Math/DTD/

是可以打开的。

 

对应的有:

http://www.w3.org/Math/DTD/mathml3/mathml3.dtd

和:

http://www.w3.org/Math/DTD/mathml2/mathml2.dtd

 

2.此处再去对于上述用到的namespace:

http://www.w3.org/1998/Math/MathML/

确认是可以打开的:

mathml url can open MathML Namespace

3.去搜了搜:

jeuclid

找到:

JEuclid – 其它开源项目 – Java开源大全

发现是:

一个工具,可以讲mathml转换为图片的。

4.所以,此刻就是去自己试试,自己此处是否可以正常工作:

不过现在搜索:

Unknown formatting object   MathML math encountered a child of

找到:

Re: [docbook] Need help using MathML ("Unknown formatting object "{http:

其主要建议是:use namespace-aware stylesheets.

那待会自己去试的时候,也可以注意这点了。

5.写测试代码期间才发现,我之前自己的Docbook的源码中,就包含了MathML了:

<preface xml:id="preface"
    xmlns="http://docbook.org/ns/docbook"
    xmlns:xl="http://www.w3.org/1999/xlink"
    xmlns:xi="http://www.w3.org/2001/XInclude"
    xmlns:ns5="http://www.w3.org/1998/Math/MathML"
    xmlns:ns4="http://www.w3.org/1999/xhtml"
    xmlns:ns3="http://www.w3.org/2000/svg"
    xmlns:ns="http://docbook.org/ns/docbook">
<title>前言</title>

只是之前没用过罢了。

6.测试代码:

<?xml version='1.0' encoding="utf-8"?>

<!DOCTYPE book
[

<!ENTITY cur_book_name      "test_mathml" >
<!ENTITY publish_date       "2014-07-05" >
<!ENTITY release_version    "0.1" >

<!ENTITY copyrith_year "2014" >
]>

<book version="5.0"
    xmlns="http://docbook.org/ns/docbook"
    xmlns:xi="http://www.w3.org/2001/XInclude"
    xmlns:xl="http://www.w3.org/1999/xlink"
    xmlns:mml="http://www.w3.org/1998/Math/MathML"
    
    xml:lang="zh_CN">
<info>
    <title>测试Mathml</title>
    <subtitle></subtitle>
    <keywordset>
        <keyword>测试</keyword>
        <keyword>MathML</keyword>
    </keywordset>

    <abstract>
        <para>测试MathML是否能正常在转换后的pdf和html中显示</para>
    </abstract>

    <revhistory>
        <revision>
            <revnumber>&release_version;</revnumber>
            <date>&publish_date;</date>
            <revremark>
                <orderedlist>
                    <listitem>第一版</listitem>
                </orderedlist>
            </revremark>
            <authorinitials>crl</authorinitials>
        </revision>
    </revhistory>

</info>

<chapter xml:id="ch01_demo_mathml"
    xmlns="http://docbook.org/ns/docbook"
    xmlns:xl="http://www.w3.org/1999/xlink"
    xmlns:xi="http://www.w3.org/2001/XInclude"
    xmlns:mml="http://www.w3.org/1998/Math/MathML"
    xmlns:ns="http://docbook.org/ns/docbook">
    <title>demo MathML</title>

    <para>
        <inlineequation>
            <mml:math display="inline">
              <mml:mrow>
                <mml:mrow>
                  <mml:mi>x</mml:mi>
                  <mml:mo>+</mml:mo>
                  <mml:mi>y</mml:mi>
                </mml:mrow>
                <mml:mo>=</mml:mo>
                <mml:mn>2</mml:mn>
              </mml:mrow>
            </mml:math>
        </inlineequation> 
    </para>
</chapter>

</book>

结果编译出错:

=============================== generating test_mathml pdf ==============================
fop --execdebug -c E:/dev_root/docbook/dev/config/fop/conf/fop.xconf ../output/fo/test_mathml.fo -pdf ../output/pdf/test_mathml.pdf
exec "/cygdrive/c/Program Files/Java/jdk1.7.0_45/bin/java" -classpath "E:/dev_root/docbook/tools/fop-1.0/lib/xmlgraphics-commons-1.4.jar;E:/dev_root/docbook/tools/fop-1.0/lib/xml-apis-ext-1.3.04.jar;E:/dev_root/docbook/tools/fop-1.0/lib/xml-apis-1.3.04.jar;E:/dev_root/docbook/tools/fop-1.0/lib/xercesImpl-2.7.1.jar;E:/dev_root/docbook/tools/fop-1.0/lib/xalan-2.7.0.jar;E:/dev_root/docbook/tools/fop-1.0/lib/serializer-2.7.0.jar;E:/dev_root/docbook/tools/fop-1.0/lib/fop-hyph.jar;E:/dev_root/docbook/tools/fop-1.0/lib/commons-logging-1.0.4.jar;E:/dev_root/docbook/tools/fop-1.0/lib/commons-io-1.3.1.jar;E:/dev_root/docbook/tools/fop-1.0/lib/batik-all-1.7.jar;E:/dev_root/docbook/tools/fop-1.0/lib/avalon-framework-4.2.0.jar;E:/dev_root/docbook/tools/fop-1.0/build/fop.jar;E:/dev_root/docbook/tools/fop-1.0/build/fop-sandbox.jar;E:/dev_root/docbook/tools/fop-1.0/build/fop-hyph.jar" org.apache.fop.cli.Main "-c" "E:/dev_root/docbook/dev/config/fop/conf/fop.xconf" "../output/fo/test_mathml.fo" "-pdf" "../output/pdf/test_mathml.pdf"
七月 05, 2014 3:37:30 下午 org.apache.fop.apps.FopFactoryConfigurator configure
信息: Default page-height set to: 11in
七月 05, 2014 3:37:30 下午 org.apache.fop.apps.FopFactoryConfigurator configure
信息: Default page-width set to: 8.26in
七月 05, 2014 3:37:33 下午 org.apache.fop.events.LoggingEventListener processEvent
警告: Font "Cambria Math,normal,700" not found. Substituting with "Cambria Math,normal,400".
七月 05, 2014 3:37:33 下午 org.apache.fop.hyphenation.Hyphenator getHyphenationTree
严重: Couldn't find hyphenation pattern zh_cn
七月 05, 2014 3:37:34 下午 org.apache.fop.events.LoggingEventListener processEvent
警告: Unknown formatting object "{http://www.w3.org/1998/Math/MathML}math" encountered (a child of fo:instream-foreign-object}. (See position 1027:111)
七月 05, 2014 3:37:34 下午 org.apache.fop.events.LoggingEventListener processEvent
警告: Unknown formatting object "{http://www.w3.org/1998/Math/MathML}mrow" encountered (a child of math}. (See position 1028:25)
七月 05, 2014 3:37:34 下午 org.apache.fop.events.LoggingEventListener processEvent
警告: Unknown formatting object "{http://www.w3.org/1998/Math/MathML}mrow" encountered (a child of mrow}. (See position 1029:27)
七月 05, 2014 3:37:34 下午 org.apache.fop.events.LoggingEventListener processEvent
警告: Unknown formatting object "{http://www.w3.org/1998/Math/MathML}mi" encountered (a child of mrow}. (See position 1030:27)
七月 05, 2014 3:37:34 下午 org.apache.fop.events.LoggingEventListener processEvent
警告: Unknown formatting object "{http://www.w3.org/1998/Math/MathML}mo" encountered (a child of mrow}. (See position 1031:27)
七月 05, 2014 3:37:34 下午 org.apache.fop.events.LoggingEventListener processEvent
警告: Unknown formatting object "{http://www.w3.org/1998/Math/MathML}mi" encountered (a child of mrow}. (See position 1032:27)
七月 05, 2014 3:37:34 下午 org.apache.fop.events.LoggingEventListener processEvent
警告: Unknown formatting object "{http://www.w3.org/1998/Math/MathML}mo" encountered (a child of mrow}. (See position 1034:25)
七月 05, 2014 3:37:34 下午 org.apache.fop.events.LoggingEventListener processEvent
警告: Unknown formatting object "{http://www.w3.org/1998/Math/MathML}mn" encountered (a child of mrow}. (See position 1035:25)
七月 05, 2014 3:37:34 下午 org.apache.fop.events.LoggingEventListener processEvent
严重: The intrinsic dimensions of an instream-foreign-object could not be determined. (See position 1027:37)

看起来,此处的fop中,暂时不支持MathML。

估计需要加入对应的库才可以?

7.把测试代码换成:

MathML

中的:

<equation>
<title>My MathML example</title>
<mml:math>
  <mml:mrow>
    <mml:mn>4</mml:mn>
    <mml:mo>+</mml:mo>
    <mml:mi>x</mml:mi>
  </mml:mrow>
</mml:math>
</equation>

即:

<chapter xml:id="ch01_demo_mathml"
    xmlns="http://docbook.org/ns/docbook"
    xmlns:xl="http://www.w3.org/1999/xlink"
    xmlns:xi="http://www.w3.org/2001/XInclude"
    xmlns:mml="http://www.w3.org/1998/Math/MathML"
    xmlns:ns="http://docbook.org/ns/docbook">
    <title>demo MathML</title>

    <equation>
    <title>My MathML example</title>
    <mml:math>
      <mml:mrow>
        <mml:mn>4</mml:mn>
        <mml:mo>+</mml:mo>
        <mml:mi>x</mml:mi>
      </mml:mrow>
    </mml:math>
    </equation>

</chapter>

然后结果是:

还是同样错误。

8.google搜:

Unknown formatting object "{http://www.w3.org/1998/Math/MathML}math" encountered (a child of fo:instream-foreign-object}

找到:

docbook General – Need help using MathML ("Unknown formatting object "{http://www.w3.org/1998/Math/MathML}math" encountered")

然后去看看:

http://jeuclid.sourceforge.net/trunk/jeuclid-fop/

然后找到对应的下载的地方:

http://jeuclid.sourceforge.net/trunk/index.html

->

http://sourceforge.net/projects/jeuclid/files/3.1.x/

->

http://sourceforge.net/projects/jeuclid/files/3.1.x/3.1.9/

->

找了下fop的jar库:

jeuclid-fop-3.1.9-distribution.zip

然后解压拷贝对应的:

copy jeuclid-core-3.1.9 and jeuclid-fop-3.1.9.jar to lib

  • jeuclid-core-3.1.9.jar
  • jeuclid-fop-3.1.9.jar

 

到fop的lib中:

copy two jeuclid lib to fop lib folder

然后再去编译看看。

然后就真的没有错误了。

生成的pdf效果是:

jeuclid fop lib generate pdf effect

很明显,没有看到我们想要的复杂的效果。

所以再去试试别的MathML的例子。

9.去把jeuclid中的example:

E:\dev_root\docbook\tools\MathML\jeuclid-fop-3.1.9-distribution\jeuclid-fop-3.1.9\example\example.mml

中的内容整合过来试试:

<chapter xml:id="ch01_demo_mathml"
    xmlns="http://docbook.org/ns/docbook"
    xmlns:xl="http://www.w3.org/1999/xlink"
    xmlns:xi="http://www.w3.org/2001/XInclude"
    xmlns:mml="http://www.w3.org/1998/Math/MathML"
    xmlns:ns="http://docbook.org/ns/docbook">
    <title>demo MathML</title>

    <equation>
    <title>My MathML example</title>
    <mml:math>
      <mml:mrow>
        <mml:mn>4</mml:mn>
        <mml:mo>+</mml:mo>
        <mml:mi>x</mml:mi>
      </mml:mrow>
    </mml:math>
    </equation>

    <math xmlns="http://www.w3.org/1998/Math/MathML" mode="display">
      <mrow>
        <mo stretchy="false">{</mo>
        <munder>
          <mrow>
            <mover>
              <mrow>
                <mpadded width="0"/>
                <!--mpadded width="0">(</mpadded-->
                <!-- \mathstrut -ugly hack a la TeX -->
                <mi>a</mi>
                <mo>,</mo>
                <mo>...</mo>
                <mo>,</mo>
                <mi>a</mi>
              </mrow>
              <mover>
                <mo>︷</mo>
                <mrow>
                  <mi>k</mi>
                  <mtext> </mtext>
                  <mi>a</mi>
                  <mtext>'s</mtext>
                </mrow>
              </mover>
            </mover>
            <mo>,</mo>
            <mover>
              <mrow>
                <mpadded/>
                <!--mpadded width="0">(</mpadded-->
                <!-- \mathstrut -ugly hack a la TeX -->
                <mi>b</mi>
                <mo>,</mo>
                <mo>...</mo>
                <mo>,</mo>
                <mi>b</mi>
              </mrow>
              <mover>
                <mo>︷</mo>
                <mrow>
                  <mi>ℓ</mi>
                  <mtext> </mtext>
                  <mi>b</mi>
                  <mtext>'s</mtext>
                </mrow>
              </mover>
            </mover>
          </mrow>
          <munder>
            <mo>︸</mo>
            <mrow>
              <mi>k</mi>
              <mo>+</mo>
              <mi>ℓ</mi>
              <mtext> elements</mtext>
            </mrow>
          </munder>
        </munder>
        <mo stretchy="false">}</mo>
      </mrow>
    </math>
    
</chapter>

编译结果是出错:

org.apache.fop.apps.FOPException: org.apache.fop.fo.ValidationException: "{http://www.w3.org/1999/XSL/Format}instream-foreign-object" is not a valid child of "fo:flow"! (See position 1316:35)
javax.xml.transform.TransformerException: org.apache.fop.fo.ValidationException: "{http://www.w3.org/1999/XSL/Format}instream-foreign-object" is not a valid child of "fo:flow"! (See position 1316:35)
        at org.apache.fop.cli.InputHandler.transformTo(InputHandler.java:302)
        at org.apache.fop.cli.InputHandler.renderTo(InputHandler.java:130)
        at org.apache.fop.cli.Main.startFOP(Main.java:174)
        at org.apache.fop.cli.Main.main(Main.java:205)
Caused by: javax.xml.transform.TransformerException: org.apache.fop.fo.ValidationException: "{http://www.w3.org/1999/XSL/Format}instream-foreign-object" is not a valid child of "fo:flow"! (See position 1316:35)
        at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:501)
        at org.apache.fop.cli.InputHandler.transformTo(InputHandler.java:299)
        ... 3 more
Caused by: org.apache.fop.fo.ValidationException: "{http://www.w3.org/1999/XSL/Format}instream-foreign-object" is not a valid child of "fo:flow"! (See position 1316:35)
        at org.apache.fop.events.ValidationExceptionFactory.createException(ValidationExceptionFactory.java:38)
        at org.apache.fop.events.EventExceptionManager.throwException(EventExceptionManager.java:54)
        at org.apache.fop.events.DefaultEventBroadcaster$1.invoke(DefaultEventBroadcaster.java:175)
        at com.sun.proxy.$Proxy1.invalidChild(Unknown Source)
        at org.apache.fop.fo.FONode.invalidChildError(FONode.java:534)
        at org.apache.fop.fo.FONode.invalidChildError(FONode.java:517)
        at org.apache.fop.fo.pagination.Flow.validateChildNode(Flow.java:103)
        at org.apache.fop.fo.FOTreeBuilder$MainFOHandler.startElement(FOTreeBuilder.java:267)
        at org.apache.fop.fo.FOTreeBuilder.startElement(FOTreeBuilder.java:171)
        at org.apache.xalan.transformer.TransformerIdentityImpl.startElement(TransformerIdentityImpl.java:1072)
        at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
        at org.apache.xerces.xinclude.XIncludeHandler.startElement(Unknown Source)
        at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
        at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
        at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
        at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
        at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:484)
        ... 4 more

---------

javax.xml.transform.TransformerException: org.apache.fop.fo.ValidationException: "{http://www.w3.org/1999/XSL/Format}instream-foreign-object" is not a valid child of "fo:flow"! (See position 1316:35)
        at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:501)
        at org.apache.fop.cli.InputHandler.transformTo(InputHandler.java:299)
        at org.apache.fop.cli.InputHandler.renderTo(InputHandler.java:130)
        at org.apache.fop.cli.Main.startFOP(Main.java:174)
        at org.apache.fop.cli.Main.main(Main.java:205)
Caused by: org.apache.fop.fo.ValidationException: "{http://www.w3.org/1999/XSL/Format}instream-foreign-object" is not a valid child of "fo:flow"! (See position 1316:35)
        at org.apache.fop.events.ValidationExceptionFactory.createException(ValidationExceptionFactory.java:38)
        at org.apache.fop.events.EventExceptionManager.throwException(EventExceptionManager.java:54)
        at org.apache.fop.events.DefaultEventBroadcaster$1.invoke(DefaultEventBroadcaster.java:175)
        at com.sun.proxy.$Proxy1.invalidChild(Unknown Source)
        at org.apache.fop.fo.FONode.invalidChildError(FONode.java:534)
        at org.apache.fop.fo.FONode.invalidChildError(FONode.java:517)
        at org.apache.fop.fo.pagination.Flow.validateChildNode(Flow.java:103)
        at org.apache.fop.fo.FOTreeBuilder$MainFOHandler.startElement(FOTreeBuilder.java:267)
        at org.apache.fop.fo.FOTreeBuilder.startElement(FOTreeBuilder.java:171)
        at org.apache.xalan.transformer.TransformerIdentityImpl.startElement(TransformerIdentityImpl.java:1072)
        at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
        at org.apache.xerces.xinclude.XIncludeHandler.startElement(Unknown Source)
        at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
        at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
        at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
        at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
        at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:484)
        ... 4 more
---------
org.apache.fop.fo.ValidationException: "{http://www.w3.org/1999/XSL/Format}instream-foreign-object" is not a valid child of "fo:flow"! (See position 1316:35)
        at org.apache.fop.events.ValidationExceptionFactory.createException(ValidationExceptionFactory.java:38)
        at org.apache.fop.events.EventExceptionManager.throwException(EventExceptionManager.java:54)
        at org.apache.fop.events.DefaultEventBroadcaster$1.invoke(DefaultEventBroadcaster.java:175)
        at com.sun.proxy.$Proxy1.invalidChild(Unknown Source)
        at org.apache.fop.fo.FONode.invalidChildError(FONode.java:534)
        at org.apache.fop.fo.FONode.invalidChildError(FONode.java:517)
        at org.apache.fop.fo.pagination.Flow.validateChildNode(Flow.java:103)
        at org.apache.fop.fo.FOTreeBuilder$MainFOHandler.startElement(FOTreeBuilder.java:267)
        at org.apache.fop.fo.FOTreeBuilder.startElement(FOTreeBuilder.java:171)
        at org.apache.xalan.transformer.TransformerIdentityImpl.startElement(TransformerIdentityImpl.java:1072)
        at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
        at org.apache.xerces.xinclude.XIncludeHandler.startElement(Unknown Source)
        at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
        at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
        at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
        at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
        at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:484)
        at org.apache.fop.cli.InputHandler.transformTo(InputHandler.java:299)
        at org.apache.fop.cli.InputHandler.renderTo(InputHandler.java:130)
        at org.apache.fop.cli.Main.startFOP(Main.java:174)
        at org.apache.fop.cli.Main.main(Main.java:205)

../../../../config/docbook.mk:560: recipe for target `../output/pdf/test_mathml.pdf' failed
make: *** [../output/pdf/test_mathml.pdf] Error 1

10.算了,换成带namespace的:

<chapter xml:id="ch01_demml:mo_mathml"
    xmlns="http://docbook.org/ns/docbook"
    xmlns:xl="http://www.w3.org/1999/xlink"
    xmlns:xi="http://www.w3.org/2001/XInclude"
    xmlns:mml="http://www.w3.org/1998/Math/MathML"
    xmlns:ns="http://docbook.org/ns/docbook">
    <title>demml:mo MathML</title>

      <mml:mrow>
        <mml:mo stretchy="false">{</mml:mo>
        <mml:munder>
          <mml:mrow>
            <mml:mover>
              <mml:mrow>
                <mml:mpadded width="0"/>
                <!--mml:mpadded width="0">(</mml:mpadded-->
                <!-- \mathstrut -ugly hack a la TeX -->
                <mml:mi>a</mml:mi>
                <mml:mo>,</mml:mo>
                <mml:mo>...</mml:mo>
                <mml:mo>,</mml:mo>
                <mml:mi>a</mml:mi>
              </mml:mrow>
              <mml:mover>
                <mml:mo>︷</mml:mo>
                <mml:mrow>
                  <mml:mi>k</mml:mi>
                  <mtext> </mtext>
                  <mml:mi>a</mml:mi>
                  <mtext>'s</mtext>
                </mml:mrow>
              </mml:mover>
            </mml:mover>
            <mml:mo>,</mml:mo>
            <mml:mover>
              <mml:mrow>
                <mml:mpadded/>
                <!--mml:mpadded width="0">(</mml:mpadded-->
                <!-- \mathstrut -ugly hack a la TeX -->
                <mml:mi>b</mml:mi>
                <mml:mo>,</mml:mo>
                <mml:mo>...</mml:mo>
                <mml:mo>,</mml:mo>
                <mml:mi>b</mml:mi>
              </mml:mrow>
              <mml:mover>
                <mml:mo>︷</mml:mo>
                <mml:mrow>
                  <mml:mi>ℓ</mml:mi>
                  <mtext> </mtext>
                  <mml:mi>b</mml:mi>
                  <mtext>'s</mtext>
                </mml:mrow>
              </mml:mover>
            </mml:mover>
          </mml:mrow>
          <mml:munder>
            <mml:mo>︸</mml:mo>
            <mml:mrow>
              <mml:mi>k</mml:mi>
              <mml:mo>+</mml:mo>
              <mml:mi>ℓ</mml:mi>
              <mtext> elements</mtext>
            </mml:mrow>
          </mml:munder>
        </mml:munder>
        <mml:mo stretchy="false">}</mml:mo>
      </mml:mrow>

</chapter>

编译结果是:

还是出错。

11.算了,去找个简单的MathML的例子吧。。

docbook General – Need help using MathML ("Unknown formatting object "{http://www.w3.org/1998/Math/MathML}math" encountered")

    <informalequation>
    <mml:math>
      <mml:msup>
        <mml:mi>x</mml:mi>
        <mml:mn>3</mml:mn>
      </mml:msup>
    </mml:math>
    </informalequation>

结果是:

可以正常生产pdf:

another example can generate mathml ok

12.再去试试:

    <inlineequation>
        <mml:math display="inline">
          <mml:mrow>
            <mml:mrow>
              <mml:mi>x</mml:mi>
              <mml:mo>+</mml:mo>
              <mml:mi>y</mml:mi>
            </mml:mrow>
            <mml:mo>=</mml:mo>
            <mml:mn>2</mml:mn>
          </mml:mrow>
        </mml:math>
    </inlineequation>

结果是:

出错了:

org.apache.fop.apps.FOPException: org.apache.fop.fo.ValidationException: "{http://www.w3.org/1999/XSL/Format}instream-foreign-object" is not a valid child of "fo:flow"! (See position 1026:35)
javax.xml.transform.TransformerException: org.apache.fop.fo.ValidationException: "{http://www.w3.org/1999/XSL/Format}instream-foreign-object" is not a valid child of "fo:flow"! (See position 1026:35)
        at org.apache.fop.cli.InputHandler.transformTo(InputHandler.java:302)
        at org.apache.fop.cli.InputHandler.renderTo(InputHandler.java:130)
        at org.apache.fop.cli.Main.startFOP(Main.java:174)
        at org.apache.fop.cli.Main.main(Main.java:205)
Caused by: javax.xml.transform.TransformerException: org.apache.fop.fo.ValidationException: "{http://www.w3.org/1999/XSL/Format}instream-foreign-object" is not a valid child of "fo:flow"! (See position 1026:35)
        at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:501)
        at org.apache.fop.cli.InputHandler.transformTo(InputHandler.java:299)
        ... 3 more
Caused by: org.apache.fop.fo.ValidationException: "{http://www.w3.org/1999/XSL/Format}instream-foreign-object" is not a valid child of "fo:flow"! (See position 1026:35)
        at org.apache.fop.events.ValidationExceptionFactory.createException(ValidationExceptionFactory.java:38)
        at org.apache.fop.events.EventExceptionManager.throwException(EventExceptionManager.java:54)
        at org.apache.fop.events.DefaultEventBroadcaster$1.invoke(DefaultEventBroadcaster.java:175)
        at com.sun.proxy.$Proxy1.invalidChild(Unknown Source)
        at org.apache.fop.fo.FONode.invalidChildError(FONode.java:534)
        at org.apache.fop.fo.FONode.invalidChildError(FONode.java:517)
        at org.apache.fop.fo.pagination.Flow.validateChildNode(Flow.java:103)
        at org.apache.fop.fo.FOTreeBuilder$MainFOHandler.startElement(FOTreeBuilder.java:267)
        at org.apache.fop.fo.FOTreeBuilder.startElement(FOTreeBuilder.java:171)
        at org.apache.xalan.transformer.TransformerIdentityImpl.startElement(TransformerIdentityImpl.java:1072)
        at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
        at org.apache.xerces.xinclude.XIncludeHandler.startElement(Unknown Source)
        at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
        at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
        at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
        at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
        at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:484)
        ... 4 more

---------

javax.xml.transform.TransformerException: org.apache.fop.fo.ValidationException: "{http://www.w3.org/1999/XSL/Format}instream-foreign-object" is not a valid child of "fo:flow"! (See position 1026:35)
        at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:501)
        at org.apache.fop.cli.InputHandler.transformTo(InputHandler.java:299)
        at org.apache.fop.cli.InputHandler.renderTo(InputHandler.java:130)
        at org.apache.fop.cli.Main.startFOP(Main.java:174)
        at org.apache.fop.cli.Main.main(Main.java:205)
Caused by: org.apache.fop.fo.ValidationException: "{http://www.w3.org/1999/XSL/Format}instream-foreign-object" is not a valid child of "fo:flow"! (See position 1026:35)
        at org.apache.fop.events.ValidationExceptionFactory.createException(ValidationExceptionFactory.java:38)
        at org.apache.fop.events.EventExceptionManager.throwException(EventExceptionManager.java:54)
        at org.apache.fop.events.DefaultEventBroadcaster$1.invoke(DefaultEventBroadcaster.java:175)
        at com.sun.proxy.$Proxy1.invalidChild(Unknown Source)
        at org.apache.fop.fo.FONode.invalidChildError(FONode.java:534)
        at org.apache.fop.fo.FONode.invalidChildError(FONode.java:517)
        at org.apache.fop.fo.pagination.Flow.validateChildNode(Flow.java:103)
        at org.apache.fop.fo.FOTreeBuilder$MainFOHandler.startElement(FOTreeBuilder.java:267)
        at org.apache.fop.fo.FOTreeBuilder.startElement(FOTreeBuilder.java:171)
        at org.apache.xalan.transformer.TransformerIdentityImpl.startElement(TransformerIdentityImpl.java:1072)
        at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
        at org.apache.xerces.xinclude.XIncludeHandler.startElement(Unknown Source)
        at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
        at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
        at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
        at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
        at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:484)
        ... 4 more
---------
org.apache.fop.fo.ValidationException: "{http://www.w3.org/1999/XSL/Format}instream-foreign-object" is not a valid child of "fo:flow"! (See position 1026:35)
        at org.apache.fop.events.ValidationExceptionFactory.createException(ValidationExceptionFactory.java:38)
        at org.apache.fop.events.EventExceptionManager.throwException(EventExceptionManager.java:54)
        at org.apache.fop.events.DefaultEventBroadcaster$1.invoke(DefaultEventBroadcaster.java:175)
        at com.sun.proxy.$Proxy1.invalidChild(Unknown Source)
        at org.apache.fop.fo.FONode.invalidChildError(FONode.java:534)
        at org.apache.fop.fo.FONode.invalidChildError(FONode.java:517)
        at org.apache.fop.fo.pagination.Flow.validateChildNode(Flow.java:103)
        at org.apache.fop.fo.FOTreeBuilder$MainFOHandler.startElement(FOTreeBuilder.java:267)
        at org.apache.fop.fo.FOTreeBuilder.startElement(FOTreeBuilder.java:171)
        at org.apache.xalan.transformer.TransformerIdentityImpl.startElement(TransformerIdentityImpl.java:1072)
        at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
        at org.apache.xerces.xinclude.XIncludeHandler.startElement(Unknown Source)
        at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
        at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
        at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
        at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
        at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:484)
        at org.apache.fop.cli.InputHandler.transformTo(InputHandler.java:299)
        at org.apache.fop.cli.InputHandler.renderTo(InputHandler.java:130)
        at org.apache.fop.cli.Main.startFOP(Main.java:174)
        at org.apache.fop.cli.Main.main(Main.java:205)

所以去尝试解决此MathML的语言错误。

13.去查查MathML的语法。

找到了官网:

MathML Namespace

->

Mathematical Markup Language (MathML) Version 3.0

->

Presentation Markup

里面有N多例子和详细语法的解释。

14.最后,终于搞清楚上述的错误原因了:

误把informalequation弄成了inlineequation

->是的编译时出错,说是,对于(inlineequation的)instream-foreign-object其下不支持fo:flow

->而对于本身informalequation,是正常支持的

最后,用:

<chapter xml:id="ch01_demml:mo_mathml"
    xmlns="http://docbook.org/ns/docbook"
    xmlns:xl="http://www.w3.org/1999/xlink"
    xmlns:xi="http://www.w3.org/2001/XInclude"
    xmlns:mml="http://www.w3.org/1998/Math/MathML"
    xmlns:ns="http://docbook.org/ns/docbook">
    <title>demo MathML</title>

    <informalequation>
        <mml:math display="inline">
          <mml:mrow>
            <mml:mrow>
              <mml:mi>x</mml:mi>
              <mml:mo>+</mml:mo>
              <mml:mi>y</mml:mi>
            </mml:mrow>
            <mml:mo>=</mml:mo>
            <mml:mn>2</mml:mn>
          </mml:mrow>
        </mml:math>
    </informalequation>

</chapter>

就可以正常的生成pdf了:

finnally use informalequation instead of inlineequation to docbook to pdf ok

15.另外,再去参考官网的很多例子:

去试试各种效果:

(1)代码:

<informalequation>
    <mml:math>
        <mml:mrow>
           <mml:mo> ( </mml:mo>
           <mml:mfrac linethickness="0">
              <mml:mi> a </mml:mi>
              <mml:mi> b </mml:mi>
           </mml:mfrac>
           <mml:mo> ) </mml:mo>
        </mml:mrow>
        <mml:mfrac linethickness="2">
           <mml:mfrac>
              <mml:mi> a </mml:mi>
              <mml:mi> b </mml:mi>
           </mml:mfrac>
           <mml:mfrac>
              <mml:mi> c </mml:mi>
              <mml:mi> d </mml:mi>
           </mml:mfrac>
        </mml:mfrac>
    </mml:math>
</informalequation>

效果:

mfrac effect of mathml not good

评价:不太好,和原先官网的效果有很大差距。。。

(2)代码:

<informalequation>
    <mml:math>
        <mml:mfrac>
           <mml:mn> 1 </mml:mn>
           <mml:mrow>
              <mml:msup>
                 <mml:mi> x </mml:mi>
                 <mml:mn> 3 </mml:mn>
               </mml:msup>
               <mml:mo> + </mml:mo>
               <mml:mfrac>
                 <mml:mi> x </mml:mi>
                 <mml:mn> 3 </mml:mn>
               </mml:mfrac>
           </mml:mrow>
        </mml:mfrac>
        <mml:mo> = </mml:mo>
        <mml:mfrac bevelled="true">
           <mml:mn> 1 </mml:mn>
           <mml:mrow>
              <mml:msup>
                 <mml:mi> x </mml:mi>
                 <mml:mn> 3 </mml:mn>
               </mml:msup>
               <mml:mo> + </mml:mo>
               <mml:mfrac>
                 <mml:mi> x </mml:mi>
                 <mml:mn> 3 </mml:mn>
               </mml:mfrac>
           </mml:mrow>
        </mml:mfrac>
    </mml:math>
</informalequation>

效果:

another mfrac and mn mrow mi mo good effect

评价:效果真心不错。

16.另外再参考:

Presentation Examples

最后来个大集合:

<?xml version='1.0' encoding="utf-8"?>

<!DOCTYPE book
[

<!ENTITY cur_book_name      "test_mathml" >
<!ENTITY publish_date       "2014-07-05" >
<!ENTITY release_version    "0.1" >

<!ENTITY copyrith_year "2014" >
]>

<book version="5.0"
    xmlns="http://docbook.org/ns/docbook"
    xmlns:xi="http://www.w3.org/2001/XInclude"
    xmlns:xl="http://www.w3.org/1999/xlink"
    xmlns:mml="http://www.w3.org/1998/Math/MathML"
    
    xml:lang="zh_CN">
<info>
    <title>测试Mathml</title>
    <subtitle></subtitle>
    <keywordset>
        <keyword>测试</keyword>
        <keyword>MathML</keyword>
    </keywordset>

    <abstract>
        <para>测试MathML是否能正常在转换后的pdf和html中显示</para>
    </abstract>

    <revhistory>
        <revision>
            <revnumber>&release_version;</revnumber>
            <date>&publish_date;</date>
            <revremark>
                <orderedlist>
                    <listitem>第一版</listitem>
                </orderedlist>
            </revremark>
            <authorinitials>crl</authorinitials>
        </revision>
    </revhistory>

</info>

<chapter xml:id="ch01_demml:mo_mathml"
    xmlns="http://docbook.org/ns/docbook"
    xmlns:xl="http://www.w3.org/1999/xlink"
    xmlns:xi="http://www.w3.org/2001/XInclude"
    xmlns:mml="http://www.w3.org/1998/Math/MathML"
    xmlns:ns="http://docbook.org/ns/docbook">
    <title>demo MathML</title>

    <sect1 xml:id="mathml_demo_mrow"><title>MathML演示:mrow的效果</title>
        <para>代码:</para>
        <programlisting language="xml">
<![CDATA[
    <informalequation>
        <mml:math display="inline">
          <mml:mrow>
            <mml:mrow>
              <mml:mi>x</mml:mi>
              <mml:mo>+</mml:mo>
              <mml:mi>y</mml:mi>
            </mml:mrow>
            <mml:mo>=</mml:mo>
            <mml:mn>2</mml:mn>
          </mml:mrow>
        </mml:math>
    </informalequation>
]]>
        </programlisting>
        <para>效果:</para>
        <informalequation>
            <mml:math display="inline">
              <mml:mrow>
                <mml:mrow>
                  <mml:mi>x</mml:mi>
                  <mml:mo>+</mml:mo>
                  <mml:mi>y</mml:mi>
                </mml:mrow>
                <mml:mo>=</mml:mo>
                <mml:mn>2</mml:mn>
              </mml:mrow>
            </mml:math>
        </informalequation>
    </sect1>

    <sect1 xml:id="mathml_demo_msup"><title>MathML演示:msup的效果</title>
        <para>代码:</para>
        <programlisting language="xml">
<![CDATA[
    <informalequation>
        <mml:math>
          <mml:msup>
            <mml:mi>x</mml:mi>
            <mml:mn>3</mml:mn>
          </mml:msup>
        </mml:math>
    </informalequation>
    
    <informalequation>
        <mml:math>
          <mml:msup>
            <mml:msqrt>
              <mml:mrow>
                <mml:mi>a</mml:mi>
                <mml:mo>+</mml:mo>
                <mml:mi>b</mml:mi>
              </mml:mrow>
            </mml:msqrt>
            <mn>27</mn>
          </mml:msup>
        </mml:math>
    </informalequation>
]]>
        </programlisting>
        <para>效果:</para>
        <informalequation>
            <mml:math>
              <mml:msup>
                <mml:mi>x</mml:mi>
                <mml:mn>3</mml:mn>
              </mml:msup>
            </mml:math>
        </informalequation>
        
        <informalequation>
            <mml:math>
              <mml:msup>
                <mml:msqrt>
                  <mml:mrow>
                    <mml:mi>a</mml:mi>
                    <mml:mo>+</mml:mo>
                    <mml:mi>b</mml:mi>
                  </mml:mrow>
                </mml:msqrt>
                <mn>27</mn>
              </mml:msup>
            </mml:math>
        </informalequation>
    </sect1>

    <sect1 xml:id="mathml_demo_mfrac_1"><title>MathML演示:mfrac的效果1</title>
        <para>代码:</para>
        <programlisting language="xml">
<![CDATA[
    <informalequation>
        <mml:math>
            <mml:mrow>
               <mml:mo> ( </mml:mo>
               <mml:mfrac linethickness="0">
                  <mml:mi> a </mml:mi>
                  <mml:mi> b </mml:mi>
               </mml:mfrac>
               <mml:mo> ) </mml:mo>
            </mml:mrow>
            <mml:mfrac linethickness="2">
               <mml:mfrac>
                  <mml:mi> a </mml:mi>
                  <mml:mi> b </mml:mi>
               </mml:mfrac>
               <mml:mfrac>
                  <mml:mi> c </mml:mi>
                  <mml:mi> d </mml:mi>
               </mml:mfrac>
            </mml:mfrac>
        </mml:math>
    </informalequation>
]]>
        </programlisting>
        <para>效果:</para>
        <informalequation>
            <mml:math>
                <mml:mrow>
                   <mml:mo> ( </mml:mo>
                   <mml:mfrac linethickness="0">
                      <mml:mi> a </mml:mi>
                      <mml:mi> b </mml:mi>
                   </mml:mfrac>
                   <mml:mo> ) </mml:mo>
                </mml:mrow>
                <mml:mfrac linethickness="2">
                   <mml:mfrac>
                      <mml:mi> a </mml:mi>
                      <mml:mi> b </mml:mi>
                   </mml:mfrac>
                   <mml:mfrac>
                      <mml:mi> c </mml:mi>
                      <mml:mi> d </mml:mi>
                   </mml:mfrac>
                </mml:mfrac>
            </mml:math>
        </informalequation>
    </sect1>

    <sect1 xml:id="mathml_demo_mfrac_2"><title>MathML演示:mfrac的效果2</title>
        <para>代码:</para>
        <programlisting language="xml">
<![CDATA[
    <informalequation>
        <mml:math>
            <mml:mfrac>
               <mml:mn> 1 </mml:mn>
               <mml:mrow>
                  <mml:msup>
                     <mml:mi> x </mml:mi>
                     <mml:mn> 3 </mml:mn>
                   </mml:msup>
                   <mml:mo> + </mml:mo>
                   <mml:mfrac>
                     <mml:mi> x </mml:mi>
                     <mml:mn> 3 </mml:mn>
                   </mml:mfrac>
               </mml:mrow>
            </mml:mfrac>
            <mml:mo> = </mml:mo>
            <mml:mfrac bevelled="true">
               <mml:mn> 1 </mml:mn>
               <mml:mrow>
                  <mml:msup>
                     <mml:mi> x </mml:mi>
                     <mml:mn> 3 </mml:mn>
                   </mml:msup>
                   <mml:mo> + </mml:mo>
                   <mml:mfrac>
                     <mml:mi> x </mml:mi>
                     <mml:mn> 3 </mml:mn>
                   </mml:mfrac>
               </mml:mrow>
            </mml:mfrac>
        </mml:math>
    </informalequation>
]]>
        </programlisting>
        <para>效果:</para>
        <informalequation>
            <mml:math>
                <mml:mfrac>
                   <mml:mn> 1 </mml:mn>
                   <mml:mrow>
                      <mml:msup>
                         <mml:mi> x </mml:mi>
                         <mml:mn> 3 </mml:mn>
                       </mml:msup>
                       <mml:mo> + </mml:mo>
                       <mml:mfrac>
                         <mml:mi> x </mml:mi>
                         <mml:mn> 3 </mml:mn>
                       </mml:mfrac>
                   </mml:mrow>
                </mml:mfrac>
                <mml:mo> = </mml:mo>
                <mml:mfrac bevelled="true">
                   <mml:mn> 1 </mml:mn>
                   <mml:mrow>
                      <mml:msup>
                         <mml:mi> x </mml:mi>
                         <mml:mn> 3 </mml:mn>
                       </mml:msup>
                       <mml:mo> + </mml:mo>
                       <mml:mfrac>
                         <mml:mi> x </mml:mi>
                         <mml:mn> 3 </mml:mn>
                       </mml:mfrac>
                   </mml:mrow>
                </mml:mfrac>
            </mml:math>
        </informalequation>
    </sect1>


    <sect1 xml:id="mathml_demo_mfenced"><title>MathML演示:mfenced的效果</title>
        <para>代码:</para>
        <programlisting language="xml">
<![CDATA[
    <informalequation>
        <mml:math>
          <mml:mrow>
            <mml:msup>
              <mml:mfenced open="[" close="]">
                <mml:mrow>
                  <mml:mi>a</mml:mi>
                  <mml:mo>+</mml:mo>
                  <mml:mi>b</mml:mi>
                </mml:mrow>
              </mml:mfenced>
              <mn>260</mn>
            </mml:msup>
            <mml:mo>+</mml:mo>
            <mml:msub>
              <mml:mfenced open="{" close="}">
                <mml:mrow>
                  <mml:mi>a</mml:mi>
                  <mml:mo>+</mml:mo>
                  <mml:mi>b</mml:mi>
                </mml:mrow>
              </mml:mfenced>
              <mml:mi>i</mml:mi>
            </mml:msub>
          </mml:mrow>
        </mml:math>
    </informalequation>
]]>
        </programlisting>
        <para>效果:</para>
        <informalequation>
            <mml:math>
              <mml:mrow>
                <mml:msup>
                  <mml:mfenced open="[" close="]">
                    <mml:mrow>
                      <mml:mi>a</mml:mi>
                      <mml:mo>+</mml:mo>
                      <mml:mi>b</mml:mi>
                    </mml:mrow>
                  </mml:mfenced>
                  <mn>260</mn>
                </mml:msup>
                <mml:mo>+</mml:mo>
                <mml:msub>
                  <mml:mfenced open="{" close="}">
                    <mml:mrow>
                      <mml:mi>a</mml:mi>
                      <mml:mo>+</mml:mo>
                      <mml:mi>b</mml:mi>
                    </mml:mrow>
                  </mml:mfenced>
                  <mml:mi>i</mml:mi>
                </mml:msub>
              </mml:mrow>
            </mml:math>
        </informalequation>
    </sect1>

</chapter>

</book>

效果:

collect many mathml code and example 1

collect many mathml code and example 2

collect many mathml code and example 3

collect many mathml code and example 4

collect many mathml code and example 5

collect many mathml code and example 6

collect many mathml code and example 7

评价:

其中部分的内容,显示异常,比如开根号之后的27次方等内容。

 

【总结】

此处在fop中用jeuclid去支持MathML的效果是:

1.一般的内容,都是可以正常输出pdf效果的。

2.有些复杂的,输出效果,要么是格式不对,要么是缺少内容。

总体评价:凑合用吧。

转载请注明:在路上 » 【记录】尝试给Docbook添加MathML的支持

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
82 queries in 0.194 seconds, using 22.41MB memory