Re: [xsl] Need exactly 23 rows of output before next page

Subject: Re: [xsl] Need exactly 23 rows of output before next page
From: Clay Leeds <cleeds@xxxxxxxxxx>
Date: Fri, 13 Aug 2004 10:57:44 -0700
On Aug 12, 2004, at 12:55 PM, J.Pietschmann wrote:
Clay Leeds wrote:
I am re-creating a medical form which outputs exactly 23 rows per page (i.e., if there are 3 rows of data, 23 nodes are output; if there are 24 rows of data, 46 nodes are output, w page one having 23 rows of data, and page 2 having one row of data filled/22 rows empty, etc.).

Uhh, requirements straight out of hell...

Ahh the joys of medical billing! I've got another form to do too! Can you say "nudge"!? I've got table-row heights & table-column-widths out the yin yang!

You can compute the number of rows necessary to make the total number
a multiple of 26 using the mod operator, and fill the missing rows
using the wendell-piez-method or a recursive template:

<xsl:for-each select="DETAILLINE">
<fo:table-row height=".8cm" border=".5pt solid {$varColor}"
border-collapse="collapse" line-height="22pt">
<fo:table-cell text-align="center" border-bottom=".5pt solid {$varColor}">
<xsl:value-of select="DOSFROM/MM"/>
<xsl:variable name="detail-count" select="count(DETAILLINE)"/>
<xsl:if test="($detail-count mod 23) != 0">
<xsl:for-each select="//node()[position() <
(24 - ($detail-count mod 23))]">
... add empty rows ...

There's one error in there... I think '<' should be '&lt;':

  <xsl:for-each select="//node()[position() &lt;
   (24 - ($detail-count mod 23))]">

Unfortunately, with 4 DETAILLINEs, it outputs 49 pages. With 3 it outputs 48 pages, With 2 it outputs 46 pages. With 1 it outputs 45 pages. It looks like the 'baseline' number of pages seems to be related to 46... a multiple of 23... hmmm...

BTW, one other problem I've got is how to maintain the alternating row background-color... I'm using the following to specify bgcolor:

<xsl:attribute name="background-color"><xsl:choose><xsl:when test="(position() mod 2) = 0"><xsl:value-of select="$varAccentBGColor"/></xsl:when><xsl:otherwise><xsl:value-of select="$varNormalBGColor"/></xsl:otherwise></xsl:choose></xsl: attribute>

It works if I have an even number of DETAILLINEs w data. Of course, in this case position() is being used... If I use $detail-count instead bgcolor for empty rows stays the same... I need to come up with a solution which sets up the starting empty row bgcolor based on whether the number of DETAILLINEs is odd or even.

There should be multiple alternative, possibly more elegant
and/or correct formulations of the solution. If performance
is bad, switch to a recursive template (the XSLT FAQ has it


I looked in the XSLT FAQ, and couldn't come up with an intelligent enough wording for searching. Any ideas on a good query?

Web Maestro Clay

Current Thread