[xsl] Interesting Table loop

Subject: [xsl] Interesting Table loop
From: Spencer Tickner <spencertickner@xxxxxxxxx>
Date: Thu, 9 Jun 2005 14:33:37 -0700
Hi everyone,

Thanks in advance for the help. I have a table comming out of another
program, I have to turn it into a html table. Using xslt 2.0.

So far I have tried recursively calling 2 templates representing the
rows and column counts of tables. Of course, because these have no
reference to the original table (there is more than 1 in each
document), I cannot acurately grab the content. Here is the xml:

<Table xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/";
aid:table="table" aid:trows="3" aid:tcols="7">

<Cell aid:table="cell" aid:crows="1" aid:ccols="1"
aid:ccolwidth="192">

<qp_table_numeric_head>Performance Measure</qp_table_numeric_head>
 </Cell>

<Cell aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="50">


<qp_table_numeric_head>2001/02Actual</qp_table_numeric_head>
</Cell>

<Cell aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="50">


<qp_table_numeric_head>2002/03Actual</qp_table_numeric_head>
</Cell>

<Cell aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="50">


<qp_table_numeric_head>2003/04Actual</qp_table_numeric_head>
</Cell>

<Cell aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="50">


<qp_table_numeric_head>2004/05Target</qp_table_numeric_head>
 </Cell>

<Cell aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="50">


<qp_table_numeric_head>2004/05Actual</qp_table_numeric_head>
 </Cell>

<Cell aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="50">

            <qp_table_numeric_head>2004/05
Variance</qp_table_numeric_head>
</Cell>

<Cell aid:table="cell" aid:crows="1" aid:ccols="1"
aid:ccolwidth="192">

<qp_table_numeric_body>2.2Percentage of total
caseload.</qp_table_numeric_body>
 </Cell>

 <Cell aid:table="cell" aid:crows="1" aid:ccols="1"
aid:ccolwidth="50">

<qp_table_numeric_data>28.4%</qp_table_numeric_data>
</Cell>

<Cell aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="50">

    <qp_table_numeric_data>35.4%</qp_table_numeric_data>
</Cell>

<Cell aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="50">


<qp_table_numeric_data>43.3%</qp_table_numeric_data>
</Cell>

 <Cell aid:table="cell" aid:crows="1" aid:ccols="1"
aid:ccolwidth="50">

<qp_table_numeric_data>46.0%</qp_table_numeric_data>
</Cell>

<Cell aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="50">

      <qp_table_numeric_data>49.8%</qp_table_numeric_data>
</Cell>

<Cell aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="50">

       <qp_table_numeric_data>+3.8%</qp_table_numeric_data>
</Cell>

<Cell aid:table="cell" aid:crows="1" aid:ccols="7">
<qp_table_numeric_footnote>Source: Planning.</qp_table_numeric_footnote>
</Cell>

 </Table>


So I here's the pseudo xslt I figure should make the table.

<xsl:template match="table"/>
  <!-- Loop until you get to the end of @aid:trows -->
  <tr>
      <!-- Loop until you get to the end of @aid:tcols -->
        <td><xsl:apply-templates select="Cell"/></td>
       <!-- End col loop -->
  </tr>
  <!-- End row loop -->
</xsl:template>

I'm kinda perplexed by how to do this, any suggestions, or if another
way jumps out at you, I'd be very gratefull for the advice. As a side
note, @aid:ccols in the Cell attribute seem to represent colspan.

Spencer

Current Thread