Package resources

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

All schemas and examples are included in the installed package.

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:

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

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.

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

The schema’s additional building blocks describe those alternatives:

Select the two catalogues

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.

Choose an alternative

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:

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

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
README.md Directory layout and usage notes.
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.
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.csv Table IDs, paths, versions, source dates and checksums.
catalogue.yaml Catalogue publication metadata and checksum.
catalogue_aliases.csv Aliases attached to individual catalogue lookups.
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.csv Table IDs, paths, versions, source dates and checksums.
catalogue.yaml Catalogue publication metadata and checksum.
catalogue_aliases.csv Aliases attached to individual catalogue lookups.
observers.csv Observer reference records.
stations.csv Station reference records.

Contact registry

Directory: examples/survey/catalogue/registries/.

File Purpose
catalogue.csv Table IDs, paths, versions, source dates and checksums.
catalogue.yaml Catalogue publication metadata and checksum.
catalogue_aliases.csv Aliases attached to individual catalogue lookups.
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)