Skip to content

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

Terminal window
./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:

Terminal window
./scripts/mondrian-schema to-yaml demo/FoodMart.mondrian.xml -o demo/FoodMart.yaml

Example β€” preview without saving:

Terminal window
./scripts/mondrian-schema to-yaml demo/FoodMart.mondrian.xml | head -40

to-xml β€” convert YAML to XML

Terminal window
./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:

Terminal window
./scripts/mondrian-schema to-xml demo/FoodMart.yaml -o FoodMart-generated.xml

Example β€” pipe to a diff to verify round-trip fidelity:

Terminal window
./scripts/mondrian-schema to-xml demo/FoodMart.yaml | diff demo/FoodMart.mondrian.xml -

lint β€” validate a schema file

Terminal window
./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:

Terminal window
./scripts/mondrian-schema lint demo/FoodMart.yaml

Example β€” lint an XML schema:

Terminal window
./scripts/mondrian-schema lint demo/FoodMart.mondrian.xml

Exit codes

CodeMeaning
0Success β€” no errors
1Bad arguments or missing input file
2Parse or validation failure β€” diagnostic written to stderr

These codes are suitable for use in CI pipelines and pre-save hooks.


Typical workflows

  1. Convert your existing XML schema to YAML:

    Terminal window
    ./scripts/mondrian-schema to-yaml my-schema.xml -o my-schema.yaml
  2. Lint the YAML to confirm it is valid:

    Terminal window
    ./scripts/mondrian-schema lint my-schema.yaml
  3. Review and annotate my-schema.yaml with comments, then upload it to Saiku via the Schemas page.


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-saiku repository checked out locally (the script is part of that repo, not a standalone binary)

  • 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.