我目前正在将带有 xslt 的 .xml 文件转换为 xsl:fo 文件。该文件应为演示文稿。我想要的是每个页面上的侧边栏,其中包含所有标题的列表(由 h1-tag 定义)。我知道了,但是接下来,如果当前页面不包含标题,我想突出显示当前页面或任何前一页上的最新标题。
我将页面序列定义如下:
<fo:page-sequence master-reference="Presentation">
<fo:static-content flow-name="xsl-region-start">
<fo:block color="#fff">
<xsl:call-template name="toc" />
</fo:block>
</fo:static-content>
<fo:flow flow-name="xsl-region-body">
<fo:block>
<xsl:apply-templates/>
</fo:block>
</fo:flow>
</fo:page-sequence>
定义 toc 如下:
<xsl:template match="toc" name="toc">
<fo:block>
<xsl:for-each select="//h1">
<fo:block font-size="18pt" font-weight="bold" margin-top="0.25cm">
<xsl:if test="is this h1-node the current headline?" >
<xsl:attribute name="color">red</xsl:attribute>
</xsl:if>
<fo:basic-link internal-destination="{generate-id(.)}">
<xsl:number format="1. " count="//h1" level="any"/>
<xsl:value-of select="."/>
</fo:basic-link>
</fo:block>
</xsl:for-each>
</fo:block>
</xsl:template>
我曾尝试使用 preciding-sibling::h1 但这在静态内容中不起作用。我也尝试用 fo:marker 解决它,但是 fop 的标记,所以在 xsl 转换之后。换句话说,有没有办法根据页面甚至它所在页面的内容来格式化静态内容中的块?提前致谢!