[xsl] Borders on column groups

Subject: [xsl] Borders on column groups
From: Gustaf Liljegren <gustafl@xxxxxxxxxx>
Date: Fri, 07 Jun 2002 00:29:17 +0200
Hello all,

Thanks Joerg and David, for solving the "Borders on row groups" problem.
Now I have a question related to column groups, which seem to be much
harder. For others, I quote the first <p> from last message:

<quote>I constructed a subset of the table model in XHTML 1.1. I like the
frame
(border around table) and rules (borders inside table) attributes, and want
to make them work in an XSL-FO stylesheet. The rules attribute can be set
to "groups", which means there will be borders only to separate column and
row groups.</quote>

Now I'm doing the vertical rules inside the table. At the setting
rules="groups" I want to have border-right on all last <col> in <colgroup>
elements, except on the last group. I know <col> may have a span attribute
too, but I removed that option in my subset, and no stand-alone <colgroup>
elements are allowed either. So, a column group consists of one or more
<col> elements in a <colgroup> element.

The XML structure looks like this:

  <table frame="none" rules="groups" width="100%">
    <caption>frame="none" rules="groups"</caption>
    <colgroup>
      <col width="*"/>
    </colgroup>
    <colgroup>
      <col width="*"/>
      <col width="*"/>
      <col width="*"/>
    </colgroup>
    <thead>
      <tr>
        <th></th>
        <th>South-East Asia</th>
        <th>Scandinavia</th>
        <th>Axis of Evil</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <th>1998</th>
        <td>16000</td>
        <td>15000</td>
        <td>14000</td>
      </tr>
      <tr>
        <th>1999</th>
        <td>18000</td>
        <td>17000</td>
        <td>14000</td>
      </tr>
    </tbody>
    <tbody>
      <tr>
        <th>2000</th>
        <td>21000</td>
        <td>20000</td>
        <td>14000</td>
      </tr>
      <tr>
        <th>2001</th>
        <td>24000</td>
        <td>23000</td>
        <td>14000</td>
      </tr>
    </tbody>
  </table>

In this case, the result should be a vertical rule after the first column.

I imagine that the border-right should be drawn if: the <table> ancestor's
<col> element that has the same number (based on document order) as the
position of the current element in the <tr>, and if this <col> element is
part of a <colgroup> element, and the <colgroup> is not the last one. I've
no idea how to say that in XPath!

I prepared an <xsl:if> element that I hope someone can help me fill in:

  <xsl:if test="ancestor::table[@rules='groups']">
    <xsl:if test=" ">
      <xsl:attribute name="border-right">
        <xsl:value-of select="$border"/>
      </xsl:attribute>
    </xsl:if>
  </xsl:if>

Gustaf


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread