Schema CLI
The mondrian-schema script wraps the mondrian.schema.yaml.SchemaCli Java tool so you do not have to remember a long mvn exec:java incantation. Use it to convert existing XML schemas to YAML, convert YAML back to XML for deployment, or validate a schema file before saving it to Saiku.
Commands
to-yaml β convert XML to YAML
./scripts/mondrian-schema to-yaml <input.xml> [-o output.yaml]Reads a Mondrian-4 XML schema and writes the equivalent YAML representation. If -o is omitted, the YAML is written to stdout.
Example β convert FoodMart:
./scripts/mondrian-schema to-yaml demo/FoodMart.mondrian.xml -o demo/FoodMart.yamlExample β preview without saving:
./scripts/mondrian-schema to-yaml demo/FoodMart.mondrian.xml | head -40to-xml β convert YAML to XML
./scripts/mondrian-schema to-xml <input.yaml> [-o output.xml]Reads a Mondrian-4 YAML schema and writes the equivalent XML. If -o is omitted, the XML is written to stdout. This is the same conversion the Saiku engine runs automatically at runtime β running it manually is useful for inspecting the output before deploying or for migrating back to an XML-native toolchain.
Example β convert back to XML:
./scripts/mondrian-schema to-xml demo/FoodMart.yaml -o FoodMart-generated.xmlExample β pipe to a diff to verify round-trip fidelity:
./scripts/mondrian-schema to-xml demo/FoodMart.yaml | diff demo/FoodMart.mondrian.xml -lint β validate a schema file
./scripts/mondrian-schema lint <input.{yaml,xml}>Parses and validates a schema file β either YAML or XML. Errors and warnings are written to stderr. On success, the command exits silently with code 0.
Example β lint a YAML schema:
./scripts/mondrian-schema lint demo/FoodMart.yamlExample β lint an XML schema:
./scripts/mondrian-schema lint demo/FoodMart.mondrian.xmlExit codes
| Code | Meaning |
|---|---|
0 | Success β no errors |
1 | Bad arguments or missing input file |
2 | Parse or validation failure β diagnostic written to stderr |
These codes are suitable for use in CI pipelines and pre-save hooks.
Typical workflows
-
Convert your existing XML schema to YAML:
Terminal window ./scripts/mondrian-schema to-yaml my-schema.xml -o my-schema.yaml -
Lint the YAML to confirm it is valid:
Terminal window ./scripts/mondrian-schema lint my-schema.yaml -
Review and annotate
my-schema.yamlwith comments, then upload it to Saiku via the Schemas page.
-
Author or edit your YAML schema locally.
-
Run lint to catch errors before uploading:
Terminal window ./scripts/mondrian-schema lint my-schema.yamlA
0exit code means the schema parsed cleanly. Any errors appear on stderr with a line reference. -
If you need to supply XML to an external tool (e.g. a legacy reporting client), convert on demand:
Terminal window ./scripts/mondrian-schema to-xml my-schema.yaml -o my-schema.xml
Add a lint step to your CI pipeline to catch schema errors before they reach production:
# In .github/workflows/ci.yml or equivalent- name: Lint Mondrian schemas run: | for f in schemas/*.yaml; do ./scripts/mondrian-schema lint "$f" doneThe script exits with code 2 on any parse or validation failure, which will fail the CI job automatically.
Prerequisites
The script requires:
- Java β available on
$PATH(same JVM version used to build the project) - Maven β for the one-time classpath build; not needed after the cache exists
- The
mondrian-saikurepository checked out locally (the script is part of that repo, not a standalone binary)
Related
- YAML schemas β the full YAML element reference.
- Schemas β upload and manage schemas in the Saiku dashboard.
- Schema designer β generate a schema from a natural-language description.