2. CALS tables
Prev | Chapter 3. Using HTML4 tables or CALS tables in your own custom schema | Next

## 2. CALS tables

The corresponding support code is contained in ``XXE_install_dir`/addon/config/common/docbook.jar`.

Procedure 3.2. Procedure

1. Add this snippet at the top of your CSS style sheet:

       @import url(xxe-config:common/css/cals_table.imp);

   If you use a namespace (e.g. `http://acme.com/ns`) for all the elements defined in your schema, including for table elements, add this snippet instead. This is not strictly needed but this will speed up the rendering of XML elements on screen:

       @namespace "http://acme.com/ns";
       @import url(xxe-config:common/css/cals_table.imp);

2. Add this snippet in your custom configuration for XXE. In the example below, you have chosen to prefix all the custom commands declared in your configuration using prefix "`my.`".

       <command name="my.tableEdit">
         <class>com.xmlmind.xmleditext.docbook.table.CALSTableEdit</class>
       </command>

   After that, you can reference the above table commands in your custom menu, custom tool bar or custom bindings. Example:

       <menu label="M_yDoc">
         <item label="Insert Column _Before"
               icon="xxe-config:common/icons/insertColumnBefore.png"
               command="my.tableEdit" parameter="insertColumnBefore"/>
         ...

3. Add this other snippet to your custom configuration. Doing so will allow you to resize a table column by dragging its column separator.

       <binding>
         <appEvent name="resize-table-column" />
         <command name="my.resizeTableColumn"
                  parameter="%{resizedColumn} %{columnCount}
                             %{oldColumnWidths} %{newColumnWidths}" />
       </binding>

       <command name="my.resizeTableColumn">
         <class>com.xmlmind.xmleditext.docbook.table.ResizeTableColumn</class>
       </command>

4. File `docbook.jar` also contains a validation hook which ensures that the `cols` attribute of elements `tgroup` and `entrytbl` is always set to a correct value before a DocBook document is validated and hence, saved to disk.

   Using commands `tableColumn` and `tableRow` also ensures that the `cols` attribute is up to date. However it is strongly recommended to add this validation hook to your custom configuration. This is done by adding this snippet:

       <validateHook name="cols_checker">
         <class>com.xmlmind.xmleditext.docbook.table.ValidateHookImpl</class>
       </validateHook>

Prev | Up | Next
1.1. HTML4 table editor command | Home | 2.1. CALS table editor command