论坛首页 Java企业应用论坛

整理在翻译与校对Spring 2.0 Reference时使用DocBook时的技巧与注意点

浏览 4574 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2006-10-11  
整理在翻译与校对Spring 2.0 Reference时使用DocBook时的技巧与注意点

一、XML文件的编辑与校对

翻译校对时,在XML文件头前增加:
<!DOCTYPE chapter SYSTEM "../lib/docbook-dtd/docbookx.dtd">
<?xml-stylesheet type="text/xsl" href="../styles/fopdf.xsl" mce_href="../styles/fopdf.xsl"?>

提交前把这两行删除,以保证XML的合式,并可以实时用浏览器查看最终的结果并进行调整。

二、段落首行缩进两个字符
通常中文文档的段落首行会缩进两个字符。
HTML版本的输出在styles/html.css样式表里面增加样式定义即可,注意build时html.css也要拷贝过去,要不然,无效果,如下:
P
{
	text-indent: 2em;
}

用FOP转换成PDF时可以通过设置param.xsl的参数。
方法是:在<xsl:attribute-set name="normal.para.spacing">中增加属性<xsl:attribute name="text-indent">2em</xsl:attribute>
变成如下即可:
<xsl:attribute-set name="normal.para.spacing">
  <xsl:attribute name="text-indent">2em</xsl:attribute>
  <xsl:attribute name="space-before.optimum">1em</xsl:attribute>
  <xsl:attribute name="space-before.minimum">0.8em</xsl:attribute>
  <xsl:attribute name="space-before.maximum">1.2em</xsl:attribute>
</xsl:attribute-set>

三、编译生成.chm文件
先利用DocBook及xsltproc来生成.hhp和.hhc文件以及所需的.html文件,然后利用hhc.exe来编译即可
命令如下:
C:\OpenDoc\Libxml\bin\xsltproc --output C:\OpenDoc\Spring\Reference\spring2rc2_zh_cn\dist\ C:\OpenDoc\DocBook\htmlhelp\htmlhelp.xsl C:\OpenDoc\Spring\Reference\spring2rc2_zh_cn\src\index.xml

由于要处理中文的问题,需要配置如下参数,下面对DocBook一些配置参数一些说明:
1、chunker.xsl中的
<xsl:param name="chunker.output.method" select="'html'"/><!--  -->
<xsl:param name="chunker.output.encoding" select="'ISO-8859-1'"/><!-- 输出的html中的text/html; charset=值 -->
<xsl:param name="chunker.output.indent" select="'yes'"/><!-- 输出的html会换行 -->
<xsl:param name="chunker.output.omit-xml-declaration" select="'no'"/>
<xsl:param name="chunker.output.standalone" select="'no'"/>
<xsl:param name="chunker.output.doctype-public" select="''"/>
<xsl:param name="chunker.output.doctype-system" select="''"/>
<xsl:param name="chunker.output.media-type" select="''"/>
<xsl:param name="chunker.output.cdata-section-elements" select="''"/>

<xsl:param name="saxon.character.representation" select="'native'"/><!-- 对于非ASCII码,按本地字符形式显示。缺省为entity;decimal,这样会把非ASCII码显示为数字实体的形式。可以用native来显示本地字符形式 -->

2、param.xsl中的
<xsl:param name="html.stylesheet" select="'styles/html.css'"/><!-- 使用css层式表 -->
<xsl:param name="l10n.gentext.language" select="'zh_cn'"/><!-- 生成的网页会使用中文习惯,如使用“目录”不用“Table of Content”,用“下一页”不用“Next”,用“章”不用“Chapter”,用“部分”不用“Part”,等等 --> 
<xsl:param name="htmlhelp.encoding" select="'GBK'"/><!-- 生成.hhp及.hhc的编码,默认为iso-8859-1 -->  

<xsl:param name="l10n.gentext.default.language" select="'en'"/><!--  --> 

<xsl:param name="htmlhelp.chm" select="'Spring_2.0_Reference_zh_CN.chm'"/><!-- 编译生成.chm的文件名 --> 

<xsl:param name="section.autolabel" select="0"/><!--  --> 
<xsl:param name="section.label.includes.component.label" select="0"/><!--  --> 

再用Microsoft HTML Help Workshop工具里的hhc.exe程序里命令行工具,hhw.exe为图形化操作界面,大家可能都比较熟悉了。
利用它们都可以进行编译chm文件。hhc.exe命令格式如下:
Usage:   hhc <filename>
    where <filename> = an HTML Help project file
Example: hhc myfile.hhp
如:hhc dist\htmlhelp.hhp
这样就可以编译出 Spring_2.0_Reference_zh_CN.chm 文件了,重要的是编辑出来的.chm可以进行中英文的搜索与正常的字符拷贝等。

四、其它继续整理总结中。。。
论坛首页 Java企业应用版

跳转论坛:
Global site tag (gtag.js) - Google Analytics