Table generation with XSL?

Subject: Table generation with XSL?
From: "Chris Burn" <chrislists@xxxxxxxxxxx>
Date: Tue, 27 Jun 2000 12:24:17 +0100

I'm sure this problem must have come up before, but i can't find any
reference to it.

I have a dtd that specifies a table structure :

<!ELEMENT Table (HeadRow, Row*, Caption?)>
<!ELEMENT HeadRow (Cell+)>
<!ELEMENT Row (Cell+)>
<!ELEMENT Caption (#PCDATA)>

As you can see authors of an xml document that conforms to this dtd can have
as many Cell elements in any Rows as they require. So some Rows will have
more Cells than others. So my problem is outputting a html table that has
the same number of cells in each row to keep proper formating.

For example if the XML document is :

    <Cell>Heading one</Cell>
    <Cell>Heading two</Cell>
    <Cell>Cell one</Cell>
    <Cell>Cell two</Cell>
    <Cell>Cell three</Cell>
    <Cell>Cell Four</Cell>
  <Caption>this is the caption</Caption>

I would like the HTML out put to be :

      <td>Heading one</td>
      <td>Heading two</td>
    <td>Cell one</td>
    <td>Cell two</td>
    <td>Cell three</td>
    <td>Cell Four</td>
    <td colspan="3">this is the caption</td>

The way I was thinking of tackling this was :

maxCells = 0
For Each Row (including HeadRow)
  count = Count number of cells in current row
  if count > maxCells then maxCells = count
End For

For each Row
    For i = 1 to maxCells
      if current row current cell[i] content <> null then ouput content else
output &nbsp;
    end for
end for
<tr><td colspan="maxCells">output caption</td></tr>

But I can't think how to write this in XSL. Does anyone have any ideas? or
has this been solved before?

Many thanks,

Chris Burn
chris burn              p.   +44 (0)20 7961 0305
webmaster               f.   +44 (0)20 7961 0307
                        e.   cburn@xxxxxxxxxxxxxxxxxx      icq. 18567886

Do You Yahoo!?
Talk to your friends online with Yahoo! Messenger.

 XSL-List info and archive:

Current Thread