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

一般我们都习惯对表格的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>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值