在Windows环境下搭建Docbook编译环境

DocBook最早采用的是SGML技术,目前已经有了相应XML技术的实现,DocBook 实际上是用SGML/XML定义的

一种针对文档撰写的方言,指的就是用SGML/XML定义了一套DTD。DTD就是DocBook的核心。目前DocBook DTD

由Oasis-Open 组织的一个技术委员会维护,并在其网站发布关于DocBook DTD的最新消息和DTD下载。DTD的下载

格式有符合SGML规范的DTD、符合XML规范的DTD、使用最新的Schema格式描述的DTD格式等。但目前只有前两个版

本是正式版本,使用其它格式描述的DTD还在不断发展中。SGML格式的DocBook DTD下载地址为:

http://www.oasis-open.org/docbook/sgml/4.2/index.shtml 

XML格式的DocBook DTD下载地址为 :

http://www.oasis-open.org/docbook/xml/4.2/index.shtml 

下载得到的docbook-4.2.zip和docbook-xml-4.2.zip中都有两个文件,即docbook.catcatalog.xml,

它们分别是SGML和XML格式的目录文件(catalog),负责将SGML和XML文档中声明的公共标识符(publicIdentifier)

来和本地文件建立映射。这两个文件的格式不同但含义相同,关于这两个文件的语法我们将在后面的章节具体讲解。

我们还需要下载ISO Entities.

SGML格式的ISO  Entities下载地址为: http://www.oasis-open.org/cover/ISOEnts.zip

XML格式的ISO Entities 下载地址为 :  

http://www.oasis-open.org/committees/docbook/xmlcharent/0.3/xmlcharent-0.3.zip

以下是具体的安装步骤:

1) 创建docbook根目录. 例如:c:\share,share就是我们在后文中常提到的根目录.

2) 安装dtd.

   2.1) 在c:\share目录下创建dtd子目录:c:\share\dtd\4.2,将docbook-4.2.zip的内容解压到该目录中.

   2.2) 在catalog.xml中,删除所有与ISO 8879:1986相关的行,例如:

        <public publicId="ISO 8879:1986//ENTITIES Diacritical Marks//EN" uri="iso-dia.gml"/>

   2.3) 在docbook.cat中,删除所有与ISO 8879:1986相关的行,例如:

       PUBLIC "ISO 8879:1986//ENTITIES Diacritical Marks//EN" "iso-dia.gml"

   2.4) 在dbcentx.mod中,将Unix的路径表达方式修改为Windows的路径表达方式(即"/"改为"\"),例如:

       "ent/iso-amsb.ent"> 修改为 "ent\iso-amsb.ent">

3) 安装和配置ISO Entities.

   3.1) 在c:\share下创建entity\sgml子目录c:\share\entity\sgml, 将ISOEnts.zip内容解压到该目录下.

   3.2)在c:\share下创建entity\xml子目录c:\share\entity\xml,将xmlcharent-0.3.zip内容解压到该目录下.

   3.3)在c:\share\entity\目录下,为sgml创建目录文件:catalog.sgml 内容为:

OVERRIDE YES

-- ...................................................................... --

-- ISO entity sets for DocBook SGML ..................................... --

PUBLIC "ISO 8879:1986//ENTITIES Diacritical Marks//EN"

       "sgml\ISOamsa"

PUBLIC "ISO 8879:1986//ENTITIES Numeric and Special Graphic//EN"

       "sgml\ISOnum"

PUBLIC "ISO 8879:1986//ENTITIES Publishing//EN"

       "sgml\ISOpub"

PUBLIC "ISO 8879:1986//ENTITIES General Technical//EN"

       "sgml\ISOtech"

PUBLIC "ISO 8879:1986//ENTITIES Added Latin 1//EN"

       "sgml\ISOlat1"

PUBLIC "ISO 8879:1986//ENTITIES Added Latin 2//EN"

       "sgml\ISOlat2"

PUBLIC "ISO 8879:1986//ENTITIES Greek Letters//EN"

       "sgml\ISOgrk1"

PUBLIC "ISO 8879:1986//ENTITIES Monotoniko Greek//EN"

       "sgml\ISOgrk2"

PUBLIC "ISO 8879:1986//ENTITIES Greek Symbols//EN"

       "sgml\ISOgrk3"

PUBLIC "ISO 8879:1986//ENTITIES Alternative Greek Symbols//EN"

       "sgml\ISOgrk4"

