Changing Headings without Changing ToC
Here should go questions about transforming XML with XSLT and FOP.
-
- Posts: 4
- Joined: Wed May 25, 2016 6:43 pm
Changing Headings without Changing ToC
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!
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!
-
- Posts: 404
- Joined: Thu Aug 21, 2003 11:36 am
- Location: Craiova
- Contact:
Re: Changing Headings without Changing ToC
Post by radu_pisoi »
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.
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
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service