dcclib logo

dcclib

dcclib is a modular Python library for working with Digital Calibration Certificates (DCCs) — the XML-based format standardised by PTB for exchanging calibration results between metrology labs, instruments, and downstream software.

The monorepo ships three co-versioned packages:

Package Purpose
dcclib Core library — parsing, validation, conversion, transformation, and formula extraction
dcclib-cli Command-line interface built on top of the core library
dcclib-rest-api Flask-based REST API exposing the same functionality over HTTP

Features at a glance

  • XSD validation — validate a DCC XML file against one of the bundled DCC schema versions or a custom schema.
  • Schematron validation — run business-rule checks via the bundled DCC schematron or a custom ruleset.
  • JSON conversion — round-trip conversion between DCC XML and JSON.
  • XSLT transformation — apply custom XSLT stylesheets to any XML document.
  • Formula extraction & evaluation — parse MathML formulas from DCCs into SymPy expressions and evaluate them, optionally with unit-aware arithmetic and uncertainty propagation via dccQuantities.
  • File extraction — list and decode Base64-encoded attachments embedded in DCCs.
  • Digital signatures — sign and verify XML digital signatures on DCC files.
  • REST API — expose all of the above over a HTTP/JSON interface.

Quick start

Installation

# Core library
pip install dcclib

# With unit-aware quantities support (requires .NET on Windows / libmono on Linux)
pip install "dcclib[quantities]"

# Install the CLI globally
pipx install "dcclib[cli]"

# CLI + quantities
pipx install "dcclib[cli,quantities]"

Python usage

from dcclib.validation import XsdValidator

validator = XsdValidator.from_version("3.3.0")
result = validator.validate_file(dcc_xml_path)

if result.is_valid:
    print("DCC is valid!")
else:
    for error in result.errors:
        print(error.message)

CLI usage

# Validate a DCC file (XSD + Schematron)
dcclib validate my_dcc.xml

# Convert to JSON
dcclib convert to-json my_dcc.xml -o my_dcc.json

# Extract and evaluate formulas
dcclib extract formulae my_dcc.xml

See the CLI documentation for the full command reference, and the Getting Started guide for a step-by-step walkthrough.

Publications and acknowledgments

This project was developed as part of the bachelor thesis of Jan Loewe at the Ostfalia University of Applied Sciences. More information on dcclib can be found in the presentation by Jan Loewe and Justin Jagieniak at the 6th International DCC Conference in 2026. The formula module is based on previous work conducted by Justin Jagieniak, Siegfried Hackel and Jan Loewe first presented at the 5th International DCC Conference in 2025. Automatic uncertainty propagation is implemented using dccQuantities which internally relies on METAS UncLib. dccQuantities was also presented at the 6th International DCC Conference by Jaime Gonzalez-Gomez, Benedikt Seeger and Vanessa Stehr.