您的位置:首页 > 其它

让docbook支持表格行颜色的渲染

2006-07-07 16:26 211 查看
一般我们都习惯对表格的header设置背景色,这样能够获取比较友好的视觉效果。
但是docbook要设置header颜色,则不能简单通过thead的属性来设置的,这一点让人很不爽。

但是可以通过如下方式来设置:

<informaltable >
<tgroup cols="2">
<colspec align="left" colwidth="200"/>
<thead>
<row>
<?dbhtml bgcolor="#EEEEEE" ?><?dbfo bgcolor="#EEEEEE" ?>
<entry align="center" >名称</entry>
<entry align="center" >描述</entry>
</row>
</thead>
</tgroup>
</informaltable>
其中<?dbhtml bgcolor="#EEEEEE" ?>表示在转换为html的时候,表头底色为#EEEEEE。
<?dbfo bgcolor="#EEEEEE" ?>表示在转换为fo文件(为了转换为pdf)的时候,表头底色为#EEEEEE。

但是,在docbook xsl 1.68以前版本,对于 dbfo 是不支持的。那么这时候,就只能够自己手工修改xslt文件的。
大家可以修改 fo目录下的table.xsl文件,对thead的转换,手工增加上颜色,即可。
当然,这样的方式,只能为所有表单设置同样的头颜色了。

如下:

<xsl:template match="thead">
<xsl:variable name="tgroup" select="parent::*"/>
<fo:table-header background-color="#EEEEEE"
font-weight="bold"
border-top-width="0.25pt"
border-top-style="solid"
border-top-color="black"
border-left-width="0.25pt"
border-left-style="solid"
border-left-color="black"
border-right-width="0.25pt"
border-right-style="solid"
border-right-color="black"
border-bottom-width="0.25pt"
border-bottom-style="solid"
border-bottom-color="black"
start-indent="0pt"
end-indent="0pt">
<xsl:apply-templates select="row[1]">
<xsl:with-param name="spans">
<xsl:call-template name="blank.spans">
<xsl:with-param name="cols" select="../@cols"/>
</xsl:call-template>
</xsl:with-param>
</xsl:apply-templates>
</fo:table-header>
</xsl:template>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: