| Navigation:First_Community->Computer->Introduction | Goto:New Topic•Setting•Search | |
Copyright © 2004 本文遵从GNU 的自由文档许可证(Free Document License)的条款,欢迎转载、修改、散布。
发布时间:2004年7月7日
更新时间:2005年07月18日
Abstract
CopyRight owned by the original author.--(www.MegaEntry.com)
介绍DocBook在linux系统和windows系统下的安装和使用。本文档还在不断整理完善中,如有错漏请网友多多指正,谢谢。MegaEntry - Social networking and discussion site!
为DocBook在windows系统中起一个根目录,盘符可自定。但为了减少配置文件的修改,尽量保持这个配置。CopyRight owned by the original author.--(www.MegaEntry.com)
放置有关docbook的格式文件。MegaEntry - Social networking and discussion site!
SET SGML_CATALOG_FILES=.\catalog;C:\unix\etc\sgml\catalogCopyRight owned by the original author.--(www.MegaEntry.com)
ISO发布的特殊字符模块。Example 2.1. check.gsm
MegaEntry - Social networking and discussion site!
<!ELEMENT HTMLLite O O (H1|P)* > <!ELEMENT (H1|P) - - (#PCDATA|EM|STRONG)* > <!ELEMENT (EM|STRONG) - - (#PCDATA) >]><HTMLLite><H1>SGML 解释器测试文件</H1>MegaEntry - Social networking and discussion site!
<P>这是一个简短的,合乎 SGML 语言规格定义的文件,用于测试你的解释环境是否配置正确。</P><P>本文件采用 GPL 版权发布,欢迎转载、改写、散播。</P></HTMLLite>CopyRight owned by the original author.--(www.MegaEntry.com)
这是openjade命令的最终工作了。我们要把上面的sgml文件通过openjade这个程序转换成rtf文件。怎么做呢?我们需要一个格式转换的样式表,现在我们就来制作一个check.dsl的样式表,以转换check.gsm文件。内容如下:Example 2.2. check.dsl
MegaEntry - Social networking and discussion site!
(element HTMLlite (make simple-page-sequence)) (element H1 (make paragraph font-family-name: "Times New Roman" font-weight: 'bold font-size: 20ptCopyRight owned by the original author.--(www.MegaEntry.com)
line-spacing: 22pt space-before: 15pt space-after: 10pt start-indent: 6pt first-line-start-indent: -6pt quadding: 'centerCopyRight owned by the original author.--(www.MegaEntry.com)
keep-with-next?: #t)) (element P (make paragraph font-family-name: "Times New Roman" font-size: 12pt line-spacing: 13.2ptCopyRight owned by the original author.--(www.MegaEntry.com)
space-before: 6pt start-indent: 6pt quadding: 'start)) (element EM (make sequence font-posture: 'italic))CopyRight owned by the original author.--(www.MegaEntry.com)
(element STRONG (make sequence font-weight: 'bold)) </style-specification-body> </style-specification></style-sheet>CopyRight owned by the original author.--(www.MegaEntry.com)
Example 2.3. ISO 特殊字符catalog文档
MegaEntry - Social networking and discussion site!
-- ...................................................................... -- -- ISO entity sets ...................................................... --PUBLIC "ISO 8879:1986//ENTITIES Diacritical Marks//EN" "ISOdia"PUBLIC "ISO 8879:1986//ENTITIES Numeric and Special Graphic//EN" "ISOnum"CopyRight owned by the original author.--(www.MegaEntry.com)
PUBLIC "ISO 8879:1986//ENTITIES Publishing//EN" "ISOpub"PUBLIC "ISO 8879:1986//ENTITIES General Technical//EN" "ISOtech"PUBLIC "ISO 8879:1986//ENTITIES Added Latin 1//EN" "ISOlat1"PUBLIC "ISO 8879:1986//ENTITIES Added Latin 2//EN" "ISOlat2"PUBLIC "ISO 8879:1986//ENTITIES Greek Letters//EN" "ISOgrk1"PUBLIC "ISO 8879:1986//ENTITIES Monotoniko Greek//EN" "ISOgrk2"CopyRight owned by the original author.--(www.MegaEntry.com)
PUBLIC "ISO 8879:1986//ENTITIES Greek Symbols//EN" "ISOgrk3"PUBLIC "ISO 8879:1986//ENTITIES Alternative Greek Symbols//EN" "ISOgrk4"PUBLIC "ISO 8879:1986//ENTITIES Added Math Symbols: Arrow Relations//EN" "ISOamsa"PUBLIC "ISO 8879:1986//ENTITIES Added Math Symbols: Binary Operators//EN" "ISOamsb"PUBLIC "ISO 8879:1986//ENTITIES Added Math Symbols: Delimiters//EN" "ISOamsc"PUBLIC "ISO 8879:1986//ENTITIES Added Math Symbols: Negated Relations//EN" "ISOamsn"MegaEntry - Social networking and discussion site!
PUBLIC "ISO 8879:1986//ENTITIES Added Math Symbols: Ordinary//EN" "ISOamso"PUBLIC "ISO 8879:1986//ENTITIES Added Math Symbols: Relations//EN" "ISOamsr"PUBLIC "ISO 8879:1986//ENTITIES Box and Line Drawing//EN" "ISObox"PUBLIC "ISO 8879:1986//ENTITIES Russian Cyrillic//EN" "ISOcyr1"PUBLIC "ISO 8879:1986//ENTITIES Non-Russian Cyrillic//EN" "ISOcyr2"MegaEntry - Social networking and discussion site!
-- ...................................................................... --Example 2.4. catalog
MegaEntry - Social networking and discussion site!
-- filename: catalog ---- file function : Under this system,all DTD version catalog file --CATALOG "c:/unix/usr/share/sgml/isoent/catalog" -- ISO external ENTITY declare file --CATALOG "c:/unix/usr/share/sgml/jade-dsssl/catalog" -- openjade dsssl module --CATALOG "c:/unix/usr/share/sgml/docbook/docbook-dsssl-1.78/catalog" -- DocBook out put stylesheet --MegaEntry - Social networking and discussion site!
CATALOG "c:/unix/usr/share/sgml/docbook/sgml-dtd-42/catalog" -- DocBook SGML version DTD module --CATALOG "c:/unix/usr/share/sgml/docbook/sgml-dtd-41/catalog" -- DocBook SGML version DTD module --CATALOG "c:/unix/usr/share/sgml/docbook/sgml-dtd-40/catalog" -- DocBook SGML version DTD module --CATALOG "c:/unix/usr/share/sgml/docbook/sgml-dtd-31/catalog" -- DocBook SGML version DTD module --CATALOG "c:/unix/usr/share/sgml/docbook/xml-dtd-41/catalog" -- DocBook XML version DTD module --CATALOG "c:/unix/usr/share/sgml/docbook/xml-dtd-412/catalog" -- DocBook XML version DTD module --CopyRight owned by the original author.--(www.MegaEntry.com)
CATALOG "c:/unix/usr/share/sgml/docbook/xml-dtd-42/catalog" -- DocBook XML version DTD module --![]() |
|
| 上面的catalog文档中还包含有41,31等版本的配置,如按本文的配置是可以不要的,所以实际应用时可根据自已的需要进行调整。 | |
Example 2.5. mybook.sgm
MegaEntry - Social networking and discussion site!
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook V4.2//EN"><book> <bookinfo> <title>An Example Book</title>MegaEntry - Social networking and discussion site!
<author> <firstname>Your first name</firstname> <surname>Your surname</surname> <affiliation> <address><email>foo@example.com</email></address> </affiliation>CopyRight owned by the original author.--(www.MegaEntry.com)
</author> <copyright> <year>2000</year> <holder>Copyright string here</holder> </copyright>MegaEntry - Social networking and discussion site!
<abstract> <para>If your book has an abstract then it should go here.</para> </abstract>MegaEntry - Social networking and discussion site!
openjade -t sgml -d C:\unix\usr\share\sgml\docbook\docbook-dsssl-1.78\html\docbook.dsl mybook.sgm![]() |
|
| 用本机的DT<!DOCTYPE book SYSTEM "C:\unix\usr\share\sgml\docbook\xml-dtd-42\docbookx.dtd">可以加快编译的速度和不用依赖网络。 | |
CopyRight owned by the original author.--(www.MegaEntry.com)
iconv-1.9.1.win32.zip-----语言转换工具。Example 2.6. xml测试文件check.xml
CopyRight owned by the original author.--(www.MegaEntry.com)
<!DOCTYPE HTMLLite [ <!ELEMENT HTMLLite O O (H1|P)* > <!ELEMENT (H1|P) - - (#PCDATA|EM|STRONG)* > <!ELEMENT (EM|STRONG) - - (#PCDATA) >]><HTMLLite>CopyRight owned by the original author.--(www.MegaEntry.com)
<H1>SGML 解释器测试文件</H1><P>这是一个简短的,合乎 xml 语言规格定义的文件,用于测试你的解释环境是否配置正确。</P><P>本文件采用 GPL 版权发布,欢迎转载、改写、散播。</P></HTMLLite>Example 2.7. xsl格式转换文件check.xsl
CopyRight owned by the original author.--(www.MegaEntry.com)
<?xml version="1.0" encoding="gb2312"?><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="html"/> <xsl:template match="/"> <html>MegaEntry - Social networking and discussion site!
<head> <title>HTMLlite document</title> </head> <body bgcolor="#FFFFFF"> <xsl:apply-templates/> </body>MegaEntry - Social networking and discussion site!
</html> </xsl:template> <xsl:template match="H1"> <h1> <xsl:apply-templates/> </h1>CopyRight owned by the original author.--(www.MegaEntry.com)
</xsl:template> <xsl:template match="P"> <p> <xsl:apply-templates/> </p> </xsl:template>MegaEntry - Social networking and discussion site!
<xsl:template match="EM"> <i> <xsl:apply-templates/> </i> </xsl:template> <xsl:template match="STRONG">CopyRight owned by the original author.--(www.MegaEntry.com)
<b> <xsl:apply-templates/> </b> </xsl:template></xsl:stylesheet>Example 2.8. mybook.xml
MegaEntry - Social networking and discussion site!
<?xml version="1.0" encoding="gb2312"?><!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" ><book>MegaEntry - Social networking and discussion site!
<bookinfo> <title>An Example Book</title> <author> <firstname>Your first name</firstname> <surname>Your surname</surname> <affiliation>CopyRight owned by the original author.--(www.MegaEntry.com)
<address><email>foo@example.com</email></address> </affiliation> </author> <copyright> <year>2000</year>CopyRight owned by the original author.--(www.MegaEntry.com)
<holder>Copyright string here</holder> </copyright> <abstract> <para>If your book has an abstract then it should go here.</para> </abstract>MegaEntry - Social networking and discussion site!
</bookinfo> <preface> <title>Preface</title> <para>Your book may have a preface, in which case it should be placedMegaEntry - Social networking and discussion site!
here.</para> </preface> <chapter> <title>My first chapter</title>CopyRight owned by the original author.--(www.MegaEntry.com)
<para>This is the first chapter in my book.</para> <sect1 id="1.1"> <title>My first section</title> <para>This is the first section in my book.</para>MegaEntry - Social networking and discussion site!
</sect1> <sect1 id="1.2"> <title>my second section</title> <para> this is the second section in my book.</para> </sect1> </chapter>CopyRight owned by the original author.--(www.MegaEntry.com)
</book><xsl:output method="html"
encoding="utf-8"
indent="no"/>
CopyRight owned by the original author.--(www.MegaEntry.com)
默认HTML格式输出文件中的章内小节是没有自动编号功能的,如果要实现小节自动编号需要设置HTML格式的两个转换参数。$ xsltproc --stringparam section.autolabel 1 \
--stringparam section.label.includes.component.label 1 \
docbook.xsl myfile.xml>myfile.htm
CopyRight owned by the original author.--(www.MegaEntry.com)
DocBook文档的HTML格式转换样式文件一般位于/usr/share/sgml/docbook/docbook-xsl-1.65.1/html/目录下。通过查看docbook.xsl文件可知,在docbook.xsl中引用param.xsl作为参数设置文件,所有的参数都在这里设置。我们打开param.xsl文件,找到以下两行,再把参数置成1就可以了。<xsl:param name="section.autolabel" select="1"/> <xsl:param name="section.label.includes.component.label" select="1"/>
<html><img tal:replace="structure container/logo"> <h1>
Welcome to <i tal:content="template/title">title</i>, this my zope tutorial,I like zope,I like python too.</h1> <h2>another test page in my zope site is zoo</h2>
<a href = index_html>zoo</a> </html>
CopyRight owned by the original author.--(www.MegaEntry.com)
源码如下:<para> <screen> <html> <co id = "co.1.1" /><img tal:replace="structure container/logo"> <h1> <co id = "co.1.2" />Welcome to <i tal:content="template/title">title</i>, this my zope tutorial,I like zope,I like python too.</h1> <h2>another test page in my zope site is zoo</h2> <co id = "co.1.3" /><a href = index_html>zoo</a> </html> </screen> </para> <calloutlist> <callout arearefs = "co.1.1"> <para>显示logo图片</para> </callout> <callout arearefs = "co.1.2"> <para>用"template/title"值(zope home page)替换title。</para> </callout> <callout arearefs = "co.1.3"> <para>建立一个到zoo目录的链接。</para> </callout> </calloutlist>上图中的每个小图标是放在images/callouts目录下的1.png、2.png、3.png文件,所以图标也可以自已设计。
Note
为方便起见,sys模块包含一个maxint成员,该成员保留了整形变量的最大正数值。
我们也可用图标来标注。如:
![]() |
|
| 为方便起见,sys模块包含一个maxint成员,该成员保留了整形变量的最大正数值。 | |
MegaEntry - Social networking and discussion site!
首先,我们需修改docbook的编译参数,位于param.xsl文件内,把以下几项修改成:<xsl:param name="admon.graphics.extension" select="'.png'"/> #设置图标格式 <xsl:param name="admon.graphics" select="1"/> #开启图标显示 <xsl:param name="admon.graphics.path">images/</xsl:param> #图标的路径
<div class="chapter" lang="en">
<div class="titlepage">
<div>
<div>
<h2 class="title">
<a name="Catalogs"></a>Chapter 3. XML catalogs
</h2>
</div>
...
这样,我们就可编写一个样式表,与生成的HTML文件中的class关联起来,从而格式化HTML文件的输出样式。下面是一个样式表的例子(可直接拷贝使用)。/* CSS2 Stylesheet for _DocBook: The Definitive Guide_
* Copyright (C) 1999, 2000, 2001, 2002 O'Reilly & Associates, Inc.
*
* $Id: defguide.css,v 1.1 2002/06/17 12:20:45 nwalsh Exp $
*/
DIV.example-output {
padding-left: 15px;
border-style: solid;
border-width: 0px;
border-left-width: 2px;
border-color: black;
}
pre.screen {
background: #E8E8E8;
}
pre.programlisting {
background: #E8E8E8;
}
div.example-source {
background: #E8E8E8;
}
p.publisher {
text-align: center;
}
body.book {
/* background-image: url(figures/htmltitlepage.gif); */
/* background-repeat: no-repeat; */
/* background-position: top center; */
}
div.component-title {
text-align: right;
}
h1.label {
font-size: 150pt;
font-weight: normal;
margin-bottom: 0px;
padding-bottom: 0px;
margin-top: 0px;
padding-top: 0px;
}
div.component-title h1.title {
margin-top: 0px;
padding-top: 0px;
margin-right: 20px;
font-size: 36pt;
}
p.alpha-version {
margin-top: 0px;
padding-top: 0px;
}
hr.component-separator {
height: 1px;
}
div.refentry div.titlepage {
margin-left: 20px;
}
div.refentry div.titlepage h1.title {
margin-left: -20px;
margin-bottom: 0px;
font-size: 36pt;
}
body {
margin-top: 0px;
padding-top: 0px;
margin-left: 0px;
margin-right: 0px;
padding-left: 0px;
padding-right: 0px;
}
div.navheader {
}
div.navfooter {
}
div.copyrightfooter {
background-color: #c6bec6;
margin-top: 0px;
padding-top: 0px;
padding-left: 10px;
padding-right: 10px;
padding-bottom: 2px;
}
div.copyrightfooter p {
margin-top: 0px;
padding-top: 10px;
}
div.refentry,
div.preface,
div.chapter,
div.appendix,
div.reference,
div.part,
div.bibliography,
div.glossary,
div.index,
div.colophon,
div.legalnotice,
div.sect1 {
margin-left: 10px;
margin-right: 10px;
}
div.book {
margin-left: 10px;
margin-right: 10px;
margin-top: 5px;
}
thead {
background-color: black;
color: white;
}
table,
tbody,thead,tfoot,
tr,td {
border-color: #8F8F8F;
}
div.docbookng-synopsis { border-left: 0.5pt solid black;
margin-left: 0.25in;
padding-left: 0.25in;
border-top: 0.5pt solid black;
margin-top: 0.25in;
border-bottom: 0.5pt solid black;
margin-bottom: 0.25in;
}
div.docbookng-synopsis
div.define-next { border-top: 0.5pt solid black;
margin-top: 0.25in;
padding-top: 0.25in;
}
为了在输出的HTML文件中使用我们自定义的样式表,可使用xsltproc命令的--stringparam参数,如:xsltproc --stringparam html.stylesheet mystylesheet.css docbook.xsl myfile.xml 注:mystylesheet.css为我们定义的样式表,docbook.xsl为转换样式表,myfile.xml为我们的DocBook源文档
CopyRight owned by the original author.--(www.MegaEntry.com)
这样,输出的HTML文件中就会有以下的定义:<link rel="stylesheet" href="mystylesheet.css"
type="text/css">
通过这种方法,我们就可用一个CSS样式表控制整个输出文件的表现形式,而不用修改DocBook的XSL样式表。<itemizedlist>
<listitem>
<para>列表内容</para>
</listitem>
</itemizedlist>
...
MegaEntry - Social networking and discussion site!
带序号的列表表示法:<orderedlist>
<listitem>
<para>列表内容</para>
</listitem>
</orderedlist>
...
<variablelist>
<varlistentry>
<term>列表段标题</term>
<listitem>
<para>列表内容</para>
<listitem>
</varlistentry>
...
</variablelist>