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] long table work around


Hi Paul,
If you are going to use alternate page-sequences for this purpose, you might want to look at the Page Sequence Master Interleave (PSMI) scheme developed by G. Ken Holman:

http://www.cranesoftwrights.com/resources/psmi/index.htm

It is used to switch page-masters in the middle of a page-sequence by breaking it into multiple page-sequences. It is typically done for inserting landscape pages for tables or graphics inside a chapter, but I think it could work for this case too.

Bob Stayton
Sagehill Enterprises
bobs@sagehill.net


----- Original Message ----- From: "Paul Tremblay" <paulhtremblay@gmail.com>
To: <docbook-apps@lists.oasis-open.org>
Sent: Wednesday, January 25, 2012 6:57 PM
Subject: [docbook-apps] long table work around


For a long table, FOP cannot create a title on each page with the words "cont." after it. I have created the following hack to get around this problem. I wonder if there is an easier way? My method required quite a bit of code.

The docbook.xml file itself had a root element of article. It contained an appendix, and the appendix had two sections. The first section had nothing unusual about it. The second section had a role of "long-table" and contained two long tables:

<doc:article xmlns:doc="http://docbook.org/ns/docbook"; xmlns:rst="http://www.restructuredtext.org";>
<doc:info>
....<!--items cut out-->
<doc:appendix>
<doc:title>Appendix</doc:title>
<doc:section xml:id="tables-of-projected-rates-and-costs" role="appendix">
<doc:title xmlns:svg="http://www.w3.org/2000/svg"; xmlns:gr="http://graph2svg.googlecode.com";>Tables of Projected Rates and Costs</doc:title>
<doc:table tabstyle="projected-costs">
...<!--items cut out-->
<doc:section xml:id="tables-of-rates-of-productivity-pre-and-post-cutover" role="long-tables">
<doc:title">Tables of Rates of Productivity Pre and Post Cutover</doc:title>
<doc:table tabstyle="long">
<doc:title>Carousel Picking 2010-2011</doc:title>
<!--etc-->

===================XSL Stylesheet========================================

<xsl:template match="d:article">
<!--create a new page sequence
     1. process everything in the body with one page sequence
     2. process the appendix in its own page sequence
     3. process each table in its own page sequence
    -->
<xsl:variable name="id">
<xsl:call-template name="object.id"/>
</xsl:variable>

<xsl:call-template name="page.sequence">
<xsl:with-param name="master-reference">titlepage</xsl:with-param>
<xsl:with-param name="content">
<fo:block id="{$id}"
                   xsl:use-attribute-sets="component.titlepage.properties">
<xsl:call-template name="article.titlepage"/>
</fo:block>
<fo:block break-after="page"/>
</xsl:with-param>
</xsl:call-template>

<xsl:call-template name="make.article.tocs"/><!--my own template-->


<xsl:call-template name="page.sequence">
<xsl:with-param name="master-reference">body</xsl:with-param>
<xsl:with-param name="content">
<xsl:apply-templates
             select="*[not(self::bibliography)][not(self::doc:appendix)]"/>
</xsl:with-param>
</xsl:call-template>


<xsl:call-template name="page.sequence">
<xsl:with-param name="master-reference">body</xsl:with-param>
<xsl:with-param name="content">
<xsl:apply-templates select="doc:appendix"/>
</xsl:with-param>
</xsl:call-template>
<xsl:apply-templates select="descendant::doc:section[@role='long-tables']" mode="long"/>
</xsl:template>

<!--create pagemasters for the long tables-->
<xsl:template name="user.pagemasters">
<fo:page-sequence-master master-name="long.table">
<fo:repeatable-page-master-alternatives>
<fo:conditional-page-master-reference
                master-reference="body-first" page-position="first"/>

<fo:conditional-page-master-reference
                master-reference="body-even" odd-or-even="even"/>
<fo:conditional-page-master-reference
                master-reference="body-odd" odd-or-even="odd"/>
</fo:repeatable-page-master-alternatives>
</fo:page-sequence-master>
</xsl:template>

<!--long tables-->

<!--don't process the section in the appendix-->
<xsl:template match="doc:section[@role='long-tables']" />

<!--process the long-tables section separately.
 1. Wrap the section title and first table in a page sequence
 2. process the other tables in their own page sequence (see below)
