100. A generic, parametrizable, table editor command
Prev | Chapter 6. Commands written in the Java™ programming language | Next

## 100. A generic, parametrizable, table editor command

Parameter syntax:

    'insertColumnBefore'|'insertColumnAfter'|
    'cutColumn'|'copyColumn'|
    'pasteColumnBefore'|'pasteColumnAfter'|
    'deleteColumn'|
    'insertRowBefore'|'insertRowAfter'|
    'cutRow'|'copyRow'|
    'pasteRowBefore'|'pasteRowAfter'|
    'deleteRow'|
    'incrColumnSpan'|'decrColumnSpan'|
    'incrRowSpan'|'decrRowSpan'

This command may be used to edit any table conforming to a model vaguely resembling the HTML table model (table contains rows, themselves possibly contained in row groups, etc).

Prerequisite in terms of selection | Parameter | Description
--- | --- | ---
A cell or an element having a cell ancestor must be implicitly or explicitly selected. | `insertColumnBefore` | Insert a column before column containing specified cell.
`insertColumnAfter` | Insert a column after column containing specified cell.
`cutColumn` | Cut to the clipboard the column containing specified cell.
`copyColumn` | Copy to the clipboard the column containing specified cell.
`pasteColumnBefore` | Paste copied or cut column before column containing specified cell.
`pasteColumnAfter` | Paste copied or cut column after column containing specified cell.
`deleteColumn` | Delete the column containing specified cell.
A row must be explicitly selected. OR a cell or an element having a cell ancestor must be implicitly or explicitly selected. | `insertRowBefore` | Insert a row before row containing specified cell.
`insertRowAfter` | Insert a row before row containing specified cell.
`cutRow` | Cut to the clipboard the row containing specified cell.
`copyRow` | Copy to the clipboard the row containing specified cell.
`pasteRowBefore` | Paste copied or cut row before row containing specified cell.
`pasteRowAfter` | Paste copied or cut row after row containing specified cell.
`deleteRow` | Delete the row containing specified cell.
A cell or an element having a cell ancestor must be implicitly or explicitly selected. | `incrColumnSpan` | Increment the number of columns spanned by specified cell.
`decrColumnSpan` | Decrement the number of columns spanned by specified cell.
`incrRowSpan` | Increment the number of rows spanned by specified cell.
`decrRowSpan` | Decrement the number of rows spanned by specified cell.

Unlike the other commands contained in this reference, this command has no fixed name. It must be instantiated and given a name using a `command` configuration element (see Section 2, “command” in XMLmind XML Editor - Configuration and Deployment). It must also be parametrized using a simple specification contained in a `property` configuration element. See example below:

DITA `simpletable` example:

      <command name="dita.simpleTableEdit">
        <class>com.xmlmind.xmledit.cmd.table.GenericTableEdit</class>
      </command>

      <property name="dita.simpleTableEdit.tableSpecification">
        table=simpletable
        row=sthead strow
        cell=stentry
      </property>

| This creates an instance of generic, parametrizable, table editor command `com.xmlmind.xmledit.cmd.table.GenericTableEdit` called `dita.simpleTableEdit`.
| Because the table editor command is called `dita.simpleTableEdit`, a property called `dita.simpleTableEdit.tableSpecification` should exist too. The value of this property maps element names and attribute names to roles understood by the generic table editor command. Example 1: "`cell=th td`" specifies that an element with name `th` or `td` should be considered by the generic table editor as being a cell. Example 2: "`rowSpan=morerows+1`" specifies that attribute `morerows`, if found in cell elements, contains the number of additional rows spanned by the cell. In the above example, the fact that the `rowGroup=`, `rowSpan=` and `columnSpan=` lines are missing means that this table model does not have the concept of row groups and that there are no attributes which could be used to specify the number of rows and the number of columns spanned by a cell.

The syntax of a table specification is:

    spec -> table_spec row_group_spec? row_spec cell_spec
            row_span_spec? column_span_spec?

    table_spec -> table= element_name_list \n

    row_group_spec -> rowGroup= element_name_list \n

    row_spec -> row= element_name_list \n

    cell_spec -> cell= element_name_list \n

    row_span_spec -> rowSpan= attribute_name_list \n

    column_span_spec -> columnSpan= attribute_name_list \n

    element_name_list -> name {S name}*

    attribute_name_list -> name{+1}? {S name{+1}?}*

    name = non_qualified_name | {namespace_URI}local_part

table=

  Specifies the names of the elements which must be considered as being tables, that is, row group containers or, directly, row containers (like in HTML 3.2 tables).

rowGroup=

  Specifies the names of the elements which must be considered as being row groups, that is, row containers. May be omitted if not relevant.

row=

  Specifies the names of the elements which must be considered as being rows, that is, cell containers.

cell=

  Specifies the names of the elements which must be considered as being cells.

rowSpan=

  Specifies the names of the attributes which are used to specify the number of rows spanned by a cell. May be omitted if not relevant.

  Use `+1` to specify that the attribute contains an additional number of rows rather than the actual number of rows spanned by a cell.

columnSpan=

  Specifies the names of the attributes which are used to specify the number of columns spanned by a cell. May be omitted if not relevant.

  Use `+1` to specify that the attribute contains an additional number of rows rather than the actual number of rows spanned by a cell.

Example 1: the specification of an HTML table would be:

    table=table
    rowGroup=tbody thead tfoot
    row=tr
    cell=td th
    rowSpan=rowspan
    columnSpan=colspan

Example 2: the (partial) specification of a CALS table would be:

    table=tgroup entrytbl
    rowGroup=tbody thead tfoot
    row=row
    cell=entry
    rowSpan=morerows+1

The fact that the `columnSpan=` line is missing means that there is no attribute which could be used to specify the number of columns spanned by a cell.

Prev | Up | Next
99. XXE.saveAs | Home | Chapter 7. XPath functions