I decided to take a different approach with this problem.

I created an SVG image containing three vertical bars, and applied it as a
page background image.  Since my column count may vary, I also created
additional SVGs with different numbers of vertical bars, depending on the
column count.  My stylesheet then uses the column count to select the image,
i.e.

<xsl:attribute name="background-image">
 <xsl:text>url(../images/column_shading_</xsl:text>
 <xsl:value-of select="$column.count"/>
 <xsl:text>.svg)</xsl:text>
</xsl:attribute>

Kind of another hokey solution, but I can't figure out any better way to do
this.

Colin

On 7/20/07, Colin Shapiro <[EMAIL PROTECTED]> wrote:

Hi,

I have an XSL-FO document that uses a multi-column page layout.  I'd like
to shade the columns of the page with a background color - only the columns,
not the entire page.  See the attached image for a sketch of what I want the
output to look like.

Now, the simplest way to do this is to give the blocks containing the
running content a background color:

<fo:block background-color="gray">
  Blah blah blah blah...
</fo:block>

However, this only shades the columns to the point where the running
content stops.  Rather, I want the full length of the columns to be shaded
regardless of whether there is any running content.

I eventually came up with the following hokey solution.  It is a template
that calls itself recursively as many times as the number of columns, and
draws a block-container with absolute position for each column:

<xsl:param name="column.count" select="3"/>
<xsl:param name="column.gap" select="0.1in"/>
<xsl:param name=" page.width" select="8.5in"/>

<xsl:variable name="column.gap.pt">
  <xsl:call-template name="length-in-points">
    <xsl:with-param name="length" select="$column.gap"/>
  </xsl:call-template>
</xsl:variable>
<xsl:variable name="page.width.pt">
  <xsl:call-template name="length-in-points">
    <xsl:with-param name="length" select="$page.width"/>
  </xsl:call-template>
</xsl:variable>

<xsl:variable name="column.width.pt">
  <xsl:value-of select="($page.width.pt -
                         (($column.count - 1) *
                          $column.gap.pt))
                        div $column.count"/>
</xsl:variable>

<xsl:template name="column.shading">
  <xsl:param name="column.number" select="1"/>

  <xsl:if test="$column.number &lt;= $column.count">
    <fo:block-container absolute-position="absolute"
                        background-color="gray"
                        height="100%"
                        width="{$column.width}pt">
      <xsl:attribute name="left">
        <xsl:value-of select="($column.number - 1) *
                              ($column.width.pt +
                               $column.gap.pt)"/>
        <xsl:text>pt</xsl:text>
      </xsl:attribute>
      <fo:block/>
    </fo:block-container>

    <xsl:call-template name=" speclist.shading">
      <xsl:with-param name="column.number" select="$column.number + 1"/>
    </xsl:call-template>
  </xsl:if>
</xsl:template>

This actually worked if I called this template before other templates that
generate running content.  This template would draw the colored bars, then
the content would be placed on top of them.

However, since I switched from FOP to XEP, this no longer works.  The
colored bars are drawn as expected, but they are drawn right over the
running content, making the content invisible.

Any clue how I could be doing this in a better, saner way?  All I want to
do is shade the columns with a background color.  If anyone has an idea,
please let me know.  Thanks.


Reply via email to