PUBLIC "ISO 8879:1986//ENTITIES Added Math Symbols: Arrow Relations//EN"

       "sgml\ISOamsa"

PUBLIC "ISO 8879:1986//ENTITIES Added Math Symbols: Binary Operators//EN"

       "sgml\ISOamsb"

PUBLIC "ISO 8879:1986//ENTITIES Added Math Symbols: Delimiters//EN"

       "sgml\ISOamsc"

PUBLIC "ISO 8879:1986//ENTITIES Added Math Symbols: Negated Relations//EN"

       "sgml\ISOamsn"

PUBLIC "ISO 8879:1986//ENTITIES Added Math Symbols: Ordinary//EN"

       "sgml\ISOamso"

PUBLIC "ISO 8879:1986//ENTITIES Added Math Symbols: Relations//EN"

       "sgml\ISOamsr"

PUBLIC "ISO 8879:1986//ENTITIES Box and Line Drawing//EN"

       "sgml\ISObox"

PUBLIC "ISO 8879:1986//ENTITIES Russian Cyrillic//EN"

       "sgml\ISOcyr1"

PUBLIC "ISO 8879:1986//ENTITIES Non-Russian Cyrillic//EN"

       "sgml\ISOcyr2"

-- End of ISO entity sets for DocBook SGML .............................. --

-- ...................................................................... --

-- ...................................................................... --

-- ISO entity sets for DocBook XML ...................................... --

PUBLIC "ISO 8879:1986//ENTITIES Diacritical Marks//EN//XML"

       "xml/iso-dia.ent"

PUBLIC "ISO 8879:1986//ENTITIES Numeric and Special Graphic//EN//XML"

       "xml/iso-num.ent"

PUBLIC "ISO 8879:1986//ENTITIES Publishing//EN//XML"

       "xml/iso-pub.ent"

PUBLIC "ISO 8879:1986//ENTITIES General Technical//EN//XML"

       "xml/iso-tech.ent"

PUBLIC "ISO 8879:1986//ENTITIES Added Latin 1//EN//XML"

       "xml/iso-lat1.ent"

PUBLIC "ISO 8879:1986//ENTITIES Added Latin 2//EN//XML"

       "xml/iso-lat2.ent"

PUBLIC "ISO 8879:1986//ENTITIES Greek Letters//EN//XML"

       "xml/iso-grk1.ent"

PUBLIC "ISO 8879:1986//ENTITIES Monotoniko Greek//EN//XML"

       "xml/iso-grk2.ent"

PUBLIC "ISO 8879:1986//ENTITIES Greek Symbols//EN//XML"

       "xml/iso-grk3.ent"

PUBLIC "ISO 8879:1986//ENTITIES Alternative Greek Symbols//EN//XML"

       "xml/iso-grk4.ent"

PUBLIC "ISO 8879:1986//ENTITIES Added Math Symbols: Arrow Relations//EN//XML"

       "xml/iso-amsa.ent"

PUBLIC "ISO 8879:1986//ENTITIES Added Math Symbols: Binary Operators//EN//XML"

       "xml/iso-amsb.ent"

PUBLIC "ISO 8879:1986//ENTITIES Added Math Symbols: Delimiters//EN//XML"

       "xml/iso-amsc.ent"

PUBLIC "ISO 8879:1986//ENTITIES Added Math Symbols: Negated Relations//EN//XML"

       "xml/iso-amsn.ent"

PUBLIC "ISO 8879:1986//ENTITIES Added Math Symbols: Ordinary//EN//XML"

       "xml/iso-amso.ent"

PUBLIC "ISO 8879:1986//ENTITIES Added Math Symbols: Relations//EN//XML"

       "xml/iso-amsr.ent"

PUBLIC "ISO 8879:1986//ENTITIES Box and Line Drawing//EN//XML"

       "xml/iso-box.ent"

PUBLIC "ISO 8879:1986//ENTITIES Russian Cyrillic//EN//XML"

       "xml/iso-cyr1.ent"

PUBLIC "ISO 8879:1986//ENTITIES Non-Russian Cyrillic//EN//XML"

       "xml/iso-cyr2.ent"

-- End of ISO entity sets for DocBook XML ............................... --

-- ...................................................................... --

  3.4)在c:\share\entity\目录下,为xml创建目录文件:catalog.xml,内容为:

