OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

docbook-apps message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]


Subject: Re: [docbook-apps] How to include sidebars in the table of contents...


Hi Bob,

With a little tweaking it worked. First, I switched over to use the <section>
element instead of <sect1>, <sect2>, etc, as you said, to reduced the amount of
customization. Second, on the line:

>       <xsl:apply-templates select="example|sect2" mode="toc">

it still wouldn't call the example toc template, only the sect2 template. So I
decideded to handle it by adding an additional block outside of the test of
section and depth:

<xsl:template match="section" mode="toc">
  ...
    <xsl:if test="$toc.section.depth &gt; $depth and section">
      <fo:block id="toc.{$cid}.{$id}"
              start-indent="{$reldepth*$toc.indent.width}pt">
        <xsl:apply-templates select="section" mode="toc">
          <xsl:with-param name="toc-context" select="$toc-context"/>
        </xsl:apply-templates>
      </fo:block>
    </xsl:if>
    <!-- begin customization to display example block -->
    <xsl:if test="example">
      <fo:blockstart-indent="{count(ancestor::*)*$toc.indent.width}pt">
        <xsl:apply-templates select="example" mode="toc">
          <xsl:with-param name="toc-context" select="$toc-context"/>
        </xsl:apply-templates>
      </fo:block>
    </xsl:if>
    <!-- end customization to display example block -->
  ...
</xsl:template>

This works perfectly. Now to clean up the presentation...
Thanks,

Ken Van Mersbergen
Tedras Global Solutions


--- Bob Stayton <bobs@sagehill.net> wrote:

