You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

基于Apache XSL-FO实现圣经书籍导向的自动化目录生成技术问询

Fixing & Enhancing Your Biblical TOC XSLT

Hey there! Let's get your automated biblical table of contents sorted out—manual work is never fun, especially with something that needs precision like this. First, I spotted a couple of simple typos in your existing code that are probably blocking progress, then we can adjust the structure to group entries by biblical book as you need.

First: Fix the Typos

You've got a couple of misspellings of select as selcet—those will break your templates right away. Let's correct those first:

  • In the <xsl:for-each> inside the Kapitel template, change selcet="Abschnitt" to select="Abschnitt"
  • In the IVZ-Eintrag template, change selcet="Titel" to select="Titel"

Second: Add Biblical Book Grouping

Assuming your XML structure has a parent element for each biblical book (let's say <Buch> for example—adjust the node name if yours is different like <Book>), here's how to restructure the XSLT to group your TOC by book:

<!-- Match each biblical book to create a top-level TOC section -->
<xsl:template match="Buch">
  <fo:block font-size="14pt" font-weight="bold" margin-top="1em">
    <xsl:value-of select="Titel"/>
  </fo:block>
  <!-- Apply templates for chapters under this book -->
  <xsl:apply-templates select="Kapitel"/>
</xsl:template>

<xsl:template match="Kapitel">
  <fo:block margin-left="1em">
    <xsl:apply-templates select="Titel" mode="Kap-Titel"/>
  </fo:block>
  <!-- Fixed the typo here: selcet → select -->
  <xsl:for-each select="Abschnitt">
    <xsl:call-template name="IVZ-Eintrag"/>
  </xsl:for-each>
  <xsl:apply-templates/>
</xsl:template>

<xsl:template match="Kapitel/Titel"/>

<!-- Fixed the typo here: selcet → select -->
<xsl:template name="IVZ-Eintrag">
  <fo:block text-align-last="justify" margin-left="2em">
    <xsl:apply-templates select="Titel" mode="IVZ-Titel"/>
    <fo:leader/>
    <fo:page-number-citation ref-id="{generate-id()}"/>
  </fo:block>
</xsl:template>

<xsl:template match="Abschnitt">
  <fo:block id="{generate-id()}">
    <xsl:apply-templates/>
  </fo:block>
</xsl:template>

How This Works

  1. The Buch template creates a bold, larger heading for each biblical book, making your TOC grouped clearly.
  2. We've fixed the two selcet typos so the loops and template applications actually work.
  3. The indentation (margin-left) helps visually distinguish books → chapters → sections in the TOC, making it easier to read.
  4. The generate-id() still correctly links each section to its page number, so the citation works as intended.

If your XML uses a different name for the book element (like <Book> instead of <Buch>), just update the match="Buch" line to match your actual node name.

内容的提问来源于stack exchange,提问作者Andrej90

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.30 05:08:16