我有一个具有以下结构的dita XML。
<bookmap>
<frontmatter><!-- FM content --></frontmatter>
<concept><!-- chapter content --></concept>
<concept><!-- chapter content --></concept>
<concept><!-- chapter content --></concept>
<concept><!-- chapter content --></concept>
<concept><!-- chapter content --></concept>
<concept><!-- chapter content --></concept>
<concept><!-- chapter content --></concept>
<concept><!-- chapter content --></concept>
</bookmap>
我只需要为第一级的首页设置不同的标题,其他页面都是正常的。
我使用dita pdf将静态内容粘贴到第一页
<fo:static-content flow-name="first-body-header">
<fo:block xsl:use-attribute-sets="__body__odd__header">
<xsl:call-template name="getVariable">
<xsl:with-param name="id" select="'Body odd header'"/>
<xsl:with-param name="params">
<!-- <prodname>
<xsl:value-of select="$productName"/>
</prodname>-->
<heading>
<fo:inline xsl:use-attribute-sets="__body__odd__header__heading">
<fo:retrieve-marker retrieve-class-name="current-header"/>
</fo:inline>
</heading>
</xsl:with-param>
</xsl:call-template>
</fo:block>
</fo:static-content>
</xsl:template>
不幸的是,此模板适用于所有 零件。
以前有没有人遇到过这个问题。我希望此标题仅适用于第一级的首页
预先感谢
阿鲁尔
答案 0 :(得分:1)
我不确定dita,但此问题为#8.5 under (Apache's) XSL-FO FAQ,可以通过以下方式(使用资源)解决此问题:
<?xml version="1.0"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<!-- layout master set: -->
<fo:layout-master-set>
<!-- page master for 1st page -->
<!-- define a (e.g.) A4 page-master with extra 20mm header region for the first page -->
<fo:simple-page-master master-name="myFirst"
page-height="297mm" page-width="210mm"
margin-top="20mm" margin-bottom="20mm"
margin-left="25mm" margin-right="25mm">
<fo:region-body margin-top="20mm"/>
<fo:region-before region-name="myHeaderFirst" extent="20mm"/>
<!-- define custom footer with <fo:region-after/> ... -->
</fo:simple-page-master>
<!-- page master for "rest" page (body only) -->
<fo:simple-page-master master-name="myRest"
page-height="297mm" page-width="210mm"
margin-top="20mm" margin-bottom="20mm"
margin-left="25mm" margin-right="25mm">
<!-- define only/same body -->
<fo:region-body/>
</fo:simple-page-master>
<!-- Da page seekwendz masta! ..combining myFirst and myRest ;) -->
<fo:page-sequence-master master-name="myDocument">
<fo:repeatable-page-master-alternatives>
<!-- here comes fo magic: "page-position" in (first|last|rest|any|only)
..with precedence! -->
<fo:conditional-page-master-reference page-position="first"
master-reference="myFirst"/>
<fo:conditional-page-master-reference page-position="rest"
master-reference="myRest"/>
</fo:repeatable-page-master-alternatives>
</fo:page-sequence-master>
</fo:layout-master-set>
<!-- here go the contents/page sequences ... -->
<fo:page-sequence master-reference="myDocument">
<!-- static content BEFORE flow! (a small pitfall,
esp. when it is the footer not the header:)) -->
<fo:static-content flow-name="myHeaderFirst">
TODO : "print" your header for first page here.
</fo:static-content>
<!-- define other/more static-contents ... -->
<fo:flow flow-name="xsl-region-body">
TODO : "print" flow/body.
<!-- xsl:applyTemplates /-->
</fo:flow>
</fo:page-sequence>
</fo:root>
https://xmlgraphics.apache.org/fop(apache的fo-impl主页)
https://www.data2type.de/en/xml-xslt-xslfo/xsl-fo/(非常详尽的xsl-fo英文和德文版文档)