<xsl:template match="doc:section[@role='long-tables']" mode="long">
<xsl:call-template name="page.sequence">
<xsl:with-param name="master-reference">long.table</xsl:with-param>
<xsl:with-param name="content">
<xsl:call-template name="my.section.title"/>
<xsl:apply-templates select="doc:table[1]" mode="long"/>
</xsl:with-param>
</xsl:call-template>
<xsl:for-each select="doc:table[position() &gt; 1]">
<xsl:call-template name="rest-of-tables"/>
</xsl:for-each>
</xsl:template>


<!--process the rest of the tables-->
<xsl:template name="rest-of-tables">
<xsl:call-template name="page.sequence">
<xsl:with-param name="master-reference">long.table</xsl:with-param>
<xsl:with-param name="content">
<xsl:apply-templates select="self::doc:table" mode="long"/>
</xsl:with-param>
</xsl:call-template>
</xsl:template>

<!--rewrite templates so you can process tables in mode="long"-->
<xsl:template match="d:table">
<xsl:call-template name="table-guts"/>
</xsl:template>

<xsl:template match="d:table[@tabstyle='long']" mode="long">
<xsl:call-template name="table-guts"/>
</xsl:template>


<!--copy template for section, rename it, and get rid of last apply-templates
This template simply makes a title-->
<xsl:template name="my.section.title">
<xsl:choose>
<xsl:when test="$rootid = @id or $rootid = @xml:id">
<xsl:call-template name="section.page.sequence"/>
<!--etc-->

<!--copy complete template for match="d:table"; rename template
I need to do this because I need to conditionally process tables-->
<xsl:template name="table-guts">
<xsl:if test="d:tgroup/d:tbody/d:tr
                |d:tgroup/d:thead/d:tr
                |d:tgroup/d:tfoot/d:tr">
<xsl:message terminate="yes">
<xsl:text>Broken table: tr descendent of CALS Table.</xsl:text>
<xsl:text>The text in the first tr is:&#10;</xsl:text>
<xsl:value-of
               select="(d:tgroup//d:tr)[1]"/>
</xsl:message>
<!--etc-->


<!--rewrite header.table. The default template puts the content in
a cell, and my content does not fit in a cell. Also, I need a separate
style for the header text that will serve as my "continued" label. The block goes beneath
rule for the header-->
<xsl:template name="header.table" >
<xsl:param name="pageclass" select="''"/>
<xsl:param name="sequence" select="''"/>
<xsl:param name="gentext-key" select="''"/>
<fo:block>
<xsl:call-template name="head.sep.rule">
<xsl:with-param name="pageclass" select="$pageclass"/>
<xsl:with-param name="sequence" select="$sequence"/>
<xsl:with-param name="gentext-key" select="$gentext-key"/>
</xsl:call-template>
<xsl:call-template name="header.content">
<xsl:with-param name="pageclass" select="$pageclass"/>
<xsl:with-param name="sequence" select="$sequence"/>
<xsl:with-param name="position" select="$direction.align.start"/>
<xsl:with-param name="gentext-key" select="$gentext-key"/>
</xsl:call-template>
</fo:block>
<xsl:call-template name="header.content">
<xsl:with-param name="pageclass" select="$pageclass"/>
<xsl:with-param name="sequence" select="$sequence"/>
<xsl:with-param name="position" select="'after-rule'"/>
<xsl:with-param name="gentext-key" select="$gentext-key"/>
</xsl:call-template>
</xsl:template>

<!--rewrite the header.content template to write the actual label for the table-->
<xsl:template name="header.content">
<xsl:param name="pageclass" select="''"/>
<xsl:param name="sequence" select="''"/>
<xsl:param name="position" select="''"/>
<xsl:param name="gentext-key" select="''"/>
<xsl:choose>
<xsl:when test="$pageclass = 'long.table' and $position = 'after-rule' and ($sequence = 'even' or $sequence = 'odd') ">
<fo:block space-before="20pt">
<xsl:apply-templates select="self::doc:table|descendant::doc:table[1]" mode="object.title.markup"/>
<xsl:text> (cont.)</xsl:text>
</fo:block>
</xsl:when>
</xsl:choose>
</xsl:template>

<!--ALL THIS JUST FOR 10 WORDS ON THE TOP OF EACH PAGE!-->




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






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