Changing Headings without Changing ToC

Here should go questions about transforming XML with XSLT and FOP.
Cmarine
Posts: 4

Changing Headings without Changing ToC

Wed May 25, 2016 6:53 pm

Greetings,

I am trying to make some changes to the alignment of my headings in PDF without affecting the ToC. Specifically, I want the heading number to be left aligned, and I want the heading name to be aligned with the body text. For example...

1.2 Making Jam
The art of making jam is....

I am able to achieve this one by altering the following XSL that controls the autonumbering
[Codebox=] <xsl:variable name="e:number-levels" select="(true(), true(), true(), true())" />
<xsl:template match="*" 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 space-end="15pt">
<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:text> </xsl:text>
<xsl:apply-templates />
</xsl:template>[/Codebox]

If I add the "space-end" attribute to the <fo:inline> tag as I have done in the example, I get the separation I am looking for. However, this also affects the ToC output which doesn't look as good.

Any thoughts on how I can affect the one and not the other? Thanks!
radu_pisoi
Posts: 327
Location: Craiova

Re: Changing Headings without Changing ToC

Thu May 26, 2016 10:46 am

Hi,

A solution is to add a parameter (disableNumbering for instance) in your customization template to control if the numbering is computed.

I think the template responsible for computing the titles for TOC is 'getNavTitle' from /DITA-OT/plugins/org.dita.pdf2/xsl/fo/commons.xsl. So, you need to also override this template and modify it to set the 'disableNumbering' to 'false' when it computes the title.
Radu Pisoi
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

Return to “XSLT and FOP”

Who is online

Users browsing this forum: No registered users and 0 guests