docbook-apps

  • 1.  Re: [docbook-apps] toc customization question

    Posted 06-01-2012 16:54
    Hi Tim,
    Your customization does not work because that template is used for handling that
    section within a toc that has already started, not for starting the toc in the first
    place for the section.

    You'll need to customize the short template named 'section.toc' from html/autotoc.xsl.
    That template calls 'make.toc', so you just need to add a conditional statement to
    skip calling 'make.toc' if that attribute is set:

    <xsl:template name="section.toc">
    <xsl:param name="toc-context" select="."/>
    <xsl:param name="toc.title.p" select="true()"/>

    <xsl:choose>
    <xsl:when test="$toc-context/@userlevel = 'syntax'">
    </xsl:when>
    <xsl:otherwise>
    <xsl:call-template name="make.toc">
    <xsl:with-param name="toc-context" select="$toc-context"/>
    <xsl:with-param name="toc.title.p" select="$toc.title.p"/>
    <xsl:with-param name="nodes"
    select="section|sect1|sect2|sect3|sect4|sect5|refentry
    |bridgehead[$bridgehead.in.toc != 0]"/>

    </xsl:call-template>
    </xsl:otherwise>
    </xsl:choose>
    </xsl:template>


    Bob Stayton
    Sagehill Enterprises
    bobs@sagehill.net


    ----- Original Message -----
    From: "Tim Arnold" <jtim.arnold@gmail.com>
    To: "Richard Hamilton" <hamilton@xmlpress.net>
    Cc: "DocBook Apps" <docbook-apps@lists.oasis-open.org>
    Sent: Friday, June 01, 2012 6:18 AM
    Subject: Re: [docbook-apps] toc customization question


    Hi Dick,
    Thanks, I have been reading that section, but it's not that I want to
    control the toc on every section, just one section that has a
    particular attribute. My question wasn't clear that I do want section
    tocs, just not for this particular section.

    As far as I can tell, I can't put selectors in the generate.toc
    parameter. Here is what I have:
    <xsl:param name="generate.toc">book toc
    part toc
    preface toc
    chapter toc
    appendix toc
    section toc
    </xsl:param>

    And if it were possible I would do this:
    <xsl:param name="generate.toc">book toc
    part toc
    preface toc
    chapter toc
    appendix toc
    section[not(@userlevel='syntax')] toc
    </xsl:param>

    so that all sections except that particular one gets the toc
    generated. That's the reason for my attempt to override the template
    for that section with mode='toc' (in my previous message).

    I don't understand why my override template is not having an effect.
    thanks,
    --Tim


    On Thu, May 31, 2012 at 9:24 PM, Richard Hamilton <hamilton@xmlpress.net> wrote:
    > Tim,
    >
    > I'm not 100% sure what you're trying to do, but it looks like you're trying to
    > control what levels in the structure get TOCs. This is controlled through a
    > parameter called generate.toc, and you shouldn't need to customize any templates to
    > assign TOCs at various levels in the structure.
    >
    > You can find a description of how to set generate.toc in Bob Stayton's book. Here is
    > a link to the pertinent section:
    >
    > http://www.sagehill.net/docbookxsl/TOCcontrol.html
    >
    > If I'm missing something, and you need to do something more, you will find a
    > complete description of TOC customization in that same section.
    >
    > I hope that helps.
    >
    > Best Regards,
    > Dick Hamilton
    > -------
    > XML Press
    > XML for Technical Communicators
    > http://xmlpress.net
    > hamilton@xmlpress.net
    >
    >
    >
    > On May 31, 2012, at 1:42 PM, Tim Arnold wrote:
    >
    >> hi, I have one particular section in which I would like to omit the
    >> table of contents.
    >> I want the section to appear in the chapter table of contents, just
    >> not have a toc generated on this section.
    >>
    >> The section has the attribute userlevel='syntax'. I tried the
    >> following template but it had no effect I could see (the toc showed up
    >> on the section). I thought it would not generate the toc in the
    >> specified section and produce a single level toc for chapters (i.e. a
    >> toc of the top-level sections in the chapter):
    >>
    >> <xsl:template match="d:section[@userlevel='syntax']" mode="toc">
    >> <xsl:param name="toc-context" select="." />
    >> <xsl:if test="local-name($toc-context) = 'chapter'">
    >> <xsl:call-template name="subtoc">
    >> <xsl:with-param name="toc-context" select="$toc-context"/>
    >> <xsl:with-param name="nodes" select="foo"/>
    >> </xsl:call-template>
    >> </xsl:if>
    >> </xsl:template>
    >>
    >> How can I omit the toc for section[@userlevel='syntax'] and still have
    >> the section listed in the chapter toc?
    >>
    >> thanks,
    >> --Tim
    >>
    >> ---------------------------------------------------------------------
    >> To unsubscribe, e-mail: docbook-apps-unsubscribe@lists.oasis-open.org
    >> For additional commands, e-mail: docbook-apps-help@lists.oasis-open.org
    >>
    >

    ---------------------------------------------------------------------
    To unsubscribe, e-mail: docbook-apps-unsubscribe@lists.oasis-open.org
    For additional commands, e-mail: docbook-apps-help@lists.oasis-open.org






  • 2.  Re: [docbook-apps] toc customization question

    Posted 06-01-2012 17:36
    Thanks Bob! That works exactly as I needed, and now I understand why
    my earlier attempt didn't work.

    thanks,
    --Tim


    On Fri, Jun 1, 2012 at 12:53 PM, Bob Stayton <bobs@sagehill.net> wrote:
    > Hi Tim,
    > Your customization does not work because that template is used for handling
    > that section within a toc that has already started, not for starting the toc
    > in the first place for the section.
    >
    > You'll need to customize the short template named 'section.toc' from
    > html/autotoc.xsl. That template calls 'make.toc', so you just need to add a
    > conditional statement to skip calling 'make.toc' if that attribute is set:
    >
    > <xsl:template name="section.toc">
    >
    >  <xsl:param name="toc-context" select="."/>
    >  <xsl:param name="toc.title.p" select="true()"/>
    >
    >  <xsl:choose>
    >   <xsl:when test="$toc-context/@userlevel = 'syntax'">
    >   </xsl:when>
    >   <xsl:otherwise>
    >     <xsl:call-template name="make.toc">
    >
    >       <xsl:with-param name="toc-context" select="$toc-context"/>
    >       <xsl:with-param name="toc.title.p" select="$toc.title.p"/>
    >       <xsl:with-param name="nodes"
    >                       select="section|sect1|sect2|sect3|sect4|sect5|refentry
    >                              |bridgehead[$bridgehead.in.toc != 0]"/>
    >
    >     </xsl:call-template>
    >   </xsl:otherwise>
    >  </xsl:choose>
    > </xsl:template>
    >
    >
    > Bob Stayton
    > Sagehill Enterprises
    > bobs@sagehill.net
    >
    >
    > ----- Original Message ----- From: "Tim Arnold" <jtim.arnold@gmail.com>
    > To: "Richard Hamilton" <hamilton@xmlpress.net>
    > Cc: "DocBook Apps" <docbook-apps@lists.oasis-open.org>
    > Sent: Friday, June 01, 2012 6:18 AM
    > Subject: Re: [docbook-apps] toc customization question
    >
    >
    >
    > Hi Dick,
    > Thanks, I have been reading that section, but it's not that I want to
    > control the toc on every section, just one section that has a
    > particular attribute. My question wasn't clear that I do want section
    > tocs, just not for this particular section.
    >
    > As far as I can tell, I can't put selectors in the generate.toc
    > parameter. Here is what I have:
    > <xsl:param name="generate.toc">book toc
    >   part toc
    >   preface toc
    >   chapter toc
    >   appendix toc
    >   section toc
    >  </xsl:param>
    >
    > And if it were possible I would do this:
    > <xsl:param name="generate.toc">book toc
    >   part toc
    >   preface toc
    >   chapter toc
    >   appendix toc
    >   section[not(@userlevel='syntax')] toc
    >  </xsl:param>
    >
    > so that all sections except that particular one gets the toc
    > generated. That's the reason for my attempt to override the template
    > for that section with mode='toc' (in my previous message).
    >
    > I don't understand why my override template is not having an effect.
    > thanks,
    > --Tim
    >
    >
    > On Thu, May 31, 2012 at 9:24 PM, Richard Hamilton <hamilton@xmlpress.net>
    > wrote:
    >>
    >> Tim,
    >>
    >> I'm not 100% sure what you're trying to do, but it looks like you're
    >> trying to control what levels in the structure get TOCs. This is controlled
    >> through a parameter called generate.toc, and you shouldn't need to customize
    >> any templates to assign TOCs at various levels in the structure.
    >>
    >> You can find a description of how to set generate.toc in Bob Stayton's
    >> book. Here is a link to the pertinent section:
    >>
    >> http://www.sagehill.net/docbookxsl/TOCcontrol.html
    >>
    >> If I'm missing something, and you need to do something more, you will find
    >> a complete description of TOC customization in that same section.
    >>
    >> I hope that helps.
    >>
    >> Best Regards,
    >> Dick Hamilton
    >> -------
    >> XML Press
    >> XML for Technical Communicators
    >> http://xmlpress.net
    >> hamilton@xmlpress.net
    >>
    >>
    >>
    >> On May 31, 2012, at 1:42 PM, Tim Arnold wrote:
    >>
    >>> hi, I have one particular section in which I would like to omit the
    >>> table of contents.
    >>> I want the section to appear in the chapter table of contents, just
    >>> not have a toc generated on this section.
    >>>
    >>> The section has the attribute userlevel='syntax'. I tried the
    >>> following template but it had no effect I could see (the toc showed up
    >>> on the section). I thought it would not generate the toc in the
    >>> specified section and produce a single level toc for chapters (i.e. a
    >>> toc of the top-level sections in the chapter):
    >>>
    >>> <xsl:template match="d:section[@userlevel='syntax']" mode="toc">
    >>> <xsl:param name="toc-context" select="." />
    >>> <xsl:if test="local-name($toc-context) = 'chapter'">
    >>> <xsl:call-template name="subtoc">
    >>> <xsl:with-param name="toc-context" select="$toc-context"/>
    >>> <xsl:with-param name="nodes" select="foo"/>
    >>> </xsl:call-template>
    >>> </xsl:if>
    >>> </xsl:template>
    >>>
    >>> How can I omit the toc for section[@userlevel='syntax'] and still have
    >>> the section listed in the chapter toc?
    >>>
    >>> thanks,
    >>> --Tim
    >>>
    >>> ---------------------------------------------------------------------
    >>> To unsubscribe, e-mail: docbook-apps-unsubscribe@lists.oasis-open.org
    >>> For additional commands, e-mail: docbook-apps-help@lists.oasis-open.org
    >>>
    >>
    >
    > ---------------------------------------------------------------------
    > To unsubscribe, e-mail: docbook-apps-unsubscribe@lists.oasis-open.org
    > For additional commands, e-mail: docbook-apps-help@lists.oasis-open.org
    >
    >
    >