The OASIS ETM format is a simple XML format for representing tables for exchange. It is used in the DocBook and NISO JATS standards.
This library provides a Ruby implementation of the OASIS Technical Resolution TR 9503:1995.
-
Full implementation of the OASIS Exchange Table Model TR 9503:1995
-
Intentionally excludes CALS table features not part of the Exchange subset (like
tfoot) -
XML serialization and deserialization
-
Validation of attribute values
-
Support for all Exchange Table Model elements:
-
table -
tgroup -
colspec -
thead -
tbody -
row -
entry
-
Add this line to your application’s Gemfile:
gem 'oasis-etm'And then execute:
bundle installOr install it yourself as:
gem install oasis-etmrequire 'oasis-etm'
# Parse an ETM XML file
table = Oasis::Etm::Table.from_xml(File.read('table.xml'))
# Access table attributes
puts table.frame
puts table.colsep
puts table.rowsep
# Access table content
table.tgroups.each do |tgroup|
tgroup.colspecs.each do |colspec|
puts "Column #{colspec.colnum}: #{colspec.colwidth}"
end
end
# Create a new table
table = Oasis::Etm::Table.new(
frame: 'all',
colsep: 1,
rowsep: 1,
tgroups: [
Oasis::Etm::Tgroup.new(
cols: 3,
colspecs: [
Oasis::Etm::Colspec.new(colnum: 1, colwidth: '1*'),
Oasis::Etm::Colspec.new(colnum: 2, colwidth: '2*'),
Oasis::Etm::Colspec.new(colnum: 3, colwidth: '1*')
]
)
]
)
# Convert to XML
xml = table.to_xmlThe OASIS ETM format follows this basic structure:
<table frame="all" colsep="1" rowsep="1">
<title>Sample Table</title>
<tgroup cols="3">
<colspec colnum="1" colwidth="1*"/>
<colspec colnum="2" colwidth="2*"/>
<colspec colnum="3" colwidth="1*"/>
<thead>
<row>
<entry>Header 1</entry>
<entry>Header 2</entry>
<entry>Header 3</entry>
</row>
</thead>
<tbody>
<row>
<entry>Cell 1</entry>
<entry>Cell 2</entry>
<entry>Cell 3</entry>
</row>
</tbody>
</tgroup>
</table>The round-trip tests in spec/oasis/etm_spec.rb verify that XML files can be
parsed into Ruby objects and then serialized back to XML without loss of
semantic content.
|
Note
|
These tests use the Canon gem for XML
comparison with the spec_friendly profile, which ignores non-semantic
differences like attribute ordering and formatting.
|
Round-trip conversion testing ensures that:
-
The parser correctly interprets all supported XML elements and attributes
-
The serializer correctly produces XML that preserves semantic meaning
-
The model accurately represents the Exchange Table Model structure
The round-trip tests use real-world XML files from various standards:
| Fixture | Source | Purpose |
|---|---|---|
|
Tests native ETM format (no namespace prefix) |
|
|
Tests ETM with standard OASIS namespace ( |
|
|
Tests ETM with alternative namespace URIs and CALS extensions |
The test fixtures contain elements and attributes that are not part of the Exchange Table Model specification but appear in real-world documents. The round-trip tests handle these as follows:
Some fixtures contain elements from other namespaces that the model does not support. These are removed before parsing to focus on Exchange Table Model compatibility:
| Element | Fixture |
|---|---|
|
|
|
|
|
|
The Exchange Table Model has evolved over time, resulting in multiple namespace URIs that refer to the same schema:
| Namespace URI | Used By |
|---|---|
Canonical OASIS Exchange Table namespace |
|
|
ISO ISOSTS format |
|
Legacy FPI (Formal Public Identifier) - used as namespace URI in older documents |
The model accepts all three namespace variants via uri_aliases for parsing.
When serializing, the model uses the canonical namespace URI for output.
The Exchange Table Model predates XML Schema and uses SGML-influenced attribute values:
| Values | Example |
|---|---|
Integers (XML Schema) |
|
Legacy strings (SGML) |
|
The model accepts both integer (0, 1) and string ("yes", "no") values
for colsep, rowsep, and pgwide attributes to ensure backward
compatibility with legacy documents.
Round-trip tests catch regressions that might otherwise go unnoticed:
-
A missing attribute mapping would cause data loss on serialization
-
An incorrect type coercion would change attribute values
-
Namespace handling bugs would produce invalid XML
-
Changes to element ordering could break downstream consumers
By testing with real-world fixtures from established standards, we ensure compatibility with the broader XML table ecosystem.
Bug reports and pull requests are welcome. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.
-
Fork it
-
Create your feature branch (
git checkout -b my-new-feature) -
Commit your changes (
git commit -am 'Add some feature') -
Push to the branch (
git push origin my-new-feature) -
Create new Pull Request
This project is licensed under the BSD 2-clause License. See the LICENSE.md file for details.
Copyright Ribose.