使用xsltproc将它发布为Html
xsltproc /usr/share/xml/docbook/xsl-stylesheets-1.73.2/html/
html.xsl
docbook.xml
这是最简单的发布。有的时候,我们需要进行一些控制,例如使用CSS、设定输出目录等,可以在命令中加入参数:
xsltproc --output ../html/\ --stringparam html.stylesheet docbook.css
\ /usr/share/xml/docbook/xsl-stylesheets-1.73.2/html/html.xsl
\ docbook.xml
这个命令有点长,我们可以把相关参数写入参数样式表param.xsl
,使用命令xsltproc param.xsl docbook.xml发布
下面是一个参数样式表的例子,复制保存:
<?xml version='1.0'?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <!--调用样式表--> <xsl:import href="/usr/share/xml/docbook/xsl-stylesheets-1.73.2/html/chunk.xsl"/> <xsl:param name="chunker.output.encoding" select="'utf-8'"/> <!--标准信息所使用的语言--> <xsl:param name="l10n.gentext.language" select="'zh_cn'"/> <!--指定样式表--> <xsl:param name="html.stylesheet" select="'docbook.css'"/> <!--对于警告类信息是否使用图形 0 1--> <xsl:param name="admon.graphics" select="1"/> <!--生成的HTML文件存放的起始目录--> <!--如果没有在Makefile或命令中指定,取消这里的注释 <xsl:param name="base.dir" select="'../html/'"/> --> <!--生成的HTML文件内容是否进行缩排 yes no--> <xsl:param name="chunker.output.indent" select="'yes'"/> <!--给节编号 0 1--> <xsl:param name="section.autolabel" select="0"/> <!--节的编号是否包含章的编号 0 1--> <xsl:param name="section.label.includes.component.label" select="1"/> <!--表格边框的属性是否使用预设CSS来指定--> <xsl:param name="table.borders.with.css" select="0"/> <!--参考书目是否进行编号--> <xsl:param name="bibliography.numbered" select="1"></xsl:param> <!--目录深度--> <xsl:param name="toc.max.depth" select="2"/> <!--sect#页面上显示目录--> <xsl:param name="generate.section.toc.level" select="0"/> <!--sect#可以生成目录条目--> <xsl:param name="toc.section.depth" select="2"/> <xsl:param name="generate.toc"> appendix toc article/appendix nop article toc,title book toc,title chapter toc,title part toc,title preface toc,title qandadiv toc qandaset toc reference toc,title sect1 toc sect2 toc sect3 toc sect4 toc sect5 toc section toc set toc,title </xsl:param> <!--在源码中插入 <?linebreak?> 标记,生成Html时替换为<br> --> <xsl:template match="processing-instruction('linebreak')"> <br/> </xsl:template> </xsl:stylesheet>
将偷懒进行到底,使用下面Makefile
,在工作目录下键入make就可以了[8]
OBJECT = all SOURCE = docbook.xml PARAM = param.xsl ARG = --output html/ COMPILER = xsltproc $(OBJECT):$(SOURCE) $(PARAM)$(COMPILER) $(ARG) $(PARAM) $(SOURCE) clean:
rm -rf ../html/*.html