How are tables structured in DITA XML?
November 10, 2023
|By Bryan Tipper
Table Structure in DITA XML
Tables are a valuable tool for organizing and presenting data in DITA XML. They provide a structured way to display information in rows and columns, making content more comprehensible. In DITA, tables are created using specific elements and attributes that define their structure and appearance.
Table Elements
DITA XML uses the following key elements for creating tables:
<table>
: This element is used to define the entire table structure. It may contain<title>
,<tgroup>
, and<tbody>
elements to further structure the table.<tgroup>
: The<tgroup>
element contains information about the table’s columns, column specifications, and other attributes.<tbody>
: The<tbody>
element is used to group rows of data within the table. It may contain one or more<row>
elements.<row>
: A<row>
element defines a single row within the table. It contains<entry>
elements that represent individual cells in the row.<entry>
: An<entry>
element represents a cell within a row. It contains the actual content of the cell, and attributes can be used to specify cell properties like alignment or width.
Example:
Here’s an example of how a table is structured in DITA XML:
<table id="sample_table">
<title>Sample Table</title>
<tgroup cols="3">
<colspec colname="col1" colwidth="1*"/>
<colspec colname="col2" colwidth="2*"/>
<colspec colname="col3" colwidth="1*"/>
<tbody>
<row>
<entry>Cell 1</entry>
<entry>Cell 2</entry>
<entry>Cell 3</entry>
</row>
<row>
<entry>Cell 4</entry>
<entry>Cell 5</entry>
<entry>Cell 6</entry>
</row>
</tbody>
</tgroup>
</table>
This example defines a table with three columns and two rows. It showcases the use of <table>
, <tgroup>
, <tbody>
, <row>
, and <entry>
elements to structure and populate the table.