Skip to content

Commit

Permalink
Support root level grouping topicrefs #2092 #2648
Browse files Browse the repository at this point in the history
Signed-off-by: Robert D Anderson <robander@us.ibm.com>
  • Loading branch information
Robert D Anderson committed May 10, 2017
1 parent 193ac13 commit 2b10b12
Showing 1 changed file with 65 additions and 17 deletions.
82 changes: 65 additions & 17 deletions src/main/plugins/org.dita.pdf2/xsl/fo/root-processing.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,7 @@ See the accompanying LICENSE file for applicable license.
<xsl:call-template name="insertBodyStaticContents"/>
<fo:flow flow-name="xsl-region-body">
<xsl:for-each select="opentopic:map/*[contains(@class, ' map/topicref ')]">
<xsl:for-each select="key('topic-id', @id)">
<xsl:apply-templates select="." mode="processTopic"/>
</xsl:for-each>
<xsl:apply-templates select="." mode="generatePageSequenceFromTopicref"/>
</xsl:for-each>
</fo:flow>
</fo:page-sequence>
Expand All @@ -240,6 +238,19 @@ See the accompanying LICENSE file for applicable license.
<xsl:call-template name="createBackCover"/>
</xsl:template>

<xsl:template match="*[contains(@class,' map/topicref ')]" mode="generatePageSequenceFromTopicref">
<xsl:choose>
<xsl:when test="empty(key('topic-id', @id))">
<xsl:apply-templates select="*[contains(@class, ' map/topicref ')]" mode="generatePageSequenceFromTopicref"/>
</xsl:when>
<xsl:otherwise>
<xsl:for-each select="key('topic-id', @id)">
<xsl:apply-templates select="." mode="processTopic"/>
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

<xsl:template match="*[contains(@class, ' bookmap/bookmap ')]" mode="generatePageSequences" priority="10">
<xsl:call-template name="createFrontMatter"/>
<xsl:choose>
Expand All @@ -265,17 +276,21 @@ See the accompanying LICENSE file for applicable license.
<xsl:apply-templates select="*" mode="generatePageSequences"/>
</xsl:template>
<xsl:template match="*[contains(@class, ' map/topicref ')]" mode="generatePageSequences" priority="0">
<xsl:variable name="referencedTopic" select="key('topic-id', @id)" as="element()*"/>
<xsl:choose>
<xsl:when test="empty($referencedTopic)">
<xsl:apply-templates select="*[contains(@class,' map/topicref ')]" mode="generatePageSequences"/>
</xsl:when>
<xsl:when test="ancestor::*[contains(@class,' bookmap/frontmatter ')]">
<!-- TODO: To fit the pattern, this should be in its own match template. But a general match for frontmatter/*
conflicts with priority of existing rules (e.g., preface); changing priorities would
break customizations. -->
<xsl:for-each select="key('topic-id', @id)">
<xsl:for-each select="$referencedTopic">
<xsl:call-template name="processFrontMatterTopic"/>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<xsl:for-each select="key('topic-id', @id)">
<xsl:for-each select="$referencedTopic">
<xsl:call-template name="processTopicSimple"/>
</xsl:for-each>
</xsl:otherwise>
Expand All @@ -287,26 +302,59 @@ See the accompanying LICENSE file for applicable license.
<xsl:apply-templates select="*" mode="generatePageSequences"/>
</xsl:template>
<xsl:template match="*[contains(@class, ' bookmap/chapter ')]" mode="generatePageSequences">
<xsl:for-each select="key('topic-id', @id)">
<xsl:call-template name="processTopicChapter"/>
</xsl:for-each>
<xsl:variable name="referencedTopic" select="key('topic-id', @id)" as="element()*"/>
<xsl:choose>
<xsl:when test="empty($referencedTopic)">
<xsl:apply-templates select="*[contains(@class,' map/topicref ')]" mode="generatePageSequences"/>
</xsl:when>
<xsl:otherwise>
<xsl:for-each select="$referencedTopic">
<xsl:call-template name="processTopicChapter"/>
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="*[contains(@class, ' bookmap/appendix ')]" mode="generatePageSequences">
<xsl:for-each select="key('topic-id', @id)">
<xsl:call-template name="processTopicAppendix"/>
</xsl:for-each>
<xsl:variable name="referencedTopic" select="key('topic-id', @id)" as="element()*"/>
<xsl:choose>
<xsl:when test="empty($referencedTopic)">
<xsl:apply-templates select="*[contains(@class,' map/topicref ')]" mode="generatePageSequences"/>
</xsl:when>
<xsl:otherwise>
<xsl:for-each select="$referencedTopic">
<xsl:call-template name="processTopicAppendix"/>
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="*[contains(@class, ' bookmap/preface ')]" mode="generatePageSequences">
<xsl:for-each select="key('topic-id', @id)">
<xsl:call-template name="processTopicPreface"/>
</xsl:for-each>
<xsl:variable name="referencedTopic" select="key('topic-id', @id)" as="element()*"/>
<xsl:choose>
<xsl:when test="empty($referencedTopic)">
<xsl:apply-templates select="*[contains(@class,' map/topicref ')]" mode="generatePageSequences"/>
</xsl:when>
<xsl:otherwise>
<xsl:for-each select="$referencedTopic">
<xsl:call-template name="processTopicPreface"/>
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="*[contains(@class, ' bookmap/appendices ')]" mode="generatePageSequences">
<xsl:for-each select="key('topic-id', @id)">
<xsl:call-template name="processTopicAppendices"/>
</xsl:for-each>
<xsl:variable name="referencedTopic" select="key('topic-id', @id)" as="element()*"/>
<xsl:choose>
<xsl:when test="empty($referencedTopic)">
<xsl:apply-templates select="*[contains(@class, ' bookmap/appendix ')]" mode="generatePageSequences"/>
</xsl:when>
<xsl:otherwise>
<xsl:for-each select="$referencedTopic">
<xsl:call-template name="processTopicAppendices"/>
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="*[contains(@class, ' bookmap/part ')]" mode="generatePageSequences">
<!-- Merge process generates placeholder for <part> with no title, no topic -->
<xsl:for-each select="key('topic-id', @id)">
<xsl:call-template name="processTopicPart"/>
</xsl:for-each>
Expand Down

0 comments on commit 2b10b12

Please sign in to comment.