Purpose
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.
Installation
Add this line to your application’s Gemfile:
gem 'oasis-etm'
And then execute:
bundle install
Or install it yourself as:
gem install oasis-etm
Usage
Basic example
require '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_xml
XML schema
The 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>
Development
Test files
spec/fixtures/native/docbook_example.xml
spec/fixtures/niso-jats/niso-jats-table-wrap.xml
-
https://jats.nlm.nih.gov/options/OASIS/tag-library/19990315/element/oasis-table.html This is to test the OASIS exchange table model when it is namespaced from another location.
spec/fixtures/isosts/isosts_tables.cals.{nn}.xml
-
Tables extracted from https://www.iso.org/schema/isosts/cals/test/isosts_tables.cals.xml. This is to test the OASIS exchange table model when it is namespaced from another location.
Contributing
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
License and Copyright
This project is licensed under the BSD 2-clause License. See the LICENSE.md file for details.
Copyright Ribose.