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

Re: [dita-users] Re: bookmap, table or figure numbering

Expand Messages
  • Dave Pawson
    Thanks Leigh. I didn t think I d be the first to want this. regards DaveP ... -- Dave Pawson XSLT XSL-FO FAQ. Docbook FAQ. http://www.dpawson.co.uk
    Message 1 of 9 , Apr 27 10:47 PM
    View Source
    • 0 Attachment
      Thanks Leigh.
      I didn't think I'd be the first to want this.

      regards DaveP

      On 27 April 2012 21:03, Leigh White <lwwhite5@...> wrote:
      > Al alternative method for getting the current chapter/appendix/part number (though it does not address the issue of counting figures within the current chapter) is to use Kyle Schwamkrug's getChapterPrefix template. By adding it to your custom.xsl file, you can use it all over the place. I use it to add chapter numbers to table and figure titles as well as to bookmarks and to page entries in the TOC. I'm pretty sure that template is posted somewhere on this list, though a quick search hasn't turned it up.
      >
      > So this:
      >
      > <number>
      >   <xsl:call-template name="getChapterPrefix" />
      >   <xsl:text>-</xsl:text>
      >   <xsl:number level="any" count="*[contains(@class, ' topic/fig ')][child::*[contains(@class, ' topic/title ')]]" from="/"/>
      > </number>
      >
      > gets me the current chapter number, a dash and the current figure number...from the root, unfortunately, not from the chapter start.
      >
      > Best,
      > Leigh
      >
      > --- In dita-users@yahoogroups.com, Dave Pawson <dave.pawson@...> wrote:
      >>
      >> Code from commons.xsl
      >>
      >> This adds a prefix, and is cautious about using the variable
      >> in case it is not set.
      >> basic code is
      >>
      >>    <xsl:for-each select="key('map-id', @id)[1]">
      >>                           <xsl:number format="1"
      >>                             count="*[contains(@class, ' bookmap/chapter ')]"/>
      >>                         </xsl:for-each>
      >>
      >>
      >>
      >>
      >>        <!-- code   from commons.xsl -->
      >>                       <!-- Only output x - if in main body -->
      >>                       <xsl:variable name='prefix'>
      >>                         <xsl:for-each select="key('map-id', @id)[1]">
      >>                           <xsl:number format="1"
      >>                             count="*[contains(@class, ' bookmap/chapter ')]"/>
      >>                         </xsl:for-each>
      >>                         <xsl:text>-</xsl:text>
      >>                       </xsl:variable>
      >>                       <!-- Select this value, unless no prefix is found -->
      >>                       <xsl:choose>
      >>                         <xsl:when test="$prefix = '-'">
      >>                           <xsl:text> </xsl:text>
      >>                         </xsl:when>
      >>                         <xsl:otherwise>
      >>                           <xsl:value-of select="$prefix"/>
      >>                         </xsl:otherwise>
      >>                       </xsl:choose>
      >>
      >>
      >>
      >> HTH others.
      >>
      >> On 25 April 2012 15:22, Dave Pawson <dave.pawson@...> wrote:
      >> > xsl/tables.xsl has a number  prior to the title.
      >> >
      >> > Table 1: table title
      >> >
      >> > I need to prefix the number with the chapter number, e.g. 3rd table in
      >> > chapter 5 would be
      >> > Table 5-3: table title
      >> >
      >> > I'm guessing others have worked out current chapter number?
      >> > Any pointers please.
      >> >
      >> > TIA
      >> >
      >> > --
      >> > Dave Pawson
      >> > XSLT XSL-FO FAQ.
      >> > Docbook FAQ.
      >> > http://www.dpawson.co.uk
      >>
      >>
      >>
      >> --
      >> Dave Pawson
      >> XSLT XSL-FO FAQ.
      >> Docbook FAQ.
      >> http://www.dpawson.co.uk
      >>
      >
      >
      >
      >
      > ------------------------------------
      >
      > Yahoo! Groups Links
      >
      >
      >



      --
      Dave Pawson
      XSLT XSL-FO FAQ.
      Docbook FAQ.
      http://www.dpawson.co.uk
    • leena.abraham01
      Hi Nancy, Tried this piece of the code snippet which u mentioned, in the commons.xsl file.
      Message 2 of 9 , Oct 8, 2013
      View Source
      • 0 Attachment

         Hi Nancy,


        Tried this piece of the code snippet which u mentioned, in the commons.xsl file.


        <xsl:number level="any" count="*[contains(@class, ' topic/fig ')]/*[contains(@class, ' topic/title ')]" from="//*[contains(@class, ' bookmap/chapter ')][last()]" format="1-1"/>


        I am not able to get the output....was ter a change made anywhere else too...??


        Regards

        Leena



        ---In dita-users@yahoogroups.com, <dave.pawson@...> wrote:

        Thanks Leigh.
        I didn't think I'd be the first to want this.

        regards DaveP

        On 27 April 2012 21:03, Leigh White <lwwhite5@...> wrote:
        > Al alternative method for getting the current chapter/appendix/part number (though it does not address the issue of counting figures within the current chapter) is to use Kyle Schwamkrug's getChapterPrefix template. By adding it to your custom.xsl file, you can use it all over the place. I use it to add chapter numbers to table and figure titles as well as to bookmarks and to page entries in the TOC. I'm pretty sure that template is posted somewhere on this list, though a quick search hasn't turned it up.
        >
        > So this:
        >
        > <number>
        >   <xsl:call-template name="getChapterPrefix" />
        >   <xsl:text>-</xsl:text>
        >   <xsl:number level="any" count="*[contains(@class, ' topic/fig ')][child::*[contains(@class, ' topic/title ')]]" from="/"/>
        > </number>
        >
        > gets me the current chapter number, a dash and the current figure number...from the root, unfortunately, not from the chapter start.
        >
        > Best,
        > Leigh
        >
        > --- In dita-users@yahoogroups.com, Dave Pawson <dave.pawson@...> wrote:
        >>
        >> Code from commons.xsl
        >>
        >> This adds a prefix, and is cautious about using the variable
        >> in case it is not set.
        >> basic code is
        >>
        >>    <xsl:for-each select="key('map-id', @id)[1]">
        >>                           <xsl:number format="1"
        >>                             count="*[contains(@class, ' bookmap/chapter ')]"/>
        >>                         </xsl:for-each>
        >>
        >>
        >>
        >>
        >>        <!-- code   from commons.xsl -->
        >>                       <!-- Only output x - if in main body -->
        >>                       <xsl:variable name='prefix'>
        >>                         <xsl:for-each select="key('map-id', @id)[1]">
        >>                           <xsl:number format="1"
        >>                             count="*[contains(@class, ' bookmap/chapter ')]"/>
        >>                         </xsl:for-each>
        >>                         <xsl:text>-</xsl:text>
        >>                       </xsl:variable>
        >>                       <!-- Select this value, unless no prefix is found -->
        >>                       <xsl:choose>
        >>                         <xsl:when test="$prefix = '-'">
        >>                           <xsl:text> </xsl:text>
        >>                         </xsl:when>
        >>                         <xsl:otherwise>
        >>                           <xsl:value-of select="$prefix"/>
        >>                         </xsl:otherwise>
        >>                       </xsl:choose>
        >>
        >>
        >>
        >> HTH others.
        >>
        >> On 25 April 2012 15:22, Dave Pawson <dave.pawson@...> wrote:
        >> > xsl/tables.xsl has a number  prior to the title.
        >> >
        >> > Table 1: table title
        >> >
        >> > I need to prefix the number with the chapter number, e.g. 3rd table in
        >> > chapter 5 would be
        >> > Table 5-3: table title
        >> >
        >> > I'm guessing others have worked out current chapter number?
        >> > Any pointers please.
        >> >
        >> > TIA
        >> >
        >> > --
        >> > Dave Pawson
        >> > XSLT XSL-FO FAQ.
        >> > Docbook FAQ.
        >> > http://www.dpawson.co.uk
        >>
        >>
        >>
        >> --
        >> Dave Pawson
        >> XSLT XSL-FO FAQ.
        >> Docbook FAQ.
        >> http://www.dpawson.co.uk
        >>
        >
        >
        >
        >
        > ------------------------------------
        >
        > Yahoo! Groups Links
        >
        >
        >



        --
        Dave Pawson
        XSLT XSL-FO FAQ.
        Docbook FAQ.
        http://www.dpawson.co.uk
      Your message has been successfully submitted and would be delivered to recipients shortly.