Skip to main content

sdc-mapper

The shared core of the Semantic Data Charter's Governed Data Record mappers. It validates a record, reads the model the record names, resolves every value against what the model says about it, hands the result to a target mapper, and reports every value: how it reached the target, or that the target cannot hold it. Where the record says why a value is missing or unusable (an Exceptional Value, from the ISO 21090 null flavors), the report also says whether the target could say it too. Every call is appended to a hash-chained log that holds no values.

Each target format is its own package (sdc-gdr2ubl, sdc-gdr2edifact, sdc-gdr2omop, ...) registered under the entry-point group sdc_mapper.targets. Outbound only. Apache 2.0.

Status: 4.2.0. The first target mapper, sdc-gdr2ubl (OASIS UBL 2.3), is in development.

Use

sdc-map targets
sdc-map map TARGET record.xml --package DIR [--mapping m.yaml] [-o out/]
sdc-map fidelity record.xml --package DIR          # every installed target, side by side, per Exceptional Value
sdc-map check-mapping m.yaml --package DIR
sdc-map log summary --days 7 | sdc-map log verify
sdc-mapper [--log-dir DIR] [--host URL]            # MCP stdio server (also sdc-mapper-mcp): the primary way agents use the mappers

A model is a package directory (dm-<ct>.jsonld, dm-<ct>.xsd) or a published model's --ct-id, fetched from the SDCStudio host; with neither, the record's own root names it. Exit status: 0 mapped, 1 refused, 2 error.

The three outcomes

  • valid: mapped.
  • valid with Exceptional Values: a value that failed its constraint is covered by an Exceptional Value (Invalid, with the constraint kept), and the rest of the record is mapped. Exceptional Values written at the source (a refusal, a masked field) are kept as written.
  • refused: a broken structure, the wrong model, or an error no Exceptional Value covers. Nothing is written; the reasons are returned and logged.

Mapping files

YAML, validated against schemas/mapping.schema.json, bound to one model schema version and one target version.

mapping: {id: credit-note-to-ubl, version: 1}
model: {ct_id: jkuyr38hydqaiwlq5vhp2rjr, schema_sha256: "…"}
target: {name: OASIS UBL, version: "2.3 CreditNote"}
rules:
  - cluster: <Accounting Supplier Party>        # a cluster to a target element
    to: cac:AccountingSupplierParty
  - cluster: <Party>                            # relative to the enclosing mapped cluster
    to: cac:Party
  - component: <Party Identification Value>
    to: cac:PartyIdentification/cbc:ID
    transform: copy
  - component: <Party Identification Scheme>
    to: cac:PartyIdentification/cbc:ID/@schemeName   # an attribute of the same element
    transform: copy
  - component: <Line Extension Amount>
    to: cbc:LineExtensionAmount
    transform: copy
    units: {to: "@currencyID", transform: copy}
  - cluster: <Party Contact>
    to: "-"
    transform: omit
    reason: the target profile carries no contact

Transforms: copy, code (a table), format, constant, binding (the code the model binds a value to), omit; clusters group or omit. Steps: .. up, . none, +name an element of the value's own, =name the element of that name the parent already has. within: restricts a rule to a context. A value no rule reaches is reported, never dropped. place(record, mapping) turns a record and its mapping into placements a mapper writes from.

Writing a mapper

A mapper has name, target, target_version, package, version, an Exceptional Value table (ev_table: an EVRule per ISO 21090 code: preserved, degraded, carried or lost) and map(record, mapping) -> MapResult. It returns one ValueOutcome for every value it was given, never writes a rejected value as a value, and registers itself:

[project.entry-points."sdc_mapper.targets"]
ubl = "sdc_gdr2ubl:UBLMapper"

Tests

python -m pytest tests -q (offline). The fixture is a HalvorsenDemo Credit Note record and its model's package; the reference mapper in tests/refmapper.py is a flat CSV used only to exercise the contract.

License

Apache 2.0. See NOTICE for the shipped SDC4 reference model schema and the fixture.

Metadata

Release files for sdc-mapper 4.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sdc-mapper 4.2.0
File Size Uploaded Provenance
sdc_mapper-4.2.0.tar.gz 64.5 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for sdc-mapper 4.2.0
File Interpreter ABI Platform
sdc_mapper-4.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 126.6 kB

Release files / sdc_mapper-4.2.0.tar.gz

Download URL sdc_mapper-4.2.0.tar.gz
Size 64.5 kB
Tags Source
SHA-256 checksum
How to use checksums
7387847fb864ee01e8f7dc23fae331e36bd3c7793b7a7db7eb8fce76e03467cc
BLAKE2b-256 checksum
How to use checksums
6b52eb242fef656cd70ae6800a1cf558ee136722e6e55fcf4005f839f47cbf4d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.

Transparency log

Release files / sdc_mapper-4.2.0-py3-none-any.whl

Download URL sdc_mapper-4.2.0-py3-none-any.whl
Size 62.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e53b190ebadcecd83b382dad6f897c104da4009e376ef29add6b13a2509e84ad
BLAKE2b-256 checksum
How to use checksums
059303ee3b4fe94a1ccb5ff0bad65f3bb751064522d103d5ccbc40dc05258515
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.

Transparency log

Security for sdc-mapper 4.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for sdc_mapper-4.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page