There doesn't seem to be an obvious way (to me) to number sections in output (e.g. 1.0, 1.1, 1.2, etc.). This also doesn't seem to be covered in Leigh White's (fantastic) Dita for Print.--
I found a few dead-ends online that revolved around customizing templates in commons.xsl that don't seem to exist in DITA-OT 2.0. The most promising was this:
<xsl:template match="*" mode="getTitle">
<!-- This doesn't seem to do anything -->
<xsl:variable name="topic" select="ancestor-or-self::*[contains(@class, ' topic/topic ')][1]" />
<xsl:variable name="id" select="$topic/@id" />
<xsl:variable name="mapTopics" select="key('map-id', $id)" />
<fo:inline>
<xsl:for-each select="$mapTopics[1]">
<xsl:choose>
<xsl:when test="parent::opentopic:map" />
<xsl:when test="ancestor-or-self::*[contains(@class, ' bookmap/frontmatter ') or contains(@class, ' bookmap/backmatter ')]" />
<xsl:when test="ancestor-or-self::*[contains(@class, ' bookmap/appendix ')]">
<xsl:number count="*[contains(@class, ' map/topicref ')] [ancestor-or-self::*[contains(@class, ' bookmap/appendix ')]]" format="A.1.1" level="multiple" />
</xsl:when>
<xsl:otherwise>
<xsl:number count="*[contains(@class, ' map/topicref ')] [not(ancestor-or-self::*[contains(@class, ' bookmap/frontmatter ')])]" format="1.1" level="multiple" />
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</fo:inline>
<xsl:text> </xsl:text>
<xsl:apply-templates />
</xsl:template>
This seemed to have no affect in the output, but looks otherwise ok/logical to me.
Has anyone successfully gotten section number in PDFs, and if so how?
You received this message because you are subscribed to the Google Groups "DITA-OT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dita-ot-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
My work requires creation of a PDF using external DITA-OT. But there’s a demand to create the TOC with numbered chapters, topics, and sub-topics (drilling-down to 5 or 6 levels). Attaching the screen for your reference (this is what I need TOC to be like, highlighted in red):
Can you please help and guide me how can I obtain this through DITA-OT?
I tried modifying custom.xsl but it is not yielding results as expected.
Looking forward to your reply.
Best regards,
Anurag Srivastava
<!--title numbering-->
<xsl:variable name="e:number-levels" select="(true(), true(), true(), true())" />
<xsl:template match="*[contains(@class, ' topic/topic ')]/*[contains(@class, ' topic/title ')]" mode="getTitle">
<xsl:variable name="topic" select="ancestor-or-self::*[contains(@class, ' topic/topic ')][1]" />
<xsl:variable name="id" select="$topic/@id" />
<xsl:variable name="mapTopics" select="key('map-id', $id)" />
<fo:inline>
<xsl:for-each select="$mapTopics[1]">
<xsl:variable name="depth" select="count(ancestor-or-self::*[contains(@class, ' map/topicref')])" />
<xsl:choose>
<xsl:when test="parent::opentopic:map and contains(@class, ' bookmap/bookmap ')" />
<xsl:when test="ancestor-or-self::*[contains(@class, ' bookmap/frontmatter ') or
 contains(@class, ' bookmap/backmatter ')]" />
<xsl:when test="ancestor-or-self::*[contains(@class, ' bookmap/appendix ')] and
 $e:number-levels[$depth]">
<xsl:number count="*[contains(@class, ' map/topicref ')]
 [ancestor-or-self::*[contains(@class, ' bookmap/appendix ')]] " format="A.1.1" level="multiple" />
</xsl:when>
<xsl:when test="$e:number-levels[$depth]">
<xsl:number count="*[contains(@class, ' map/topicref ')]
 [not(ancestor-or-self::*[contains(@class, ' bookmap/frontmatter ')])]" format="1.1" level="multiple" />
</xsl:when>
</xsl:choose>
</xsl:for-each>
</fo:inline>
<xsl:value-of select="' '" />
<xsl:apply-templates />
</xsl:template>