Skip to main content

A lightweight library for working with Akoma Ntoso Act documents

Project description

Cobalt is a lightweight Python library for working with Akoma Ntoso documents. It makes it easy to work with Akoma Ntoso documents, metadata and FRBR URIs.

It is lightweight because most operations are done on the XML document directly without intermediate objects. You still need to understand how Akoma Ntoso works.

Read the full documentation at


Install using:

$ pip install cobalt

Use it like this:

>>> from cobalt import Act
>>> act = Act()
>>> act.title = "Act 10 of 1980"
>>> act.frbr_uri = "/za/act/1980-05-03/10"
>>> act.frbr_uri.year
>>> act.frbr_uri.number
>>> act.frbr_uri.doctype
>>> print act.to_xml()
[ lots of xml ]


  1. Clone the repo

  2. Install development dependencies:

    pip install -e .[dev]
  3. Make your changes

  4. Run tests:

    nosetests && flake8 cobalt
  5. Send a pull request

Releasing a New Version

  1. Run the tests!

  2. Update VERSION appropriately

  3. Update the Change Log section in README.rst

  4. Commit and tag:

    git tag vX.X.X
    git push -u origin --tags
  5. Build artefacts:

    rm -rf build dist && python sdist bdist_wheel
  6. Upload to PyPI:

    twine upload dist/*

Change Log


  • Allow setting of missing component names


  • Better error handling when parsing malformed XML.


(replaced by 4.0.2)


  • Support AKN 3.0 namespaces
  • Produce URIs with akn prefix by default (backwards compatibility maintained)
  • Support all Akoma Ntoso document types
  • Start FRBR URI work component with ! (eg. !main)
  • FRBRcountry uses full country code from the FRBR URI
  • FRBRnumber uses number portion from FRBR URI
  • FRBRdate for FRBRWork contains the date portion of the FRBR URI
  • Include AKN 3.0 schema and support for validating against the schema
  • The elements returned by components() are now attachment or component elements, not the inner doc


  • FIX issue where a four-digit number in an FRBR URI confuses the parser



  • Python 3.6 and 3.7 support
  • Drop support for Python 2.x


  • FIX don’t mistake numbers in uris with subtypes and numeric numbers as actors
  • FIX link to GitHub
  • Unicode literals when parsing FRBR URIs


  • FIX don’t strip empty whitespace during objectify.fromstring


  • FIX don’t pretty-print XML, it introduces meaningful whitespace


  • FIX FrbrUri clone bug when a URI had a language.


  • Move table of contents, render and other locale (legal tradition) specific functionality out of Cobalt.
  • FIX bug that returned the incorrect language when extracting a document’s expression URI.


  • Inject original img src as data-src


  • Support for i18n in XSLT files, including all 11 South African languages from


  • Support for images
  • Change how XSLT params are passed to the renderer
  • Add expression_frbr_uri method to Act class


  • When rendering HTML, ensure primary container elements and schedules have appropriate ids


  • When rendering HTML, scope component/schedule ids to ensure they’re unique


  • Render ref elements as HTML a elements
  • Optionally prepend a resolver URL before a elements


  • Convert EOL elements to BR when changing XML to HTML


  • Support dates before 1900. Contributed by rkunal.


  • lifecycle and identification meta elements now have a configurable source attribute


  • TOCElement items now include a best-effort title


  • Use HTML5 semantic elements section and article when generating HTML for acts


  • FIX use schedule FRBRalias as heading


  • Transforming XML to HTML now includes all attributes as data- attributes


  • Refactor TOC helpers into own file
  • Fix .format in FrbrUri


  • first release

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for cobalt, version 4.1.0
Filename, size File type Python version Upload date Hashes
Filename, size cobalt-4.1.0-py3-none-any.whl (73.4 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size cobalt-4.1.0.tar.gz (72.8 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page