<?xml version='1.0'?>
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">

<!-- ...................................................................... -->
<!-- ISO entity sets ...................................................... -->

<public publicId="ISO 8879:1986//ENTITIES Diacritical Marks//EN//XML"
        uri="xml/iso-dia.ent"/>

<public publicId="ISO 8879:1986//ENTITIES Numeric and Special Graphic//EN//XML"
        uri="xml/iso-num.ent"/>

<public publicId="ISO 8879:1986//ENTITIES Publishing//EN//XML"
        uri="xml/iso-pub.ent"/>

<public publicId="ISO 8879:1986//ENTITIES General Technical//EN//XML"
        uri="xml/iso-tech.ent"/>

<public publicId="ISO 8879:1986//ENTITIES Added Latin 1//EN//XML"
        uri="xml/iso-lat1.ent"/>

<public publicId="ISO 8879:1986//ENTITIES Added Latin 2//EN//XML"
        uri="xml/iso-lat2.ent"/>

<public publicId="ISO 8879:1986//ENTITIES Greek Letters//EN//XML"
        uri="xml/iso-grk1.ent"/>

<public publicId="ISO 8879:1986//ENTITIES Monotoniko Greek//EN//XML"
        uri="xml/iso-grk2.ent"/>

<public publicId="ISO 8879:1986//ENTITIES Greek Symbols//EN//XML"
        uri="xml/iso-grk3.ent"/>

<public publicId="ISO 8879:1986//ENTITIES Alternative Greek Symbols//EN//XML"
        uri="xml/iso-grk4.ent"/>

<public publicId="ISO 8879:1986//ENTITIES Added Math Symbols: Arrow Relations//EN//XML"
        uri="xml/iso-amsa.ent"/>

<public publicId="ISO 8879:1986//ENTITIES Added Math Symbols: Binary Operators//EN//XML"
        uri="xml/iso-amsb.ent"/>

<public publicId="ISO 8879:1986//ENTITIES Added Math Symbols: Delimiters//EN//XML"
        uri="xml/iso-amsc.ent"/>

<public publicId="ISO 8879:1986//ENTITIES Added Math Symbols: Negated Relations//EN//XML"
        uri="xml/iso-amsn.ent"/>

<public publicId="ISO 8879:1986//ENTITIES Added Math Symbols: Ordinary//EN//XML"
        uri="xml/iso-amso.ent"/>

<public publicId="ISO 8879:1986//ENTITIES Added Math Symbols: Relations//EN//XML"
        uri="xml/iso-amsr.ent"/>

<public publicId="ISO 8879:1986//ENTITIES Box and Line Drawing//EN//XML"
        uri="xml/iso-box.ent"/>

<public publicId="ISO 8879:1986//ENTITIES Russian Cyrillic//EN//XML"
        uri="xml/iso-cyr1.ent"/>

<public publicId="ISO 8879:1986//ENTITIES Non-Russian Cyrillic//EN//XML"
        uri="xml/iso-cyr2.ent"/>
</catalog>

4) 安装SGML的DSSSL样表

   DTD定义了DocBook的元素, 描述了DocBook文档的结构, 但是DTD并没有包含一点点文档格式化的信息,

   无论如何,文档的漂亮的表现形式——格式, 都是非常重要的. 这些就依靠样表来解决了. SGML的样表是DSSSL

   4.1) 可以从以下地址下载DSSS样表,笔者下载的版本为:docbook-dsssl-1.79.zip

           http://sourceforge.net/projects/docbook/

   4.2) 在c:\share根目录下创建子目录: c:\share\style\dsssl , 将docbook-dsssl-1.79.zip解压到该目录.

   4.3) 修改 c:\share\style\dsssl\catalog文件,Unix的路径表达方式修改为Windows的路径表达

         方式(即"/"改为"\"),例如:

    PUBLIC "-//Norman Walsh//DOCUMENT DocBook Print Stylesheet//EN"

    print/docbook.dsl

    修改为:

    PUBLIC "-//Norman Walsh//DOCUMENT DocBook Print Stylesheet//EN"

    print\docbook.dsl

     4.4)   修改  c:\share\style\dsssl\catalog文件,删除以下语句行:

    DTDDECL "-//Norman Walsh//DTD DocBook HTML 1.0//EN"

    dtds/html/dbhtml.dcl

