Bookmaps are incorrectly numbered in PDF output, how can I debug this?

susannecm
Posts: 68
Joined: Wed Mar 17, 2010 1:04 pm

Bookmaps are incorrectly numbered in PDF output, how can I debug this?

Post by susannecm » Mon Apr 16, 2018 3:57 pm

Hi,
I am trying to create PDF output with topic numbers, and the PDF bookmarks are still incorrectly numbered if a bookmap contains parts. In this case, the chapters are assigned the number of the previous part:

VII Part Heading
VII Chapter Heading
1.1 Topic Heading
...
VII Another Chapter Heading
2.1 Another Topic Heading

I am using a piece of code from a book on DITA print output:

Code: Select all


<xsl:template name="getChapterPrefix">
<xsl:variable name="topicType">
<xsl:call-template name="determineTopicType"/>
</xsl:variable>
<!-- Looks back up the document tree to find which top-level topic I'm nested in. -->
<xsl:variable name="containingChapter" select="ancestor-or-self::*[contains(@class, ' topic/topic')][position()=last()]"/>
<!-- And get the id of that chapter. I'll need it later. -->
<xsl:variable name="id" select="$containingChapter/@id"/>
<!-- Get the chapters and appendixes from the merged map because, at this point, I don't
know whether the topic I'm in is inside a chapter or an appendix or a part. -->
<xsl:variable name="topicChapters">
<xsl:copy-of select="$map//*[contains(@class, ' bookmap/chapter')]"/>
</xsl:variable>
<xsl:variable name="topicAppendices">
<xsl:copy-of select="$map//*[contains(@class, ' bookmap/appendix')]"/>
</xsl:variable>
<xsl:variable name="topicParts">
<xsl:copy-of select="$map//*[contains(@class, ' bookmap/part')]"/>
</xsl:variable>
<!-- Figure out the chapter number. -->
<xsl:variable name="chapterNumber">
<xsl:choose>
<!-- If there's something in $topicChapters with an id that matches the id of the
context node, then I'm inside a chapter. -->
<xsl:when test="$topicChapters/*[@id = $id]">
<xsl:number format="1" value="count($topicChapters/*[@id =$id]/preceding-sibling::*) + 1"/>
</xsl:when>
<!-- If there's something in $topicAppendices with an id that matches the id of
the context node, then I'm inside an appendix. -->
<xsl:when test="$topicAppendices/*[@id = $id]">
<xsl:number format="A" value="count($topicAppendices/*[@id =$id]/preceding-sibling::*) + 1"/>
</xsl:when>
<!-- If there's something in $topicParts with an id that matches the id of the context node,
then I'm inside a part. -->
<xsl:when test="$topicParts/*[@id = $id]">
<xsl:number format="I" value="count($topicParts/*[@id =$id]/preceding-sibling::*) + 1"/>
</xsl:when>
<xsl:otherwise></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- If $chapterNumber is defined, return it.-->
<xsl:choose>
<xsl:when test="$chapterNumber != ''">
<xsl:value-of select="$chapterNumber"/>
</xsl:when>
</xsl:choose>
</xsl:template>
This line of code could be wrong (because I am not really interested in the top level topic if the chapter is within a part):

Code: Select all


        <!-- Looks back up the document tree to find which top-level topic I'm nested in. -->
<xsl:variable name="containingChapter" select="ancestor-or-self::*[contains(@class, ' topic/topic')][position()=last()]"/>
Is it possible to debug my transformation scenario? My configuration is as follows:
  • external DITA OT 2.5.4
  • customization plugin/custom transtype
  • RenderX XEP
THe oXygen online help contains a topic on how to debig PDF transformation, but seems to assume a fairly different configuration.

Thanks for any felp
Susanne