Loading ...
Sorry, an error occurred while loading the content.

Re: [dita-users] Re: Outline Numbering in PDF?

Expand Messages
  • Mark Peters
    Hi Tom, I really appreciate your providing the templates needed to add outline numbering to topics in the PDF output. Currently, the templates add numbering at
    Message 1 of 42 , May 2, 2011
    • 0 Attachment
      Hi Tom,

      I really appreciate your providing the templates needed to add outline numbering to topics in the PDF output. Currently, the templates add numbering at all levels in the output. I'd like to number the topics at the chapter level and below (that is, not add numbering to parts).

      I would have thought that the following line would limit numbering to the chapter level and below, but I was mistaken:

      <xsl:when test="count($level)=1 and parent::*/@id[. = //*/chapter/@id]">

      Do you have any idea how to limit the outline numbering to the chapter level and below? I've tried adding logic at different locations in the templates, without success.

      Thanks,
      Mark


      On Thu, Apr 21, 2011 at 1:46 PM, Mark Peters <markpeters.work@...> wrote:
      Kudos to Chris Johnson and Tom Ed White for providing templates to auto-number titles to the specified level. They work like a charm. I'd like to use them to auto-number the topic titles in our 300-odd page software installation guides,  making it easier for customers and Support personnel to locate a set of instructions in the guides.

      Our guides are grouped into parts. The challenge we're encountering is as follows: Chapter numbers don't restart with each new part. If there are 20 chapters in a guide, then the chapters are numbered 1-20.

      The templates add numbering at the part level and below. So, topic numbering is as follows:

      1. Part I
           1.1 Chapter 1
                1.1.1 Heading 1
           1.2 Chapter 2
                1.2.1 Heading 1
      2. Part II
           2.1 Chapter 3
                2.1.1 Heading 1
           2.2 Chapter 4

                2.2.1 Heading 1

      I'd prefer to insert numbering starting at the chapter level, not the part level.

      Part I
           1 Chapter 1
                1.1 Heading 1
           2 Chapter 2
                2.1 Heading 1
      Part II
           3 Chapter 3
                3.1 Heading 1
           4 Chapter 4
                4.1 Heading 1

      This topic title numbering would make more sense to readers.

      How could I modify the templates to insert numbering starting at the chapter level? I don't see a logical spot to add this if/then statement in the XSL.

      Thanks,
      Mark



      On Fri, Jul 30, 2010 at 3:50 PM, tomedw <wtomed@...> wrote:
       

      I recently wrote some templates to support topic numbering for bookmaps. I haven't tested it completely, but so far it seems ok. It supports chapters, appendices, bookmarks. I have not tested prefaces or parts, but these templates can be easily modified for that. Thanks to Chris Johnson for the original templates.

      Note you will need to modify other templates to remove redundant numbering, for example in the TOC and the chapter cover pages. That's what the getNonumTitle template is for.

      Pasting the text into this edit windows may have messed up some syntax.

      Regards,
      Tom Ed White
      Tekelec

      <!--Thanks to Chris Johnson from the Yahoo Dita group for basic template.
      I added support for bookmaps.
      Maximum level to which Topic titles are numbered.
      See "getTitleNumber" template below
      -->
      <xsl:variable name="topicTitle.numLevel">6</xsl:variable>

      <!-- getNonumTitle template is a copy of the original getTitle
      template that will be used for titles that should not be numbered. -->

      <xsl:template name="getNonumTitle"><!-- get fully-processed title content by whatever mechanism -->
      <xsl:choose>
      <!-- add keycol here once implemented-->
      <xsl:when test="@spectitle">
      <xsl:value-of select="@spectitle"/>
      </xsl:when>
      <xsl:otherwise>
      <xsl:apply-templates/>
      </xsl:otherwise>
      </xsl:choose>
      </xsl:template>

      <!-- getTitle template override. See demo\fo\xsl\fo\commons.xsl -->
      <xsl:template name="getTitle">
      <!--
      get fully-processed title content by whatever mechanism
      -->
      <xsl:variable name="titleNumber">
      <!-- Add title numbers to topic titles ONLY-->
      <xsl:if test="parent::*[contains(@class,'topic/topic')]">
      <xsl:call-template name="getTitleNumber" />
      </xsl:if>
      </xsl:variable>
      <xsl:choose>
      <!-- add keycol here once implemented-->
      <xsl:when test="@spectitle">
      <xsl:value-of select="@spectitle" />
      </xsl:when>
      <!-- Suppress numbering of the glossary -->
      <xsl:when test="parent::*[contains(@class,'topic/topic')][@id = //*/glossarylist/@id]">
      <xsl:apply-templates />
      </xsl:when>
      <xsl:otherwise>
      <xsl:value-of select="$titleNumber" />
      <xsl:apply-templates />
      </xsl:otherwise>
      </xsl:choose>
      </xsl:template>

      <!-- Number topics down to level = $topicTitle.numLevel -->
      <xsl:template name="getTitleNumber">
      <!-- Find the -->
      <xsl:variable name="level"
      select="ancestor::*[contains(@class,' topic/topic ')]" />
      <xsl:variable name="appendix"
      select="//*[contains(@class,' bookmap/appendix ')]" />
      <xsl:choose>
      <xsl:when test="count($level)=1 and parent::*/@id[. = //*/chapter/@id]">
      <xsl:for-each select="$level">


      <xsl:value-of
      select="count(preceding-sibling::*[contains(@class,' topic/topic ')]) + 1" />
      <xsl:text> </xsl:text>
      </xsl:for-each>
      </xsl:when>
      <xsl:when test="count($level)=1 and parent::*/@id[. = //*/appendix/@id]">
      <!-- from="*[contains(@class,' topic/topic ')][@id[. = $appendix[1]/@id]"-->
      <!-- <xsl:number level="multiple" format="A"/>-->
      <xsl:for-each select="$level">
      <xsl:number
      value="count(preceding-sibling::*[contains(@class,' topic/topic ')][@id = //*/appendix/@id]) + 1"
      format="A"/>

      <xsl:text> </xsl:text>
      </xsl:for-each>
      </xsl:when>
      <xsl:when
      test="not(count($level) &gt; $topicTitle.numLevel) and ancestor::*/@id[. = //*/appendix/@id]">
      <xsl:number
      count="*[contains(@class,' topic/topic ')][@id = //*/appendix/@id|//*/topicref/@id]"
      level="multiple" format="A.1" />
      <xsl:text> </xsl:text>
      </xsl:when>
      <xsl:when test="not(count($level) &gt; $topicTitle.numLevel)">
      <xsl:number count="*[contains(@class,' topic/topic ')]"
      level="multiple" format="1.1" />
      <xsl:text> </xsl:text>
      </xsl:when>
      <xsl:otherwise />
      <!--
      no title numbering at nth level where n > $topicTitle.numLevel
      -->
      </xsl:choose>
      </xsl:template>


      --- In dita-users@yahoogroups.com, "mostberg9000" <magnus_osterberg@...> wrote:
      >
      > Excuse me, I made an error. I wrote that I receive dynamically numbered chapter headings in the TOC.
      >
      > The truth is that I do not.
      >
      > Kind regards,
      > MagnusT




      --
      Senior technical writer
      Saba Software, Inc.



      --
      Senior technical writer
      Saba Software, Inc.
    • Sander Verhagen
      Hi, As a matter of fact, I ve just done the plugin generator for title numbering both Chapters only and All levels , and at this time I can see no
      Message 42 of 42 , Sep 9, 2012
      • 0 Attachment

        Hi,

         

         

        As a matter of fact, I've just done the plugin generator for title numbering both “Chapters only” and “All levels”, and at this time I can see no difference in the output.

         

        Kind regards, Sander.

         

         

         

         

        From: dita-users@yahoogroups.com [mailto:dita-users@yahoogroups.com] On Behalf Of Sander Verhagen
        Sent: donderdag 6 september 2012 13:49
        To: dita-users@yahoogroups.com
        Subject: RE: [dita-users] Re: Outline Numbering in PDF?

         

         

        Hi,

         

         

        I belief I did that in the past and it did only outline numbering on the level of files. If there was sub-topics inside a file, these weren’t numbered.

         

        Kind regards, Sander.

         

         

        From: dita-users@yahoogroups.com [mailto:dita-users@yahoogroups.com] On Behalf Of juliov27612
        Sent: donderdag 6 september 2012 13:22
        To: dita-users@yahoogroups.com
        Subject: [dita-users] Re: Outline Numbering in PDF?

         

         

        Hi Sander,

        If you haven't used Jarno's PDF Plugin generator, you should give it a go. If I remember correctly you can just set it up to generate a plugin that does the heading numbering for you and that code is very efficient and I believe even handles the Appendix correctly.

        The generator is here: http://dita-generator-hrd.appspot.com/pdf-plugin/

        Good luck,

        Julio J. Vazquez
        SDI Global Solutions

        --- In dita-users@yahoogroups.com, Sander Verhagen <sverhagen@...> wrote:
        >
        > Hi,
        >
        >
        > I found great XSLT code in the following post from 2010:
        > http://tech.dir.groups.yahoo.com/group/dita-users/message/19154
        >
        > It works well, except for numbering the appendices. When appendices are included processing gets incredibly slow. I'm doing this on a non-trivial document, with over 100 pages of appendices. (At which point I can't even see the processing finish within my span of patience.) If I dial down on the appendices I can see it perform better.
        >
        > I also experimented by commenting the following lines. If doing that, performance is much alike before adding this entire XSLT code. I can figure that the //* in there makes it slow. I don't know, though, how to fix it so that my appendices are properly numbered - though fast :)
        >
        > <xsl:number
        > count="*[contains(@class,' topic/topic ')][@id = //*/appendix/@id|//*/topicref/@id]"
        > level="multiple" format="A.1" />
        > <xsl:text> </xsl:text>
        >
        > Your help would be appreciated! Thanks, Sander.
        >

      Your message has been successfully submitted and would be delivered to recipients shortly.