Skip to content

Commit

Permalink
Add support for appendix toc entry
Browse files Browse the repository at this point in the history
  • Loading branch information
jelovirt committed Oct 30, 2024
1 parent 9ec24e3 commit 7f46ab1
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 2 deletions.
84 changes: 84 additions & 0 deletions src/generator/com/elovirta/pdf/commons.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,90 @@
</fo:block>
</axsl:template>

<!-- Appendix -->

<axsl:template match="*" mode="processTopicAppendixInsideFlow">
<fo:block axsl:use-attribute-sets="topic">
<!-- TODO: Replace with mode="commonattributes" -->
<axsl:call-template name="commonattributes"/>
<axsl:variable name="level" as="xs:integer">
<axsl:apply-templates select="." mode="get-topic-level"/>
</axsl:variable>
<axsl:if test="$level eq 1">
<fo:marker marker-class-name="current-topic-number">
<axsl:variable name="topicref"
select="key('map-id', ancestor-or-self::*[contains(@class, ' topic/topic ')][1]/@id)[1]"
as="element()?"/>
<axsl:for-each select="$topicref">
<axsl:apply-templates select="." mode="topicTitleNumber"/>
</axsl:for-each>
</fo:marker>
<axsl:apply-templates select="." mode="insertTopicHeaderMarker"/>
</axsl:if>
<axsl:apply-templates select="." mode="customTopicMarker"/>

<axsl:apply-templates select="*[contains(@class,' topic/prolog ')]"/>

<!-- <axsl:apply-templates select="." mode="insertChapterFirstpageStaticContent">-->
<!-- <axsl:with-param name="type" select="'appendix'"/>-->
<!-- </axsl:apply-templates>-->

<fo:block axsl:use-attribute-sets="topic.title">
<axsl:attribute name="id">
<axsl:call-template name="generate-toc-id"/>
</axsl:attribute>
<!-- <axsl:apply-templates select="." mode="customTopicAnchor"/>-->
<axsl:call-template name="pullPrologIndexTerms"/>
<axsl:apply-templates select="*[contains(@class,' ditaot-d/ditaval-startprop ')]"/>

<axsl:call-template name="getVariable">
<axsl:with-param name="id" select="'Appendix with number'"/>
<axsl:with-param name="params" as="element()*">
<number>
<axsl:sequence select="e:get-title-number(.)"/>
<!-- <axsl:apply-templates select="key('map-id', @id)[1]" mode="topicTitleNumber"/>-->
</number>
</axsl:with-param>
</axsl:call-template>
<axsl:text><xsl:text> </xsl:text></axsl:text>

<axsl:apply-templates select="*[contains(@class,' topic/title ')]" mode="getTitle"/>
</fo:block>

<axsl:if test="*[contains(@class,' topic/shortdesc ') or
contains(@class, ' topic/abstract ')]/node()">
<fo:block axsl:use-attribute-sets="topic__shortdesc">
<axsl:apply-templates select="*[contains(@class,' topic/shortdesc ') or
contains(@class, ' topic/abstract ')]/node()"/>
</fo:block>
</axsl:if>
<axsl:apply-templates select="*[contains(@class,' topic/body ')]"/>
<axsl:apply-templates select="*[contains(@class, ' ditaot-d/ditaval-endprop ')]"/>
<axsl:if test="*[contains(@class,' topic/related-links ')]//
*[contains(@class,' topic/link ')]
[not(@role) or @role != 'child']">
<axsl:apply-templates select="*[contains(@class,' topic/related-links ')]"/>
</axsl:if>

<axsl:choose>
<axsl:when test="$appendixLayout='BASIC'">
<!-- <axsl:apply-templates select="* except(*[contains(@class, ' topic/title ') or contains(@class,' ditaot-d/ditaval-startprop ') or-->
<!-- contains(@class, ' topic/prolog ') or contains(@class, ' topic/topic ')])"/>-->
<!--xsl:apply-templates select="." mode="buildRelationships"/-->
</axsl:when>
<axsl:when test="exists(*[contains(@class, ' topic/topic ')])">
<fo:block axsl:use-attribute-sets="e:appendix_toc">
<axsl:apply-templates select="*[contains(@class, ' topic/topic ')]" mode="part-toc"/>
</fo:block>
<!-- <axsl:apply-templates select="." mode="createMiniToc"/>-->
</axsl:when>
</axsl:choose>

<axsl:apply-templates select="*[contains(@class,' topic/topic ')]"/>
<axsl:call-template name="pullPrologIndexTerms.end-range"/>
</fo:block>
</axsl:template>

<!-- <axsl:template match="*" mode="createPartToc">-->
<!-- Part introduction -->
<!--
Expand Down
10 changes: 8 additions & 2 deletions src/generator/com/elovirta/pdf/toc.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,11 @@
<axsl:param name="tocItemContent"/>
<axsl:param name="currentNode"/>
<axsl:for-each select="$currentNode">
<axsl:variable name="topicref" select="key('map-id', @id)"/>
<axsl:variable name="level" select="count(ancestor-or-self::*[contains(@class, ' topic/topic ')])"/>
<axsl:choose>
<xsl:if test="some $key in map:keys($root) satisfies starts-with($key, 'style-toc-part')">
<axsl:when test="$level eq 1">
<axsl:when test="$level eq 1 and $topicref/self::*[contains(@class, ' bookmap/part ')]">
<fo:block axsl:use-attribute-sets="__toc__part__content">
<axsl:copy-of select="$tocItemContent"/>
</fo:block>
Expand All @@ -84,7 +85,7 @@
</axsl:when>
</xsl:if>
<xsl:if test="some $key in map:keys($root) satisfies starts-with($key, 'style-toc-chapter')">
<axsl:when test="$level eq 1 or $level eq 2">
<axsl:when test="$level = (1, 2) and $topicref/self::*[contains(@class, ' bookmap/chapter ')]">
<fo:block axsl:use-attribute-sets="__toc__chapter__content">
<axsl:copy-of select="$tocItemContent"/>
</fo:block>
Expand Down Expand Up @@ -583,6 +584,11 @@
<xsl:with-param name="prefix" select="'style-chapter-toc'"/>
</xsl:call-template>
</axsl:attribute-set>
<axsl:attribute-set name="e:appendix_toc">
<xsl:call-template name="generate-attribute-set">
<xsl:with-param name="prefix" select="'style-chapter-appendix'"/>
</xsl:call-template>
</axsl:attribute-set>
</xsl:if>
</axsl:stylesheet>
</xsl:template>
Expand Down

0 comments on commit 7f46ab1

Please sign in to comment.