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

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 UTC