Tables
CXML tables are loosely based on the OASIS Exchange Table Model.
The top-level element is <table>. <table> elements can be placed inside paragraphs. A table nested within a paragraph overrides the inherited (external) paragraph style of a master table.
New in CXML 3.4
<table> now support @author and @dateTime.
<table> has eight attributes:
| Attribute | Value | Description |
|---|---|---|
| type | string | The name of the Adobe InDesign table style. Tables without a type or with an unknown type will use [Basic Table] as a fallback. |
| id | string | The unique ID of the table. |
| width | string | The width of the table. Width is either a fixed (absolute) value, percentage, or proportional width. Labels for fixed values are case insensitive. Allowed labels are:
For more information, see note from the Oasis Exchange table specification below. When a percentage or proportional width is specified, the effective table width in Adobe InDesign is reduced by the sum of half the left and right table border stroke, and the text frame insets and paragraph indents. |
| condition | string | The name of the condition; for more information, see Conditions. |
| style | string | Set a local style override to customise the appearance of the table border and font. |
| status | added changed deleted | Indicates the modification status of the table. |
| author NEW | string | The author of the tracked change. |
| dateTime NEW | ISO 8601 datetime string | The date and time of the tracked change (2024-01-09T14:37:00Z). |
<table type="Films">
<tgroup cols="2">
<colspec colname="1" />
<colspec colname="2" />
<thead>
<row>
<entry><p>Film</p></entry>
<entry><p>Year</p></entry>
</row>
</thead>
<tbody>
<row>
<entry><p>Monty Python and the Holy Grail</p></entry>
<entry><p>1975</p></entry>
</row>
<row>
<entry><p>Monty Python's Life of Brian</p></entry>
<entry><p>1979</p></entry>
</row>
<row>
<entry><p>Monty Python's The Meaning of Life</p></entry>
<entry><p>1983</p></entry>
</row>
</tbody>
</tgroup>
</table>A table with tracked changes:
<table type="Knights" status="added" author="Terry Gilliam" dateTime="1975-04-05T09:00:00Z">
<tgroup cols="2">
<colspec colname="1" />
<colspec colname="2" />
<tbody>
<row>
<entry><p>Sir Lancelot</p></entry>
<entry><p>The Brave</p></entry>
</row>
<row>
<entry><p>Sir Robin</p></entry>
<entry><p>The Not-Quite-So-Brave-as-Sir-Lancelot</p></entry>
</row>
</tbody>
</tgroup>
</table>Note
The Oasis Exchange table specification states:
Either proportional measure of the form _number*_, e.g., "5*" for
5 times the proportion, or "*" (which is equivalent to "1*"); fixed
measure, e.g., “2pt” for 2 point, “3pi” for 3 pica. (Mixed measure,
e.g., 2*+3pt, while allowed in the full CALS table model, is not
supported in this Exchange model.) Coefficients are positive integers
or fixed point numbers; for fixed point numbers, a leading (possibly 0)
integer part is required, and implementations should support at least
2 decimal places. A value of "" [the null string] is treated as a
proportional measure of "1*".Columns
A table (<table>) contains a table group (<tgroup>), which contains columns (<colspec>). <colspec> elements are specified in a left-to-right column order and define column information for each column in a <tgroup>.
<tgroup> has one attribute:
| Attribute | Value | Description |
|---|---|---|
| cols | integer | Required. Specifies the number of columns that apply to the table header (<thead>), table rows (<tbody>), and table footer (<tfoot>). The value of the @cols attribute must match the count of the columns (<colspec>) and vice versa. |
Note
CXML 3.2 is the last version to support multiple <tgroup>s; this use is deprecated as Adobe InDesign does not fully support multiple <tgroup>s.
<colspec> has four attributes:
| Attribute | Value | Description |
|---|---|---|
| colname | string | Required. A unique name for the column; used when merging cells using entry@namest and entry@nameend . |
| align | left center right justify justifyLeft justifyCenter justifyRight justifyFull | Specifies the horizontal alignment of the column. This value overrides the horizontal alignment of any Adobe InDesign paragraph style within the column. However, this attribute is also overridden by any <entry> within the column that has its own align attribute. |
| rotate | 0 90 180 270 | The rotation of the content. This value overrides the text rotation of the Adobe InDesign cell styles within this column. Notes
|
| colwidth | string | The width of the column.@colwidth is either a fixed (absolute) value and label, proportional width, or percentage measurement. Percentage measurements are included for legacy support.Labels for fixed values are case insensitive. Allowed labels are:
For more information, see note from the Oasis Exchange table specification above. Notes If the sum of the @colwidth for all columns does not equal table@width, then table@width overrides colspec@colwidth. |
These @colwidth values are all valid:
<table>
<tgroup cols="8">
<colspec colname="1" colwidth="25" />
<colspec colname="2" colwidth="40pt" />
<colspec colname="3" colwidth="6.35cm" />
<colspec colname="4" colwidth="31.75mm" />
<colspec colname="5" colwidth="3.5pi" />
<colspec colname="6" colwidth="1in" />
<colspec colname="7" colwidth="1*" />
<colspec colname="8" colwidth="2*" />
</tgroup>
</table>Rows
The table header (<thead>) may contain any number of <row> elements.
The table body (<tbody>) must contain at least one <row> element (or the table won't work in Adobe InDesign).
The table footer (<tfoot>) may contain any number of <row> elements.
The <row> element contains table cell (<entry>) elements for each table cell.
These rows are all valid:
<table>
<tgroup cols="3">
<thead>
<row>
<entry><p>Song</p></entry>
<entry><p>Composer</p></entry>
<entry><p>Scene</p></entry>
</row>
</thead>
<tbody>
<row>
<entry><p>Always Look on the Bright Side of Life</p></entry>
<entry><p>Eric Idle</p></entry>
<entry><p>Monty Python's Life of Brian</p></entry>
</row>
<row>
<entry><p>The Lumberjack Song</p></entry>
<entry><p>Terry Jones and Michael Palin</p></entry>
<entry><p>And Now for Something Completely Different</p></entry>
</row>
<row>
<entry><p>Galaxy Song</p></entry>
<entry><p>Eric Idle</p></entry>
<entry><p>Monty Python's The Meaning of Life</p></entry>
</row>
</tbody>
</tgroup>
</table>Cells
The <entry> element is used to create table cells.
<entry> has several attributes:
| Attribute | Value | Description |
|---|---|---|
| type | string | Specifies the name of an Adobe InDesign cell style. Cell styles affect cell border stroke and color, background color, and cell insets. |
| namest | string | Specifies the starting colspec@colname when horizontally merging cells. |
| nameend | string | Specifies the ending colspec@colname when horizontally merging cells. |
| morerows | integer | Specifies the number of additional rows when vertically merging cells. Cannot extend beyond <thead> into <tbody> , or <tbody> into <tfoot> . |
| valign | top middle bottom justify | Specifies the vertical alignment for the cell contents. This value overrides the vertical justification of any Adobe InDesign cell style. |
| align | left center right justify justifyLeft justifyCenter justifyRight justifyFull | Specifies the horizontal alignment for the cell contents. This value overrides the parent colspec@align attribute and the horizontal alignment of any Adobe InDesign paragraph style within the cell. |
| rotate | 0 90 180 270 | Specifies the rotation (clockwise) of the cell contents. This value overrides the text rotation within any Adobe InDesign cell style. Notes
|
| style | string | Set a local style override to customise the appearance of the table cell background, page break, border, and font. |
Table cell styles
You can style table cells in two ways: via cell styles (entry@type) or local overrides (entry@style).
Cell styles (via entry@type) alter the border stroke and color, the background fill, and cell insets.
A styled table cell:
<entry type="Green">
<p>It's only a wafer-thin mint, sir...</p>
</entry>A table cell with local style overrides:
<entry style="border-left:4px dotted rgb(125,15,15);
border-right:4px solid #ccFF14;
background: namedColor(Pantone 353C) 45%">Cell merging
Column spans are accomplished using entry@namest and entry@nameend. The value of each of these attributes must correspond to a value in colspec@colname.
Row spans are accomplished via entry@morerows. The @morerows attribute is an integer count of the extra rows the cell covers (not the total number of rows).
If you wanted to represent this table in CXML:
| Date | Consumer price index | Private consumption chain price index | Other consumer price measures | |||||
|---|---|---|---|---|---|---|---|---|
| All groups | Excluding volatile items | Market prices excluding volatile items | Based on seasonally adjusted quarterly price changes | |||||
| Goods | Services | Total | Weighted median | Trimmed mean | ||||
| 2003/4 | ||||||||
| Dec | 2.4 | 2.4 | 1.6 | 2.2 | 1.8 | 1.0 | 2.8 | 2.5 |
Then, your CXML would look like this:
<table type="CPI">
<tgroup cols="9">
<colspec colname="1" />
<colspec colname="2" />
<colspec colname="3" />
<colspec colname="4" />
<colspec colname="5" />
<colspec colname="6" />
<colspec colname="7" />
<colspec colname="8" />
<colspec colname="9" />
<tbody>
<row>
<entry morerows="2" namest="1" align="right" valign="middle">
<p>Date</p>
</entry>
<entry nameend="6" namest="2" align="center" valign="middle">
<p>Consumer price index</p>
</entry>
<entry morerows="2" namest="7" align="center" valign="middle">
<p>Private consumption chain price index</p>
</entry>
<entry nameend="9" namest="8" align="center" valign="middle">
<p>Other consumer price measures</p>
</entry>
</row>
<row>
<entry morerows="1" namest="2" align="center" valign="middle">
<p>All groups</p>
</entry>
<entry morerows="1" namest="3" align="center" valign="middle">
<p>Excluding volatile items</p>
</entry>
<entry nameend="6" namest="4" align="center" valign="middle">
<p>Market prices excluding volatile items</p>
</entry>
<entry nameend="9" namest="8" align="center" valign="middle">
<p>Based on seasonally adjusted quarterly price changes</p>
</entry>
</row>
<row>
<entry namest="4" align="center" valign="middle">
<p>Goods</p>
</entry>
<entry namest="5" align="center" valign="middle">
<p>Services</p>
</entry>
<entry namest="6" align="center" valign="middle">
<p>Total</p>
</entry>
<entry namest="8" align="center" valign="middle">
<p>Weighted median</p>
</entry>
<entry namest="9" align="center" valign="middle">
<p>Trimmed mean</p>
</entry>
</row>
<row>
<entry namest="1" align="right" valign="middle">
<p>2003/4</p>
</entry>
<entry nameend="9" namest="2" align="center" valign="middle"></entry>
</row>
<row>
<entry namest="1" align="right" valign="middle">
<p>Dec</p>
</entry>
<entry namest="2" align="center" valign="middle">
<p>2.4</p>
</entry>
<entry namest="3" align="center" valign="middle">
<p>2.4</p>
</entry>
<entry namest="4" align="center" valign="middle">
<p>1.6</p>
</entry>
<entry namest="5" align="center" valign="middle">
<p>2.2</p>
</entry>
<entry namest="6" align="center" valign="middle">
<p>1.8</p>
</entry>
<entry namest="7" align="center" valign="middle">
<p>1.0</p>
</entry>
<entry namest="8" align="center" valign="middle">
<p>2.8</p>
</entry>
<entry namest="9" align="center" valign="middle">
<p>2.5</p>
</entry>
</row>
</tbody>
</tgroup>
</table>A table with tracked changes: