Skip to contents

Download the packaged schemas and survey example. This article also describes the YAML contracts for reference configurations and catalogue mappings.

Use Work with reference catalogues for reference retrieval and Catalogue mapping for resolution.

Get the resources

Download all schemas and examples (0.7.0, ZIP).

The ZIP archive preserves schema/ and examples/, including both survey catalogues and their relative paths.

Its file name includes the package version; each schema retains its own format version.

Keep the survey directory together when using its configurations and correspondence CSVs locally.

You can also locate the installed resources:

# Locate the versioned schemas.
system.file("schema", package = "form.model")
# Locate all examples, including the private registry template.
system.file("examples", package = "form.model")

Schemas

See Model specification for the form model contract.

Each reference and mapping configuration declares schema_version: "1.0.0"; this version identifies its format.

Catalogue publications, table revisions and correspondence data have separate versions or checksums.

File Purpose
mapping-1.0.0.yaml Catalogue mapping schema.
model-1.0.0.yaml Form model schema.
references-1.0.0.yaml Reference configuration schema.

The reference and mapping schemas use these building blocks:

  • dialect, contract_version and root identify the contract and its starting definition.
  • definitions and ref define and reuse nodes.
  • type, properties and required describe values and mandatory fields.
  • values describes named mapping entries; min_items requires a minimum number of entries.
  • enum, min_length, minimum and exclusive_minimum constrain individual values.
  • environment: true permits a YAML !env reference at that location in a reference configuration.
  • The mapping schema adds one_of, sequence, items and mutually_exclusive.

Unknown properties, duplicate keys and empty mapping keys are invalid.

YAML expressions are never evaluated. Use the package readers to validate these contracts.

Reference configuration schema

references-1.0.0.yaml defines the form.references/schema/1 dialect.

Use reference_schema() to inspect it and read_reference_configuration() to read a configuration.

Reading validates the structure and source settings without retrieving catalogue data.

Required structure

  • schema_version must be the string "1.0.0".
  • catalogues contains at least one named catalogue.
  • Each catalogue requires source and tables; an optional label names it for consumers.
  • source.url identifies an existing local directory or an HTTP(S) catalogue URL.
  • tables contains at least one table ID, each with at least one named lookup column.
  • Every lookup declares matching: exact or matching: name, plus the boolean ignore_case.

Table IDs and lookup names are exact declarations; lookup names identify actual columns.

Each source directory contains catalogue.yaml, catalogue.csv and the CSV files listed in that catalogue.

Optional source settings

Field Default Meaning
cache Session temporary path Set a path explicitly to reuse files across runs.
timeout 60 Positive request timeout in seconds.
max_connections 4 Positive whole-number limit for CSV downloads.
user Omitted User name for HTTPS Basic authentication.
password Omitted Password, usually supplied through !env.
  • Relative source and cache paths resolve from the configuration file’s directory.
  • Omitting cache gives each source a temporary path for the current R session.
  • Supply user and password together for HTTPS Basic authentication.
  • url, cache, user and password accept !env VARIABLE; it names an environment variable.
  • With prompt = TRUE, the reader can securely request a missing environment password.
  • A catalogue’s omitted label defaults to its identifier when lookups are resolved.

See private catalogue authentication for the workflow.

Survey reference configuration

This is the target configuration used by the survey examples.

schema_version: "1.0.0"
catalogues:
  code_lists:
    label: Code lists
    source:
      url: catalogue/code_lists/
    tables:
      stations:
        code: {matching: exact, ignore_case: false}
      observers:
        code: {matching: exact, ignore_case: true}
        name: {matching: name, ignore_case: true}
  registries:
    label: Registries
    source:
      url: catalogue/registries/
    tables:
      contacts:
        email: {matching: exact, ignore_case: true}
        name: {matching: name, ignore_case: true}

Mapping configuration schema

mapping-1.0.0.yaml defines the form.references/mapping-schema/1 dialect.

Use mapping_schema() to inspect it and read_mapping_configuration() to read a mapping.

The reader validates structure, resolves lookup defaults and checks duplicate alternative selections.

It does not retrieve catalogue data, load reference configurations or open correspondence CSVs.

Required structure

  • schema_version must be the string "1.0.0".
  • catalogues requires both source and target, each with configuration and catalogue names.
  • mappings contains at least one target table ID.
  • Each target declares one correspondence object or a nonempty list of alternatives.
  • Every correspondence requires source.table.

The schema’s additional building blocks describe those alternatives:

  • one_of requires exactly one structural alternative.
  • sequence describes an unnamed list whose entries are checked through items.
  • mutually_exclusive forbids fields together; dotted paths address nested properties.

Select the two catalogues

  • configuration names a reference configuration supplied by the caller.
  • catalogue selects an entry in that configuration’s catalogues mapping.

These are names, not filesystem paths. Catalogue URLs, credentials and lookup settings stay in their configurations.

Declare mappings by target table

Start from the required target reference, then supply the input value with its source identity.

  • Each key under mappings is a target catalogue table ID.
  • source.table identifies the source table supplying values for that target.
  • Translation still runs from source to target.
  • The same source table may appear in mappings for different target tables.

Choose an alternative

  • Use one object when a target has a single source mapping.
  • Use a list when a target accepts several source mappings.
  • Select one alternative using the source table, effective lookups and returned property.

Alternatives are not fallbacks or a transformation chain. Never select the first one or retry after a failed match.

Lookup defaults

Each entry can override the catalogue defaults:

Setting Default Role
source.lookup catalogues.source.lookup Identify the source input column.
lookup catalogues.target.lookup Select the target lookup column.
property The effective target lookup Select the target column to return.

Both effective lookups must be declared, either in the entry or through the catalogue defaults.

Two rules determine where the correspondence comes from:

  • source.property and file are optional and mutually exclusive; there is no mode property.
  • When the source property equals its lookup, omit source.property and use the input unchanged.

That shortcut performs no source lookup and does not resolve source aliases.

Survey mapping configuration

The station entry uses a CSV; the observer entries show source-property and unchanged-input correspondences.

schema_version: "1.0.0"
catalogues:
  source: {configuration: source, catalogue: code_lists, lookup: id}
  target: {configuration: target, catalogue: code_lists, lookup: code}
mappings:
  stations:
    source:
      table: stations
    file: correspondences/stations.csv
  observers:
    - source:
        table: observers
        property: name
      lookup: name
      property: code
    - source:
        table: observers
        lookup: name
      lookup: name
      property: code

Correspondence files

  • file selects a local CSV with exactly two columns: source_value and target_value.
  • Relative paths resolve from the directory containing mapping.yaml.
  • Both columns are read as text, preserving leading zeros and literal values.
  • Empty or missing values in either column are invalid correspondence data.
  • File existence and CSV contents are checked during preparation, separately from YAML structure.

The survey correspondence file deliberately includes repeated, conflicting and unmatched values.

source_value,target_value
station-north,001
station-north,001
station-south,002
station-legacy,OLD-STATION
station-conflict,001
station-conflict,002
station-absent,999

See Catalogue mapping for matching order, resolution outcomes and provenance.

Example downloads

Every file below is included in the complete archive and in the installed package.

Survey configurations

Directory: examples/survey/.

File Purpose
form-empty.xlsx Empty survey form.
form.xlsx Populated survey form.
form.yaml Survey form model.
mapping.yaml Station and observer correspondences between the catalogues.
README.md Directory layout and usage notes.
references-source.yaml Source code lists using technical identifiers.
references.yaml Target code lists and the survey contact registry.

Mapping correspondence CSV

Directory: examples/survey/correspondences/.

File Purpose
stations.csv Explicit source station IDs and target station codes.

Source code lists

Directory: examples/survey/catalogue-source/code_lists/.

These records use technical identifiers; observer names allow rebound to the target name lookup.

File Purpose
catalogue_aliases.csv Aliases attached to individual catalogue lookups.
catalogue.csv Table IDs, paths, versions, source dates and checksums.
catalogue.yaml Catalogue publication metadata and checksum.
observers.csv Observer reference records.
stations.csv Station reference records.

Target code lists

Directory: examples/survey/catalogue/code_lists/.

These tables contain the station and observer codes expected by the survey form model.

File Purpose
catalogue_aliases.csv Aliases attached to individual catalogue lookups.
catalogue.csv Table IDs, paths, versions, source dates and checksums.
catalogue.yaml Catalogue publication metadata and checksum.
observers.csv Observer reference records.
stations.csv Station reference records.

Contact registry

Directory: examples/survey/catalogue/registries/.

File Purpose
catalogue_aliases.csv Aliases attached to individual catalogue lookups.
catalogue.csv Table IDs, paths, versions, source dates and checksums.
catalogue.yaml Catalogue publication metadata and checksum.
contacts.csv Contact registry records.

Private source template and overview

Directory: examples/.

The private-source template needs your catalogue URLs and user name before use.

File Purpose
README.md Directory layout and usage notes.
references.private.example.yaml Public code lists and a private HTTPS registry template.

See Getting started to load the survey form model.

Use the published catalogues

The same catalogue files can be retrieved directly from the website.

# Load the catalogue retrieval functions.
library(form.model)
# Choose a temporary cache for these downloads.
resources_cache_directory <- tempfile("survey-resources-")
# Configure the published target code lists.
reference_source_configuration <- reference_source(
  "https://ultreia-io.github.io/form.model/examples/survey/catalogue/code_lists/", resources_cache_directory)
# Retrieve the station and observer tables, verifying their checksums.
reference_values <- get_reference_tables(c("observers", "stations"), reference_source_configuration)
# Configure the published contact registry.
reference_registry_source <- reference_source(
  "https://ultreia-io.github.io/form.model/examples/survey/catalogue/registries/", resources_cache_directory)
# Retrieve and verify the contact table.
reference_registry_tables <- get_reference_tables("contacts", reference_registry_source)
# Remove the temporary files created by this example.
unlink(resources_cache_directory, recursive = TRUE)