Restart page numbering from 1 in each chapter in PDF

<oXygen/> general issues.
surangamas
Posts: 47

Restart page numbering from 1 in each chapter in PDF

Mon May 16, 2016 7:49 pm

Hi:

I am trying to find a way to restart page number from 1 for each chapter in the PDF output, instead of using the default continuous page numbering that DITA-OT offers. I was trying to uncomment parts of this code in "commons.xsl":

Code: Select all

  <xsl:template name="startPageNumbering">
        <!--BS: uncomment if you need reset page numbering at first chapter-->
<!--
        <xsl:variable name="id" select="ancestor-or-self::*[contains(@class, ' topic/topic ')][1]/@id"/>
        <xsl:variable name="mapTopic" select="key('map-id', $id)"/>

        <xsl:if test="not(($mapTopic/preceding::*[contains(@class, ' bookmap/chapter ') or contains(@class, ' bookmap/part ')])
            or ($mapTopic/ancestor::*[contains(@class, ' bookmap/chapter ') or contains(@class, ' bookmap/part ')]))">
            <xsl:attribute name="initial-page-number">1</xsl:attribute>
        </xsl:if>
-->

    </xsl:template>


But didn't seem to work at all, I was wondering where else could I have done to make this happen? Thanks for your help.
radu_pisoi
Posts: 318
Location: Craiova

Re: Restart page numbering from 1 in each chapter in PDF

Tue May 17, 2016 2:52 pm

Hi,

If you uncomment the content of the 'startPageNumbering' template, the page number should be reset only for the first chapter.

If you want to reset the page number for all chapters, you should modify the condition to something like that:

Code: Select all

<xsl:if test="not(
  ($mapTopic/ancestor::*[contains(@class, ' bookmap/chapter ') or contains(@class, ' bookmap/part ')]))">
            <xsl:attribute name="initial-page-number">1</xsl:attribute>
</xsl:if>
Radu Pisoi
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
surangamas
Posts: 47

Re: Restart page numbering from 1 in each chapter in PDF

Wed May 18, 2016 12:27 am

Hi Radu:
Thanks for the reply. Maybe I didn't mention this in my original post: even if I uncomment the code mentioned above without modifying anything, the page number is still not reset to one; it still runs continuously from one until the end, let alone resetting it for every chapter.

I uncommented and modified the code as below, but it still didn't work; the page number is still run continuously from 1 until the last number"

Code: Select all

<xsl:template name="startPageNumbering">
        <xsl:variable name="id" select="ancestor-or-self::*[contains(@class, ' topic/topic ')][1]/@id"/>
        <xsl:variable name="mapTopic" select="key('map-id', $id)"/>
        <xsl:if test="not(($mapTopic/ancestor::*[contains(@class, ' bookmap/chapter ') or contains(@class, ' bookmap/part ')]))">
            <xsl:attribute name="initial-page-number">1</xsl:attribute>
</xsl:if>
    </xsl:template>


What else could I have done to make this work? Thanks.
radu_pisoi
Posts: 318
Location: Craiova

Re: Restart page numbering from 1 in each chapter in PDF

Wed May 18, 2016 9:01 am

Hi,

The cause could be that you are modifying the sources of another DITA-OT that you are running.

oXygen 18.0 comes with two DITA-OT frameworks:
- DITA-OT 1.8 - {oXygenInstallDir}/frameworks/dita/DITA-OT
- DITA-OT 2.2.3 - {oXygenInstallDir}/frameworks/dita/DITA-OT2.x

By default it is used DITA-OT 2.2, but you can change this from Preferences -> DITA -> DITA Open Toolkit.

So, please check you are modifying the source files of DITA-OT you are using. To verify this, you can add an xsl:message in your customization and check in the transformation console for it.
Radu Pisoi
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
surangamas
Posts: 47

Re: Restart page numbering from 1 in each chapter in PDF

Wed May 18, 2016 3:33 pm

Hi Radu:

I am not using the default DITA-OT that came with Oxygen; I am using the custom DITA-OT which I believe is version 1.8, that came with Oxygen v. 17.1. The custom DITA-OT was the one I modified.

So are you saying that this code would only work with DITA-OT 2.x?
surangamas
Posts: 47

Re: Restart page numbering from 1 in each chapter in PDF

Wed May 18, 2016 4:09 pm

To experiment this a bit, I selected the locally installed DITA-OT to process PDF transform, uncommented the code in commons.xsl, and the result was still the same - page number did not restart at each chapter.

I began to wonder whether this had anything to do with my DITA map, so I am including the structure of my DITA map for your reference:

<bookmap>
.....
.....
.....
.....
<frontmatter>
<booklists>
<toc/>
</booklists>
</frontmatter>
<chapter class="- map/topicref bookmap/chapter ">
<topicref href="1.dita">
<topicref href="1.1.dita"/>
<topicref href="1.2.dita"/>
<topicref href="1.3.dita"/>
<topicref href="1.4.dita"/>
</topicref>

<chapter class="- map/topicref bookmap/chapter ">
<topicref href="2.dita">
<topicref href="2.1.dita"/>
<topicref href="2.2.dita"/>
<topicref href="2.3.dita"/>
<topicref href="2.4.dita"/>
</topicref>
<backmatter class="- map/topicref bookmap/backmatter ">
<booklists>
<indexlist/>
<figurelist/>
<tablelist/>
</booklists>
</backmatter>
</bookmap>
radu_pisoi
Posts: 318
Location: Craiova

Re: Restart page numbering from 1 in each chapter in PDF

Thu May 19, 2016 12:01 pm

Hi,

Could you send us the content of the DITA-OT transformation console to the support@oxygenxml.com?

You can enable to always display the DITA-OT console output from 'Preferences' -> 'DITA' -> 'Show console output' option.
Radu Pisoi
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

Return to “Other Issues”

Who is online

Users browsing this forum: No registered users and 3 guests