http://www.napcsweb.com/blog/2008/03/03/working-with-docbook-on-windows/
Posted by Brian in Howto, snacks, tips (March 3rd, 2008)
Setting up a toolchain for working with Docbook on Windows often requires setting things up using Cygwin. Many people are just simply not willing to do that. This tutorial will show you how to set up a native environment to work with Docbook, and show you how to make CHM and PDF files on Windows.
通常情况下,在设置Windows环境下的Docbook时都需要用到Cygwin。但是有些人不想那么麻烦。这篇入门指导将会介绍如何在Windows自然环境下配置Docbook,以及如何制成CHM和PDF文件。
Thanks to http://supportweb.cs.bham.ac.uk/documentation/tutorials/docsystem/build/tutorials/docbooksys/segmentedhtml/ch03s03.html#DocBookSys-Chapter3-XML-Install-libxml-Windows for much of this information.
感谢http://supportweb.cs.bham.ac.uk /documentation/tutorials/docsystem/build/tutorials/docbooksys/segmentedhtml/ch03s03.html#DocBookSys-Chapter3-XML-Install-libxml-Windows 提供丰富的信息指导。
Getting the tools
The tools you need to work with Docbook XML and XSTL are all available on Windows. The first thing you need to do is visit http://www.zlatkovic.com/pub/libxml/ (new window) and grab the latest versions of
* libxml2
* libxslt
* iconv
Download each and unzip the contents of the folder to c:\windows or another location on your path. For reference, these files are the ones you’re looking for:
iconv.exe
libexslt.dll
libxml2.dll
libxslt.dll
xmlcatalog.exe
xmllint.exe
xsltproc.exe
If you feel better about putting these in their own folder, that’s fine as long as you add the new folder to your path.
下载工具
您需要在 Windows下配置好Docbook XML和XSTL。首先需要访问 http://www.zlatkovic.com/pub/libxml/ 下载最终版本的
* libxml2
* libxslt
* iconv
下载并且解压缩到 c:\windows或者其他文件夹下。请确认一下这些文件:
iconv.exe
libexslt.dll
libxml2.dll
libxslt.dll
xmlcatalog.exe
xmllint.exe
xsltproc.exe
如果您觉得更想让他们在自己的文件夹下,那一定要把文件夹添加到您的路径下。(译者注:就是添加到Path环境变量里。)
Getting the Stylesheets
In order to build a book, you need to have the XSLT stylesheets so you can transform your XML into a pretty-looking book with a table of contents and nicely formatted text.
Download the docbook-xml-ns files from sourceforge: http://sourceforge.net/project/showfiles.php?group_id=21935
Unpack to your c:\ drive and then rename the extracted folder to c:\docbook-xsl
下载样式表
为了创建一本书,您需要有XSLT样式表来让您可以把XML文件变成精美的带有目录的图书和有着漂亮格式的文本。
从sourceforge下载docbook-xml-ns文件:http://sourceforge.net/project/showfiles.php?group_id=21935
解压缩到c:\docbook-xsl
Generating PDFs
In order to create a PDF, you have to first convert to the FO format and then use a Java library to convert the FO to a PDF. Apache FOP does this for you. You’ll need to have a JRE (Java Runtime) installed though. Visit http://java.sun.com/ for that.
创建PDF文件
为了创建PDF文件,您需要首先把文件转换为FO格式的文件,然后使用Java库把 FO文件转化为PDF文件。Apache的FOP就是为您而制的。不过您需要先安装好JRE(Java 运行环境)。请访问http://java.sun.com/ 。
Get FOP to build PDFs
Download FOP at http://www.uniontransit.com/apache/xmlgraphics/fop/fop-0.94-bin-jdk1.4.zip and unzip it to a temp location. Copy all .jar files in build/ and lib/ to your Java installation’s lib/ext folder. On my system it’s C:\Program Files\Java\jre1.5.0_11\lib\ext. Your system will differ depending on your installed version of Java.
Next, download OFFO-hyphenation from http://offo.sourceforge.net/index.html and grab the offo-hyphenation-fop-stable.zip file from the downloads page and put the jar files in the same folder as the FOP files.
下载创建PDF文件的FOP
在http://www.uniontransit.com/apache/xmlgraphics/fop/fop-0.94-bin-jdk1.4.zip 下载FOP文件并且解压缩到一个临时目录中。拷贝所有 build/ 和 lib/目录中的 .jar 文件到您Java安装文件夹的 lib/ext 目录中。在我的系统下是 C:\Program Files\Java\jre1.5.0_11\lib\ext 。您的系统的具体情况主要是由您安装的Java的版本决定的。
下一步,下载从http://offo.sourceforge.net /index.html下载 OFFO-hyphenation 并且把 offo-hyphenation-fop-stable.zip文件里的jar文件都复制到和FOP相同的文件夹里。
Building your first book
创建您的第一本书
Create a project folder called “my_book” and create a new file called “book.xml” in this folder.
创建一个叫“my_book”的项目文件夹,并且在这个文件夹里创建一个叫“book.xml”的文件。
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
<book>
<bookinfo>
<title>My Simple Book</title>
</bookinfo>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="chapter1.xml"/>
</book>
Then create a chapter for your book. Create the file chapter1.xml in your project folder with this content:
然后在您的书里创建一个章节。在您的项目文件夹里创建内容如下的 chapter1.xml文件:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
<chapter
Summary
总结
Docbook is a really great way to create books, tutorials, and documentation in a format that can be transformed into various other formats. It’s extremly easy to work with in Windows too!
Docbook是一种很伟大的创建图书、入门向导和文章的方式,并且文档能够被转换为各种格式。在 Windows下也能轻松使用了!