> Hi Ken,
> In the FO stylesheet, the TOC is processed by a sequence of templates to 
> handle the various levels. The division.toc template starts the TOC and 
> selects only the top level elements to include, those that can reside as 
> direct children of book or part.  An example element would never be 
> included in a selection in that context.
> 
> You will see that the division.toc template does this step:
> 
>       <xsl:apply-templates select="$nodes" mode="toc">
>         <xsl:with-param name="toc-context" select="$toc-context"/>
>       </xsl:apply-templates>
> 
> It processes its chapter, appendix, and other nodes using mode="toc". 
> Further down in fo/autotoc.xsl you will see templates such as:
> 
> <xsl:template match="preface|chapter|appendix|article"    mode="toc">
> 
> By using a mode like this, each element type can be handled differently. 
> Each such template calls the template named 'toc.line' to generate its 
> entry in the TOC, and then does apply-templates in mode="toc" on any child 
> elements to be included under it.  Each level is responsible for selecting 
> those elements to be included under it.  So you don't actually need to 
> customize the division.toc template. Instead, you need to customize 
> templates further down the hierarchy.
> 
> In your case, an example inside a sect1 requires customizing the template 
> that starts with:
> 
> <xsl:template match="sect1" mode="toc">
> 
> Change the apply-templates in this template to select both example and 
> sect2:
> 
>       <xsl:apply-templates select="example|sect2" mode="toc">
>         <xsl:with-param name="toc-context" select="$toc-context"/>
>       </xsl:apply-templates>
> 
> You will have to repeat that process for each section level (unless you 
> switch to using <section> elements, for which there is only one template in 
> mode="toc").
> 
> The other thing you will have to change is how an example element is 
> formatted in a table of contents.  The default formatting assumes the 
> example entry is in a separate "List of Examples", so the entry is just the 
> example number and title, without the "Example" label before the number. 
> So you will also need to customize the template that matches example in 
> mode="toc".  The original template in fo/autotoc.xsl is:
> 
> <xsl:template match="figure|table|example|equation|procedure" mode="toc">
>   <xsl:call-template name="toc.line"/>
> </xsl:template>
> 
> Replace the call to the 'toc.line' template with a copy of the content of 
> the 'toc.line' template, and add the word "Example " to the label:
> 
> <xsl:template match="figure|table|example|equation|procedure" mode="toc">
>   <xsl:variable name="id">
>     <xsl:call-template name="object.id"/>
>   </xsl:variable>
> 
>   <xsl:variable name="label">
>     <xsl:text>Example </xsl:text>
>     <xsl:apply-templates select="." mode="label.markup"/>
>   </xsl:variable>
> 
>   <fo:block text-align-last="justify"
>             text-align="start"
>             end-indent="{$toc.indent.width}pt"
>             last-line-end-indent="-{$toc.indent.width}pt">
>     <fo:inline keep-with-next.within-line="always">
>       <fo:basic-link internal-destination="{$id}">
>         <xsl:if test="$label != ''">
>           <xsl:copy-of select="$label"/>
>           <xsl:value-of select="$autotoc.label.separator"/>
>         </xsl:if>
>         <xsl:apply-templates select="." mode="titleabbrev.markup"/>
>       </fo:basic-link>
>     </fo:inline>
>     <fo:inline keep-together.within-line="always">
>       <xsl:text> </xsl:text>
>       <fo:leader leader-pattern="dots"
>                  leader-pattern-width="3pt"
>                  leader-alignment="reference-area"
>                  keep-with-next.within-line="always"/>
>       <xsl:text> </xsl:text>
>       <fo:basic-link internal-destination="{$id}">
>         <fo:page-number-citation ref-id="{$id}"/>
>       </fo:basic-link>
>     </fo:inline>
>   </fo:block>
> </xsl:template>
> 
> If you are doing this for all languages (not just English), then you would 
> use a call to the gentext template with a param named 'key' with value 
> 'example'.
> 
> Bob Stayton
> Sagehill Enterprises
> DocBook Consulting
> bobs@sagehill.net
> 
> 
> ----- Original Message ----- 
> From: "Ken Van Mersbergen" <kenvm97@yahoo.com>
> To: <docbook-apps@lists.oasis-open.org>
> Sent: Thursday, April 27, 2006 10:49 AM
> Subject: Re: [docbook-apps] How to include sidebars in the table of 
> contents...
> 
> 
> >I modified my division.toc to include example when setting $node. Still no
> > results. So I corrected my use of placing an example in sidebar. Instead 
> > of
> > including sidebars in the ToC, I want to include example.
> >
> > I'm using docbook V4.5CR1, with xsl stylesheets V1.68.1, and outputing to 
> > PDF
> > using fop 0.20.5.
> >
> > I have limited my toc.section.depth to 1.
> >
> > With that said, here is a sample of my xml:
> > <book>
> >  <chapter label="1">
> >    <title>Introduction</title>
> >    <sect1 label="1.1">
> >      <title>Why...</title>
> >      <sect2>
> >        <title>...</title>
> >        <example/>
> >      </sect2>
> >    </sect1>
> >    <sect1 label="1.2">
> >      <title>Who</title>
> >      <example/>
> >    </sect>
> >    ...
> >  </chapter>
> > </book>
> >
> > This should display as:
> > 1.  Introduction
> > 1.1 Why...
> >    Example 1: title
> > 1.2 Who...
> >    Example 2: title
> > 1.3 ...
> > 1.4 ...
> >
> > Ken Van Mersbergen
> > Tedras Global Solutions
> >
> > --- Bob Stayton <bobs@sagehill.net> wrote:
> >
> >> The list recently discussed how to add qandsets to a TOC, the
> >> discussion starting here:
> >>
> >> http://lists.oasis-open.org/archives/docbook-apps/200601/msg00095.html
> >>
> >> and continued here:
> >> http://lists.oasis-open.org/archives/docbook-apps/200602/msg00077.html
> >>
> >> Your problem is similar, it seems.  Instead of customizing
> >> component.toc (used for article), you would want to customize
> >> division.toc for a book.  HTML and FO processing is a bit
> >> different you will find.
> >>
> >> Bob Stayton
> >> Sagehill Enterprises
> >> DocBook Consulting
> >> bobs@sagehill.net
> >>
> >>
> >> ----- Original Message ----- 
> >> From: "Ken Van Mersbergen" <kenvm97@yahoo.com>
> >> To: <docbook-apps@lists.oasis-open.org>
> >> Sent: Friday, April 07, 2006 4:05 PM
> >> Subject: [docbook-apps] How to include sidebars in the table of
> >> contents...
> >>
> >>
> >> >I am automatically generating a ToC and want to include blocks
> >> >marked with the
> >> > <sidebar> tag in the table of contents (note that I have my
> >> > examples tagged as
> >> > a sidebar with a role of example) so that it appears like this:
> >> >
> >> > 1.  Introduction
> >> > 1.1 Why...
> >> > 1.2 Who...
> >> >    Example 1: title
> >> >    Example 2: title
> >> > 1.3 ...
> >> > 1.4 ...
> >> >
> >> > Where/how do I override the template to include do this in the
> >> > Toc? Is this a
> >> > case where it would be better to manually generate a ToC?
> >> >
> >> > Thanks,
> >> > Ken
> >> >
> >> >
> >> > __________________________________________________
> >> > Do You Yahoo!?
> >> > Tired of spam?  Yahoo! Mail has the best spam protection around
> >> > http://mail.yahoo.com
> >> >
> >> > ---------------------------------------------------------------------
> >> > To unsubscribe, e-mail:
> >> > docbook-apps-unsubscribe@lists.oasis-open.org
> >> > For additional commands, e-mail:
> >> > docbook-apps-help@lists.oasis-open.org
> >> >
> >> >
> >> >
> >>
> >>
> >>
> >
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Tired of spam?  Yahoo! Mail has the best spam protection around
> > http://mail.yahoo.com
> >
> > ---------------------------------------------------------------------
> > 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
> 
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]