5) 安装XML样表XSL

   5.1) 可以从以下地址下载XML的样表XSL,笔者下载的版本为:docbook-xsl-1.76.1.zip

          http://sourceforge.net/projects/docbook/

   5.2) 在c:\share根目录下创建子目录: c:\share\style\xsl , 将docbook-xsl-1.76.1.zip解压到该目录.

6) 安装LDP扩展

LDP(Linux文档计划)使用DocBook格式撰写文档,并且在 Norman Walsh DSSSL 的基础上进行了

一定的扩充。我们使用 LDP 的DSSSL扩充,一方面使自己撰写的文档具有LDP的统一的风格,另一方

可以学习到定制 DSSSL 的知识。

  6.1)可以从以下地址下载扩展文件ldp.dsl.

         http://www.tldp.org/authors/tools/ldp.dsl

   6.2) 将ldp.dsl拷贝到c:\share\style\dsssl目录下.

  6.3)修改ldp.dsl扩展文件,删除掉以下内容.

<style-sheet>

;; ------------------------------------------------------------------------

;; ldp.dsl - LDP Customized DSSSL Stylesheet

;; v1.12, 2003-03-19

;; Copyright (C) 2000-2003

;;

;; This program is free software; you can redistribute it and/or modify

;; it under the terms of the GNU General Public License as published by

;; the Free Software Foundation; either version 2 of the License, or

;; (at your option) any later version.

;;

;; This program is distributed in the hope that it will be useful,

;; but WITHOUT ANY WARRANTY; without even the implied warranty of

;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the

;; GNU General Public License for more details.

;;

;; You should have received a copy of the GNU General Public License

;; along with this program; if not, write to the Free Software

;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA

;; ------------------------------------------------------------------------


7) 在根木文件c:\share中,建立全局目录文件catalog.xml,内容如下:

<?xml version='1.0'?>

<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">

<!-- ...................................................................... -->

<!-- DocBook driver file .................................................. -->

<nextCatalog  catalog="dtd/4.2/catalog.xml" /> 

<!-- ...................................................................... -->

<!-- ISO entity sets ...................................................... -->

<nextCatalog  catalog="entity/xml/catalog.xml" /> 

<nextCatalog  catalog="style/xsl/catalog.xml" /> 

</catalog>

8) 安装OpenJade

OpenJade 是一个DSSSL语言的实现工具,它可以把SGML和XML文档通过DSSSL转换为其它格式,如转换为 RTF、

TeX、HTML等格式。OpenJade 源自 James Clark's 的工具 JADE (James' DSSSL Engine),现在作为开放源码,

由Source Forge维护。

  8.1) 从以下地址下载Windows平台的OpenJade安装包openjade-1.3-1.exe

  http://sourceforge.net/projects/openjade/files/openjade/1.3/

   8.2) 安装openjade-1.3-1,例如:C:\Program Files\OpenJade-1.3\ 。

      需要将C:\Program Files\OpenJade-1.3\bin 添加到系统PATH变量中,以便可以在Windows命令行直接调用openjade

9)导入openjade自带的DTD到c:\share\dtd目录。

   将OpenJade自带的c:\Program Files\OpenJade-1.3\dsssl,加入到c:\share\dtd目录中,重命名为openjade

10) 在根目录文件c:\share中,建立全局目录文件catalog.sgml,内容如下:

OVERRIDE YES

SGMLDECL "dtd\4.2\docbook.dcl"

CATALOG "dtd\4.2\docbook.cat"

CATALOG "entity\catalog.sgml"

CATALOG "style\dsssl\catalog"

CATALOG "dtd\openjade\catalog"

DOCTYPE book dtd\4.2\docbook.dtd

DOCTYPE article dtd\4.2\docbook.dtd

DOCTYPE chapter dtd\4.2\docbook.dtd

 11.配置环境变量

SGML/XML的应用程序需要通过环境变量SGML_CATALOG_FILES和XML_CATALOG_FILES来确认目录文件的位置,

进而找到相应的DTD等文件.Windows通过控制面板中的系统来设置环境变量,

设置 SGML_CATALOG_FILES 为 C:\share\catalog.sgml

设置 XML_CATALOG_FILES 为 C:\share\catalog.xml

------------------------------------------------------------------------------------------------

你可能感兴趣的:(在Windows环境下搭建Docbook编译环境)