Skip to content

Commit

Permalink
Add function to get title number
Browse files Browse the repository at this point in the history
  • Loading branch information
jelovirt committed Oct 18, 2024
1 parent f04a396 commit 6df4c04
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
5 changes: 1 addition & 4 deletions src/generator/com/elovirta/pdf/links.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,7 @@
</axsl:template>

<axsl:template match="*[contains(@class, ' topic/topic ')]" mode="retrieveReferenceTitle">
<axsl:variable name="topicref" select="key('map-id', @id)[1]"/>
<axsl:variable name="contents" as="node()*">
<axsl:apply-templates select="$topicref[1]" mode="e:title-number"/>
</axsl:variable>
<axsl:variable name="contents" as="node()*" select="e:get-title-number(.)"/>
<axsl:if test="exists($contents)">
<axsl:copy-of select="$contents"/>
<axsl:text>
Expand Down
16 changes: 8 additions & 8 deletions src/generator/com/elovirta/pdf/topic.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,7 @@

<axsl:template match="*[contains(@class, ' topic/topic ')]/*[contains(@class, ' topic/title ')]" mode="getTitle">
<axsl:variable name="topic" select="ancestor-or-self::*[contains(@class, ' topic/topic ')][1]"/>
<axsl:variable name="id" select="$topic/@id"/>
<axsl:variable name="mapTopics" select="key('map-id', $id)"/>
<axsl:variable name="contents" as="node()*">
<axsl:apply-templates select="$mapTopics[1]" mode="e:title-number"/>
</axsl:variable>
<axsl:variable name="contents" as="node()*" select="e:get-title-number($topic)"/>
<axsl:if test="exists($contents)">
<axsl:copy-of select="$contents"/>
<!-- <fo:leader leader-pattern="space" leader-length="from-nearest-specified-value(font-size)"/>-->
Expand All @@ -50,6 +46,12 @@
<axsl:apply-templates/>
</axsl:template>

<axsl:function name="e:get-title-number" as="node()*">
<axsl:param name="topic" as="element()"/>
<axsl:variable name="topicref" as="element()*" select="key('map-id', $topic/@id, root($topic))"/>
<axsl:apply-templates select="$topicref[1]" mode="e:title-number"/>
</axsl:function>

<axsl:template match="*[contains(@class, ' map/topicref')]" mode="e:title-number">
<axsl:variable name="depth" select="count(ancestor-or-self::*[contains(@class, ' map/topicref')])"/>
<axsl:choose>
Expand Down Expand Up @@ -119,9 +121,7 @@

<axsl:template name="getNavTitle">
<axsl:variable name="topicref" select="key('map-id', @id)[1]"/>
<axsl:variable name="contents" as="node()*">
<axsl:apply-templates select="$topicref[1]" mode="e:title-number"/>
</axsl:variable>
<axsl:variable name="contents" as="node()*" select="e:get-title-number(.)"/>
<axsl:if test="exists($contents)">
<axsl:copy-of select="$contents"/>
<!-- <fo:leader leader-pattern="space" leader-length="from-nearest-specified-value(font-size)"/>-->
Expand Down

0 comments on commit 6df4c04

Please sign in to comment.