Formex4 Builder

This module can construct a Formex4 table from an instance of type Table.

Formex describes the format for the exchange of data between the Publication Office and its contractors. In particular, it defines the logical markup for documents which are published in the different series of the Official Journal of the European Union.

This builder allow you to convert Word document tables into Formex4 tables using the Formex4 schema (formex-05.59-20170418.xd).

Specifications and examples:

  • The Formex4 documentation and schema is available online in the Publication Office: Formex Version 4.

  • An example of Formex4 table is available in the Schema documentation: TBL

class benker.builders.formex4.Formex4Builder(detect_titles=False, **options)

Bases: benker.builders.base_builder.BaseBuilder

Formex4 builder used to convert tables into TBL elements according to the TBL Schema

build_cell(row_elem, cell, row)

Build the Formex4 <CELL> element.

Formex4 attributes:

  • @COL The mandatory COL attribute is used to specify in which column the cell is located.

  • @COLSPAN When a cell in a row ‘A’ must be linked to a group of cells in the same row, the first CELL element of this group has to provide the COLSPAN attribute. The value of the COLSPAN attribute is the number of cells in the group. The COL attribute of the first cell indicates the number of the first column in the group.

    The use of the COLSPAN attribute is only allowed to relate the value of a cell in several columns within the same row. Its value must be at least equal to ‘2’.

  • @ROWSPAN When a cell in column ‘A’ is linked to a cell in row ‘B’ located just below row ‘A’, the CELL element of this single cell must provide the ROWSPAN attribute. The value of the ROWSPAN attribute is equal to the number of cells in the group. The CELL element relating to the single cell must be placed within the first ROW element in the group. The ROW elements corresponding to the other rows in the group may not contain any CELL elements for the column containing the single cell ‘A’.

    The use of the ROWSPAN attribute is only authorised to relate the value of a cell in several rows. Its value must be at least equal to ‘2’.

  • @ACCH If the group of related cells is physically delimited by a horizontal brace, this symbol must be marked up using the ACCH attribute.

  • @ACCV If the group of related cells is physically delimited by a vertical brace, this symbol must be marked up using the ACCV attribute.

  • @TYPE The TYPE attribute of the CELL element is used to indicate locally the type of contents of the cells. It overrides the value of the TYPE attribute defined for the row (ROW) which contains the cell.

Parameters

Changed in version 0.4.4: Modification of the Formex4 builder to better deal with empty cells (management of <IE/> tags).

build_corpus(tbl_elem, table)

Build the Formex4 <CORPUS> element.

Parameters
  • tbl_elem (etree._Element) – Parent element: <TBL>.

  • table (benker.table.Table) – Table

Changed in version 0.4.3: If this option detect_titles is enable, a title will be generated if the first row contains an unique cell with centered text.

build_row(corpus_elem, row)

Build the Formex4 <ROW> element.

Formex4 attributes:

  • @TYPE The TYPE attribute indicates the specific role of the row in the table. The allowed values are:

    • ALIAS: if the row contains aliases. Such references may be used when the table is included on several pages of a publication. The references are associated to column headers on the first page and are repeated on subsequent pages.

    • HEADER: if the row contains cells which may be considered as a column header. This generally occurs for the first row of a table.

    • NORMAL: if most of the cells of the row contain ‘simple’ or ‘normal’ data. This is the default value.

    • NOTCOL: if the cells of the row contain units of measure relating to subsequent rows.

    • TOTAL: if the row contains data which could be considered as ‘totals’.

    Note that this TYPE attribute is also provided for the cells (CELL), which could be used to override the value defined for the row. On the other hand, ‘NORMAL’ is the default value, so it is necessary to specify the TYPE attribute value in each cell of a row which has a specific type in order to avoid the default overriding (see the first row of the example below).

Parameters
  • corpus_elem (etree._Element) – Parent element: <CORPUS>.

  • row (benker.table.RowView) – The row.

build_tbl(table)

Build the Formex4 <TBL> element.

Formex4 attributes:

  • @NO.SEQ This mandatory attribute provides a sequence number to the table. This number represents the order in which the table appears in the document.

  • @CLASS The CLASS attribute is mandatory and is used to specify the type of data contained in the table. The allowed values are:

    • GEN: if the table contains general data (default value),

    • SCHEDULE: if it is a schedule,

    • RECAP: if it is a synoptic table.

    These two last values are only used for documents related to the general budget.

  • @COLS This mandatory attribute provides the actual number of columns of the table.

  • @PAGE.SIZE The PAGE.SIZE attribute takes one of these values:

    • DOUBLE.LANDSCAPE: table on two A4 pages forming an A3 landscape page,

    • DOUBLE.PORTRAIT: table on two A4 pages forming an A3 portrait page,

    • SINGLE.LANDSCAPE: table on a single A4 page in landscape,

    • SINGLE.PORTRAIT: table on a single A4 page in portrait (default).

Parameters

table (benker.table.Table) – Table

Returns

The newly-created <TBL> element.

build_title(tbl_elem, row)

Build the table title using the <TITLE> element.

For instance:

<TITLE>
  <TI>
    <P>Table IV</P>
  </TI>
</TITLE>
Parameters
  • tbl_elem (etree._Element) – Parent element: <TBL>.

  • row (benker.table.RowView) – The row which contains the title.

Changed in version 0.4.4: Modification of the Formex4 builder to better deal with empty cells (management of <IE/> tags).

finalize_tree(tree)

Finalize the resulting tree structure: calculate the @NO.SEQ values: sequence number of each table.

Parameters

tree (etree._ElementTree) – The resulting tree.

generate_table_tree(table)

Build the XML table from the Table instance.

Parameters

table (benker.table.Table) – Table

Returns

Table tree

benker.builders.formex4.revision_mark(name, attrs)