benker.parsers.cals package¶
CALS Parser Implementation¶
This module can parse the tables (table
elements) of a CALS file.
Specifications and examples:
- The CALS DTD is available online in the OASIS web site: CALS Table Model Document Type Definition.
- An example of CALS table is available in Wikipedia: CALS Table Model
The main elements of a CALS table are:
table
: a table can contains one or severaltgroup
.titles
: table titles (not supported by the CALS parser)tgroup
: a portion of tablecolspec
: column specificationsspanspec
: spanning specifications (not supported by the CALS parser)thead
: table headercolspec
: header column specifications (not supported by the CALS parser)row
: table row (seetbody
)
tfoot
: table footercolspec
: footer column specifications (not supported by the CALS parser)row
: table row (seetbody
)
tbody
: table bodyrow
: table rowentry
: table entry which contains paragraphsentrytbl
: table entry which contains a table (not supported by the CALS parser)
An example of CALS table is available in Wikipedia: CALS Table Model
New in version 0.5.0.
-
class
benker.parsers.cals.
CalsParser
(builder, cals_ns=None, width_unit='mm', **options)¶ Bases:
benker.parsers.base_parser.BaseParser
CALS tables parser
-
get_cals_qname
(name)¶
-
parse_cals_colspec
(cals_colspec)¶ Parse a CALS-like
colspec
element.For instance:
<colspec colname="c1" colnum="1" colsep="1" rowsep="1" colwidth="30mm" align="center"/>
Parameters: cals_colspec (ElementType) – CALS-like colspec
element.
-
parse_cals_entry
(cals_entry)¶ Parse a
entry
element.Parameters: cals_entry (ElementType) – table entry Changed in version 0.5.1: The “vertical-align” style is built from the
@cals:valign
attribute.
-
parse_cals_row
(cals_row)¶ Parse a
row
element which containsentry
elements.This element may be in a
BLK`
Parameters: cals_row (ElementType) – table row Changed in version 0.5.1: The “vertical-align” style is built from the
@cals:valign
attribute.
-
parse_cals_table
(cals_table)¶ Parse a CALS
table
element.Parameters: cals_table (ElementType) – CALS table Element. Returns: State of the parser (for debug purpose). Changed in version 0.5.1: Add support for the
@cals:width
attribute (table width).
-
parse_cals_tgroup
(cals_tgroup)¶
-
parse_table
(cals_table)¶ Convert a
<table>
CALS element into table object.Parameters: cals_table (ElementType) – CALS element. Return type: benker.table.Table Returns: Table.
-
setup_table
(styles=None, nature=None)¶
-
transform_tables
(tree)¶
-
-
benker.parsers.cals.
ElementType
¶ alias of
lxml.etree._Element