Forum Bugs

"error: table header cell has no associated subcells" despite scope=colgroup

natevw
When generating with `--pdf-profile=PDF/UA-1` option, I am getting

prince: error: table header cell has no associated subcells


which I have traced down to the first row of a set of nested headers in my HTML.


By nested headers I mean like:

       | appendages        | nutritional intake     |
       |-------------------|------------------------|
       | arms       | legs | breakfast  | dinner    |
|------|------------|------|------------|-----------|
| dogs | 0          | 4    | kibble     | leftovers |
| cats | 0          | 4    | early bird | mouse     |
| kids | 2          | 2    | waffles    | casserole |



Following the advice at https://developer.mozilla.org/en-US/docs/Learn/HTML/Tables/Advanced#the_scope_attribute I added some initially missing `scope="colgroup"` attributes which I believe give it all the required semantic structure those headings should need.

But the following snippet still triggers the original Prince error above, ultimately leading to an additional

error: not identifying as PDF/UA-1 due to problems in structure tree


unless I comment out/remove the first header row!

<thead>
  <tr> <!-- if I remove this row the error goes away -->
    <td rowspan="2" class="empty-spot"></td>
    <th colspan="2" scope="colgroup">appendages</th>
    <th colspan="2" scope="colgroup">nutritional intake</th>
  </tr>
  <tr>
    <th>arms</th>
    <th>legs</th>
    <th>breakfast</th>
    <th>dinner</th>
  </tr>
</thead>


This seems like a bug to me, no? Or are my table semantics actually still incorrect?
natevw
In search of a workaround short of entirely "unheadering" my colgroup headers, I've gone as far as

<table><colgroup>
  <col />
  <col span="2" />
  <col span="2" />
</colgroup><thead>
  <tr>
    <td rowspan="2" class="empty-spot"></td>
    <th colspan="2" scope="colgroup" id="ghead1">appendages</th>
    <th colspan="2" scope="colgroup" id="ghead2">nutritional intake</th>
  </tr>
  <tr>
    <th headers="ghead1">arms</th>
    <th headers="ghead1">legs</th>
    <th headers="ghead2">breakfast</th>
    <th headers="ghead2">dinner</th>
  </tr>
</thead><tbody>
  <tr>
    <th>dogs</th>
    <td>0</td><td>4</td>
    <td>kibble</td><td>leftovers</td>
  </tr><tr>
    <th>cats</th>
    <td>0</td><td>4</td>
    <td>bird</td><td>mouse</td>
  </tr><tr>
    <th>kids</th>
    <td>2</td><td>2</td>
    <td>waffles</td><td>casserole</td>
  </tr>
</tbody></table>



Specifically:

1. Retained the scope=colgroup as before
2. Added explicit colgroup/col elements in case those are necessary?
3. Added `headers=` attribute to directly target the header cells causing the "no associated subcells" error

But none of this has avoided the error, and Prince will not generate PDF/UA-1 on account of this :-(

Edited by natevw

wangp
We need better diagnostics when things go wrong. Fortunately, the table matches a structure that is known to work:
<table>
  <tr>
    <td rowspan="2"></td>
    <th colspan="2" scope="colgroup">appendages</th>
    <th colspan="2" scope="colgroup">nutritional intake</th>
  </tr>
  <tr>
    <th scope="col">arms</th>
    <th scope="col">legs</th>
    <th scope="col">breakfast</th>
    <th scope="col">dinner</th>
  </tr>
  <tr>
    <th scope="row">dogs</th>
    <td>0</td>
    <td>4</td>
    <td>kibble</td>
    <td>leftovers</td>
  </tr>
  <tr>
    <th scope="row">cat</th>
    <td>0</td>
    <td>4</td>
    <td>bird</td>
    <td>mouse</td>
  </tr>
  <tr>
    <th scope="row">kids</th>
    <td>2</td>
    <td>2</td>
    <td>waffles</td>
    <td>casserole</td>
  </tr>
</table>
natevw
Thank you very much! This worked and also cleared up the "not identifying as PDF/UA-1" error.

So the only necessary workaround is, in a situation where rowgroup/colgroup scope(s) need to be specified, then to also add explicit `scope=` attributes to *all* the <th> elements i.e. including the usually-automatic col/row ones.