【背景】
已经折腾好了,实现最基本的,将Docbook 5.0输入为pdf:
但是示例源码xml中是article,此处希望改为book类型。
然后再一点点把原先某文章内容,移植过来。
此处记录此过程。
1.参考:http://learn.akae.cn/media/index.html,将xml源码改为:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | <? xml version = '1.0' encoding = "utf-8" ?> < bookinfo > < title >我的第一篇Docbook 5.0文档</ title > < author > < firstname >Crifan</ firstname > < surname >Li</ surname > </ author > </ bookinfo > < section > < title >文档介绍</ title > < para > </ para > </ section > </ book > |
然后cygwin中:
1 2 3 | CLi@PC-CLI-1 ~ /develop/docbook/written/test $ xsltproc.exe -o fo /cnBookTest .fo /home/CLi/develop/docbook/tools/docbook-xsl-ns-1 .76.1 /fo/docbook_fo .xsl cnBookTest.xml Making portrait pages on USletter paper (8.5inx11in) |
cmd中,fop出错:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | D:\tmp\tmp_dev_root\cgwin\home\CLi\develop\docbook\written\ test >fop -c D:\tmp\tmp_dev_root\cgwin\etc\fop\fop.xconf D:\tmp\tmp_dev_root\cgwin\home\CLi\develop\docbook\written\ test \fo\cnBookTest.fo -pdf D:\tmp\tmp_dev_root \cgwin\home\CLi\develop\docbook\written\ test \output\pdf\cnBookTest.pdf Apr 26, 2012 4:30:34 PM org.apache.fop.apps.FopFactoryConfigurator configure INFO: Default page-height set to: 11in Apr 26, 2012 4:30:34 PM org.apache.fop.apps.FopFactoryConfigurator configure INFO: Default page-width set to: 8.26in Apr 26, 2012 4:30:35 PM org.apache.fop.events.LoggingEventListener processEvent WARNING: Font "Symbol,normal,700" not found. Substituting with "Symbol,normal,400" . Apr 26, 2012 4:30:35 PM org.apache.fop.events.LoggingEventListener processEvent WARNING: Font "ZapfDingbats,normal,700" not found. Substituting with "ZapfDingbats,normal,400" . Apr 26, 2012 4:30:35 PM org.apache.fop.hyphenation.Hyphenator getHyphenationTree SEVERE: Couldn't find hyphenation pattern zh_cn Apr 26, 2012 4:30:35 PM org.apache.fop.cli.Main startFOP SEVERE: Exception javax.xml.transform.TransformerException: org.apache.fop.fo.ValidationException: "fo:flow" is missing child elements. Required content model: marker* (%block;)+ (See position 2:29101) 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: "fo:flow" is missing child elements. Required content model: marker* (%block;)+ (See position 2:29101) at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:501) at org.apache.fop.cli.InputHandler.transformTo(InputHandler.java:299) ... 3 more 。。。。。。。。。。。。 |
2.看到这里的解释:
Re: fop-0.93 gives fo:flow error converting docbook5 –> pdf
感觉好像是说要在book段中添加一些内容,就可以了。
所以先去试试,多添加一些内容,再去编译试试。
最后是,参考了:
最后把源码改为:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | <? xml version = '1.0' encoding = "utf-8" ?> < bookinfo > < title >我的第一篇Docbook 5.0文档</ title > < author >< firstname >李茂</ firstname >< affiliation >< orgname >crifan.com</ orgname ></ affiliation >< email >admin AT crifan DOT com</ email ></ author > < pubdate >2012.04.26</ pubdate > < copyright > < year >2012</ year > < holder >李茂</ holder > < holder >crifan.com</ holder > </ copyright > < legalnotice > < para >Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; </ para > </ legalnotice > < revhistory > < revision > < revnumber >0.1</ revnumber > < date >2012.04.26</ date > < revdescription > < para >最原始版本,开始搭建book的架构。</ para > </ revdescription > </ revision > </ revhistory > </ bookinfo > < part > < title >第一部分的标题</ title > < chapter > < title >第一部分的第一章的标题</ title > < para >这是第一部分的第一段</ para > < para >这是第一部分的第二段</ para > </ chapter > < chapter > < title >第一部分的第二章的标题</ title > </ chapter > </ part > < part > < title >第二部分的标题</ title > < chapter > < title >第二部分的第一章的标题</ title > < para > 第二部分的第一章的第一个段落 </ para > </ chapter > < chapter > < title >第二部分的第二章的标题</ title > < para > 第二部分的第一章的第二个段落 </ para > </ chapter > </ part > </ book > |
用同样的命令去生成的pdf,其中的目录效果为:
4.关于lang的问题,去添加了:
<book xmlns="http://docbook.org/ns/docbook" version="5.0" xmlns:xlink=’http://www.w3.org/1999/xlink’ xmlns:xi="http://www.w3.org/2001/XInclude" xml:lang="zh-CN"> |
然后 xsltproc编译没问题,但是fop转换时候出现错误:
SEVERE: Couldn’t find hyphenation pattern zh_cn |
网上找了下:
使用FOP转换Docbook到PDF时遇到的错误及解决 (一)
其解释说,对于中文来说,可以忽略,而且目前生成出来的pdf的中文显示,貌似也是OK的,所以就暂时不管了。
5.找到了官方文档:
DocBook 5: The Definitive Guide
的中文版,先是从DocBook 5.0中文版下载到的defguide5-zh_CN-r7406.pdf,后来又找到了原始出处:
http://code.google.com/p/i18n-zh/downloads/list
且有最新版本的,比如此时的最新版本是r8205的:
DocBook 5.0: 权威指南 – pdf(r8205) – fop
在此感谢作者。
5.参考dedication,又去添加了题词(Declaration):
1 2 3 | < dedication > < para >感谢天,感谢地,感谢阳光和照耀着大地</ para > </ dedication > |
效果如下:
转载请注明:在路上 » 【记录】如何写Docbook 5.0的Book的源码