cpacs-schema-tool is the shared formatter, checker, linter, and explicit
migration utility for CPACS XML Schema files. It is intended for the official
CPACS repository, TiGL, and project-internal CPACS schema instances.
The package ships the CPACS Standard Schema Rules. Projects use those rules without copying a configuration file and may layer small, explicit overrides on top when necessary.
cpacs-schema format schema/cpacs_schema.xsd --in-place
cpacs-schema check schema/cpacs_schema.xsd
cpacs-schema lint schema/cpacs_schema.xsd
cpacs-schema rename-types schema/cpacs_schema.xsd
cpacs-schema prune-unused schema/cpacs_schema.xsdThe commands deliberately distinguish representation-preserving formatting from schema-changing migrations:
formatnormalizes ordering, attributes, whitespace, and redundant occurrence defaults.checkverifies canonical formatting and XSD compilation.lintchecks CPACS conventions, references, reachability, prefixes, and XSD validity.rename-typesproduces a dry-run plan unless--applyis supplied.prune-unusedproduces a dry-run plan unless--applyis supplied.
Writes are atomic. Existing files are overwritten only with --in-place; an
optional --backup creates <schema>.bak.
Development installation:
python -m pip install -e ".[dev]"
python -m pytestUsing Conda:
conda create -n cpacs-schema -c conda-forge python=3.10 pip git
conda activate cpacs-schema
python -m pip install "cpacs-schema-tool @ git+https://github.com/DLR-SL/cpacs-schema-tool.git@v0.1.1"
cpacs-schema --versionUsing Pixi:
pixi run checkUntil the package is published on PyPI, a consumer can pin the released Git tag:
[pypi-dependencies]
cpacs-schema-tool = {
git = "https://github.com/DLR-SL/cpacs-schema-tool.git",
tag = "v0.1.1"
}Running a command without --rules uses the bundled standard policy:
cpacs-schema lint schema/cpacs_schema.xsdThe bundled policy defines, among other things:
- the
cpacsroot element andcpacsTyperoot type; - canonical top-level declaration and attribute ordering;
- CPACS base-type ordering;
- type naming rules;
- reference and reachability checks;
- XSD/XLink prefix conventions;
- severities for diagnostics
CPACS001throughCPACS011.
The policy has its own metadata:
[policy]
name = "CPACS Standard Schema Rules"
version = "1.0"--rules applies a partial TOML file over the bundled CPACS defaults. The option
may be repeated; later files take precedence.
cpacs-schema lint project_schema.xsd \
--rules project_schema_overrides.tomlExample:
[reachability]
keep_add = ["projectMetadataType"]
[naming.types]
exceptions_add = ["LegacyProjectType"]
[rules.CPACS009]
severity = "error"Tables are merged recursively. Scalar values and ordinary arrays replace the
corresponding defaults. For array-valued settings, _add and _remove modify
the existing standard list without copying it:
[reachability]
keep_add = ["publicProjectType"]
keep_remove = ["obsoletePublicType"]A complete independent policy can be supplied with --replace-rules. It must
contain every required table and is mutually exclusive with --rules.
cpacs-schema lint another_schema.xsd \
--replace-rules complete_policy.tomlThe effective merged policy can be inspected reproducibly:
cpacs-schema lint schema.xsd --print-effective-rulesConsumer repositories should pin a released tool version or full Git commit. Changes that alter canonical formatting or turn formerly accepted constructs into errors must be documented in the changelog. Explicit rename mappings are best supplied as release-specific override files rather than accumulated in the permanent standard policy.
Apache License 2.0. See LICENSE and NOTICE.