【背景】
之前看到:
http://velocity.apache.org/docbook/DocBook-Framework-1.0.pdf
中的pdf有页眉和页脚:
所以,想要也去给自己的pdf,以及html,去添加页眉和页脚。
其中我目前的pdf是这样的:
【折腾过程】
1.参考:
和官网的:
pdf的:
和html的:
去试试,
结果是:
最终是用:
E:\Dev_Root\docbook\dev\config\docbook-xsl-ns-1.78.1\fo\docbook_crl.xsl
中加上:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | <!--============================================================================ header setting =============================================================================--> <!-- E:\Dev_Root\docbook\tools\docbook-xsl-ns-1.78.1\fo\pagesetup.xsl --> < xsl:template name = "footer.content" > < xsl:param name = "pageclass" select = "''" /> < xsl:param name = "sequence" select = "''" /> < xsl:param name = "position" select = "''" /> < xsl:param name = "gentext-key" select = "''" /> <!-- <fo:block> <xsl:value-of select="$pageclass"/> <xsl:text>, </xsl:text> <xsl:value-of select="$sequence"/> <xsl:text>, </xsl:text> <xsl:value-of select="$position"/> <xsl:text>, </xsl:text> <xsl:value-of select="$gentext-key"/> </fo:block> --> < fo:block > <!-- pageclass can be front, body, back --> <!-- sequence can be odd, even, first, blank --> <!-- position can be left, center, right --> < xsl:choose > < xsl:when test = "$pageclass = 'titlepage'" > <!-- nop; no footer on title pages --> </ xsl:when > < xsl:when test="$double.sided != 0 and $ sequence = 'even' and $ position = 'left' "> < fo:page-number /> </ xsl:when > < xsl:when test="$double.sided != 0 and ($ sequence = 'odd' or $ sequence = 'first' ) and $ position = 'right' "> < fo:page-number /> </ xsl:when > < xsl:when test = "$double.sided = 0 and $position='right'" > < fo:page-number /> </ xsl:when > < xsl:when test = "$position='center'" > < xsl:value-of select = "/book/info/title" /> </ xsl:when > < xsl:when test = "$sequence='blank'" > < xsl:choose > < xsl:when test = "$double.sided != 0 and $position = 'left'" > < fo:page-number /> </ xsl:when > < xsl:when test = "$double.sided = 0 and $position = 'center'" > < fo:page-number /> </ xsl:when > < xsl:otherwise > <!-- nop --> </ xsl:otherwise > </ xsl:choose > </ xsl:when > < xsl:otherwise > <!-- nop --> </ xsl:otherwise > </ xsl:choose > </ fo:block > </ xsl:template > |
只实现了:
让footnote部分,页号在右下角显示的。
目前的问题:
试过如下这些:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | < xsl:when test = "$position='center'" > < xsl:value-of select = "ancestor-or-self::book/bookinfo/title" /> </ xsl:when > < xsl:when test = "$position='center'" > < xsl:value-of select = "ancestor-or-self::book/info/title" /> </ xsl:when > < xsl:when test = "$position='center'" > < xsl:value-of select = "ancestor-or-self::info/title" /> </ xsl:when > < xsl:when test = "$position='center'" > < xsl:value-of select = "ancestor-or-self::/book/info/title" /> </ xsl:when > < xsl:when test = "$position='center'" > < xsl:value-of select = "/book/info/title" /> </ xsl:when > |
都还是无法获得想要的book的title。
而对应的docbook的book的xml中,是正常的:
1 2 3 4 5 6 7 8 9 10 | < book version = "5.0" xml:lang = "zh_CN" > < info > < title >Docbook开发手记</ title > < subtitle ></ subtitle > |
但是就是无法获得。
感觉像是:
所谓的runtime的header和footer,是无法获得这些内容的。
但是,还是很奇怪,因为要是之前示例代码中的:
1 2 3 4 | < xsl:when test = "$sequence = 'first' and $position = 'center'" > < xsl:value-of select = "ancestor-or-self::book/bookinfo/corpauthor" /> 8 </ xsl:when > |
那么按理来说,我这里的:
book/info/title
就也该可以的才对。
注:
对于select的用法,已经参考了:
了,确保写法是正确无误的。
2.最终,目前的效果如下:
即:
footer部分的,页号在右边;
但是footer中间部分,想要显示book的info的title,暂时未成功;
header的中间,还是保留之前的chapter的title。
暂时所用配置如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | <!--============================================================================ header setting =============================================================================--> <!-- E:\Dev_Root\docbook\tools\docbook-xsl-ns-1.78.1\fo\pagesetup.xsl --> < xsl:template name = "footer.content" > < xsl:param name = "pageclass" select = "''" /> < xsl:param name = "sequence" select = "''" /> < xsl:param name = "position" select = "''" /> < xsl:param name = "gentext-key" select = "''" /> <!-- <fo:block> <xsl:value-of select="$pageclass"/> <xsl:text>, </xsl:text> <xsl:value-of select="$sequence"/> <xsl:text>, </xsl:text> <xsl:value-of select="$position"/> <xsl:text>, </xsl:text> <xsl:value-of select="$gentext-key"/> </fo:block> --> < fo:block > <!-- pageclass can be front, body, back --> <!-- sequence can be odd, even, first, blank --> <!-- position can be left, center, right --> < xsl:choose > < xsl:when test = "$pageclass = 'titlepage'" > <!-- nop; no footer on title pages --> </ xsl:when > < xsl:when test="$double.sided != 0 and $ sequence = 'even' and $ position = 'left' "> < fo:page-number /> </ xsl:when > < xsl:when test="$double.sided != 0 and ($ sequence = 'odd' or $ sequence = 'first' ) and $ position = 'right' "> < fo:page-number /> </ xsl:when > < xsl:when test = "$double.sided = 0 and $position='right'" > < fo:page-number /> </ xsl:when > < xsl:when test = "$double.sided = 0 and $position='center'" > < xsl:value-of select = "ancestor-or-self::book/info/title" /> </ xsl:when > < xsl:when test = "$sequence='blank'" > < xsl:choose > < xsl:when test = "$double.sided != 0 and $position = 'left'" > < fo:page-number /> </ xsl:when > < xsl:when test = "$double.sided = 0 and $position = 'center'" > < fo:page-number /> </ xsl:when > < xsl:otherwise > <!-- nop --> </ xsl:otherwise > </ xsl:choose > </ xsl:when > < xsl:otherwise > <!-- nop --> </ xsl:otherwise > </ xsl:choose > </ fo:block > </ xsl:template > |
另外,html的footer和header,暂时懒得去弄了。
有空再弄。
【总结】
还是没有完全搞懂啊。。。
转载请注明:在路上 » 【记录】docbook为html,pdf添加页眉和页脚