DCC Export¶
calServer generates Digital Calibration Certificates (DCC) according to the specification of the Physikalisch-Technische Bundesanstalt (PTB), version 3.3.0. This section describes the technical implementation, the generation process, and the setup.
Basics¶
The DCC is a machine-readable XML format for calibration certificates, standardized by the PTB. It enables automated exchange of calibration data between laboratories and their customers. calServer implements:
- XML generation according to PTB DCC v3.3.0
- Embedding of the PDF calibration certificate as Base64 in the XML
- XSD validation of the generated XML
- Mapping of calServer database fields to DCC XML elements via a configurable JSON file
Architecture¶
The DCC generation comprises three components:
FrontendCalibration
│
▼
DccXmlGenerator ◄── dcc-mapping.json
│
├── generate() Build XML structure
├── embedPdf() Embed PDF as Base64
└── validate() Validate against XSD
│
▼
DCC XML file
DccXmlGenerator¶
The class DccXmlGenerator (under httpdocs/protected/components/) is the central entry point. It:
- Reads the mapping configuration from
dcc-mapping.json - Loads the calibration record with relations (inventory, customer, results, standards)
- Creates a
DOMDocumentwith the DCC namespaces - Builds the
administrativeDataandmeasurementResultssections - Optionally embeds the rendered PDF as Base64
- Validates the result against the PTB XSD schema
The key namespaces:
| Namespace | URI |
|---|---|
| DCC | https://ptb.de/dcc |
| SI | https://ptb.de/si |
DCC Mapping¶
The mapping between calServer fields and DCC XML elements is defined in a JSON file (dcc-mapping.json) that is delivered together with the report templates. This file describes which database fields are transferred to which XML elements.
The mapping is managed via the admin model AdminReportSetting:
hasDccMapping()-- Checks whether a DCC mapping exists for a report templategetDccMappingPath()-- Returns the path to the mapping file
ReportEngineManager¶
The class ReportEngineManager controls whether DCC generation is active:
The feature flag enable_dcc_plugin is set system-wide in the application properties.
XML Structure¶
A generated DCC follows this structure:
<?xml version="1.0" encoding="UTF-8"?>
<dcc:digitalCalibrationCertificate
xmlns:dcc="https://ptb.de/dcc"
xmlns:si="https://ptb.de/si"
schemaVersion="3.3.0">
<dcc:administrativeData>
<!-- Laboratory information, customer information,
calibration object, calibration date -->
</dcc:administrativeData>
<dcc:measurementResults>
<!-- Measurement results with SI units -->
</dcc:measurementResults>
<dcc:document>
<!-- Embedded PDF (Base64) -->
</dcc:document>
</dcc:digitalCalibrationCertificate>
Generation Process¶
The complete workflow of a DCC generation:
- The user triggers report generation for a calibration
- The
ReportEngineManagerchecks whether the DCC plugin is enabled - The report template is checked for an existing DCC mapping
- The
DccXmlGeneratoris instantiated with the path to the mapping file generate($ctag)loads the calibration data and generates the XMLembedPdf($pdfPath)embeds the rendered PDF reportvalidate()validates the XML against the XSD schema- The finished XML is saved and made available for download
Setup¶
Prerequisites¶
- calServer version with DCC support
- JasperReports template with associated
dcc-mapping.json - PTB XSD schema (optional, for validation)
Enable Feature Flag¶
The DCC plugin is enabled via the application properties:
Section: features > report_engine > enable_dcc_plugin = 1
Set Up Report Template¶
- Upload the JasperReports template to the directory
httpdocs/reports/calibrations/ - Place the associated
dcc-mapping.jsonin the same directory - Configure the report template under Administration > Report Management
Create Mapping File¶
The dcc-mapping.json defines the mapping of calServer fields to DCC XML elements. The file is created per report template and references the internal field names (C-series for calibration fields, I-series for inventory fields).
Languages¶
The DCC export supports German and English. The language selection is passed as a parameter when calling generate():
$generator = new DccXmlGenerator($mappingPath, $xsdPath);
$dom = $generator->generate($ctag, 'de'); // or 'en'
Troubleshooting¶
| Problem | Cause | Solution |
|---|---|---|
Failed to parse dcc-mapping.json |
JSON file is malformed or missing | Check path and JSON syntax |
Calibration not found |
Invalid calibration ID | Check CTAG value |
PDF file not found for DCC embedding |
PDF was not generated | Check report generation, review Report Runner logs |
| XSD validation error | XML does not conform to the schema | Check mapping file and calibration data |