W3C home > Mailing lists > Public > www-xsl-fo@w3.org > September 2003

Re: fo:table - how do you wrap around?

From: Mike Haarman <mhaarman@infinitecampus.org>
Date: Fri, 5 Sep 2003 15:16:45 -0500
Message-ID: <002801c373ea$a0c82a80$c70aa8c0@ic.org>
To: <www-xsl-fo@w3.org>

From: <michelleaiken-webboards9999@mailblocks.com>

>     <xsl:apply-templates select="Contact" />

From your instance, you mean Customer here.  Your Contact[sic] template always
begins a row.  You want to define two columns for your table:

<fo:table-column column-width="8cm"/>
<fo:table-column column-width="8cm"/>


and call one template to build a row and fill one cell and another to populate
the adjacent cell.  Apply templates on Customer like this:

<xsl:apply-templates select="Customer[position() mod 2 = 1]" mode="row"/>


which will fire this template:

<xsl:template match="Customer" mode="row">
  <fo:table-row>
    <fo:table-cell padding-start="4pt" text-align="left">
      <fo:block>
        <xsl:value-of select="@Name" />
      </fo:block>
      <xsl:apply-templates select="A1 | City | State | ZIP"/>
    </fo:table-cell>
    <xsl:apply-templates select="following-sibling::Customer[1]" mode="cell"/>
  </fo:table-row>
</xsl:template>


As you can see, after building the cell, this template apply-templates the next
Customer in line to fill the next cell, firing this template:

<xsl:template match="Customer" mode="cell">
  <fo:table-cell padding-start="4pt" text-align="left">
    <fo:block>
      <xsl:value-of select="@Name" />
    </fo:block>
    <xsl:apply-templates select="A1 | City | State | ZIP"/>
  </fo:table-cell>
</xsl:template>


> I can't just add another column because I need to loop through all the
> contacts in the xml file, and the second column would be the same as
> the first, just different data.

Not sure what you mean by this.  The above templates do what you say you want.

hth,

Mike
Received on Friday, 5 September 2003 16:17:26 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 3 October 2007 16:06:11 GMT