This is the mail archive of the docbook-apps@lists.oasis-open.org mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[docbook-apps] SOLVED (Was: Re: [docbook-apps] force pagebreaks in a glossary)


I needed to manually insert pagebreaks into a DocBook glossary.  This
required several tuning steps in XSL processing, which Bob Stayton figured
out.  Many kudos to Bob!

First, processing of page break directives need to be added to the
processing of glossaries:
"
A glossary as list is handled differently from other lists.  In the
make-glossary template, it explicitly selects only 'glossentry' elements
to process.  Since it is not a general 'apply-templates', the PI is never
selected for processing.
Also, it turns out that it is easier to use a separate PI template in
'glossary.as.list' mode."
"

Second, in the standard XSL files there are several templates for
glossaries, so we need to make sure the correct one is selected:
"This problem was I specified the wrong template to process the glossary.
I forgot that in addition to a template with match="glossary" in
fo/glossary.xsl, there is also a template with match="book/glossary" and a
higher priority value.
"
Moreover, the XSL needs to actually generate paging:
"  The difference is that the latter generates a page-sequence and the
former does not (it assumes the glossary is in an element that creates a
page-sequence).  The result was a broken FO file when the fo:blocks got
dumped outside of any page-sequence.
"

Finally, fop does not properly process the pagebreak attribute for a
list-tem but it does so for a list-item-label:
"That's because FOP does not implement the whole spec.  In this case, a
break-before on a list-block does not work.
"

This is what finally worked:
I copied the book/glossary template from Norman Walshes fo/glossary.xsl to
my own XSL, and made some modifications (at the end) like Bob advised
above:


<!-- This selects the PI as well as the glossentry elements for processing -->
<xsl:template match="book/glossary|/glossary">
  <xsl:variable name="id">
    <xsl:call-template name="object.id"/>
  </xsl:variable>

  <xsl:variable name="master-reference">
    <xsl:call-template name="select.pagemaster"/>
  </xsl:variable>

  <fo:page-sequence hyphenate="{$hyphenate}"
                    master-reference="{$master-reference}">
    <xsl:attribute name="language">
      <xsl:call-template name="l10n.language"/>
    </xsl:attribute>
    <xsl:attribute name="format">
      <xsl:call-template name="page.number.format">
        <xsl:with-param name="master-reference" select="$master-reference"/>
      </xsl:call-template>
    </xsl:attribute>

    <xsl:attribute name="initial-page-number">
      <xsl:call-template name="initial.page.number">
        <xsl:with-param name="master-reference" select="$master-reference"/>
      </xsl:call-template>
    </xsl:attribute>

    <xsl:attribute name="force-page-count">
      <xsl:call-template name="force.page.count">
        <xsl:with-param name="master-reference" select="$master-reference"/>
      </xsl:call-template>
    </xsl:attribute>

    <xsl:attribute name="hyphenation-character">
      <xsl:call-template name="gentext">
        <xsl:with-param name="key" select="'hyphenation-character'"/>
      </xsl:call-template>
    </xsl:attribute>
    <xsl:attribute name="hyphenation-push-character-count">
      <xsl:call-template name="gentext">
        <xsl:with-param name="key" select="'hyphenation-push-character-count'"/>
      </xsl:call-template>
    </xsl:attribute>
    <xsl:attribute name="hyphenation-remain-character-count">
      <xsl:call-template name="gentext">
        <xsl:with-param name="key" select="'hyphenation-remain-character-count'"/>
      </xsl:call-template>
    </xsl:attribute>

    <xsl:apply-templates select="." mode="running.head.mode">
      <xsl:with-param name="master-reference" select="$master-reference"/>
    </xsl:apply-templates>
    <xsl:apply-templates select="." mode="running.foot.mode">
      <xsl:with-param name="master-reference" select="$master-reference"/>
    </xsl:apply-templates>

    <fo:flow flow-name="xsl-region-body">
      <xsl:call-template name="make-glossary">
        <xsl:with-param name="entries"
         select="glossentry|processing-instruction('pagebreak')"/>
      </xsl:call-template>
    </fo:flow>

  </fo:page-sequence>
</xsl:template>


<!-- Page orientation and layout -->
<xsl:template match="processing-instruction('pagebreak')">
    <fo:block break-after="page"/>
</xsl:template>


<!-- This handles the PI in the glossary -->
<xsl:template match="processing-instruction('pagebreak')"
     mode="glossary.as.list">
  <fo:list-item>
    <fo:list-item-label><fo:block break-before="page"/></fo:list-item-label>
    <fo:list-item-body><fo:block/></fo:list-item-body>
  </fo:list-item>
</xsl:template>


--
#>!$!%(@^%#%*(&(#@#*$^@^$##*#@&(%)@**$!(&!^(#((#&%!)%*@)(&$($$%(@#)&*!^$)^@*^@)

	Tom Peters







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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]