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_versionandrootidentify the contract and its starting definition. -
definitionsandrefdefine and reuse nodes. -
type,propertiesandrequireddescribe values and mandatory fields. -
valuesdescribes named mapping entries;min_itemsrequires a minimum number of entries. -
enum,min_length,minimumandexclusive_minimumconstrain individual values. -
environment: truepermits a YAML!envreference at that location in a reference configuration. - The mapping schema adds
one_of,sequence,itemsandmutually_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_versionmust be the string"1.0.0". -
cataloguescontains at least one named catalogue. - Each catalogue requires
sourceandtables; an optionallabelnames it for consumers. -
source.urlidentifies an existing local directory or an HTTP(S) catalogue URL. -
tablescontains at least one table ID, each with at least one named lookup column. - Every lookup declares
matching: exactormatching: name, plus the booleanignore_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
cachegives each source a temporary path for the current R session. - Supply
userandpasswordtogether for HTTPS Basic authentication. -
url,cache,userandpasswordaccept!env VARIABLE; it names an environment variable. - With
prompt = TRUE, the reader can securely request a missing environment password. - A catalogue’s omitted
labeldefaults 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_versionmust be the string"1.0.0". -
cataloguesrequires bothsourceandtarget, each withconfigurationandcataloguenames. -
mappingscontains 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_ofrequires exactly one structural alternative. -
sequencedescribes an unnamed list whose entries are checked throughitems. -
mutually_exclusiveforbids fields together; dotted paths address nested properties.
Select the two catalogues
-
configurationnames a reference configuration supplied by the caller. -
catalogueselects an entry in that configuration’scataloguesmapping.
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
mappingsis a target catalogue table ID. -
source.tableidentifies 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.propertyandfileare optional and mutually exclusive; there is nomodeproperty. - When the source property equals its lookup, omit
source.propertyand 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: codeCorrespondence files
-
fileselects a local CSV with exactly two columns:source_valueandtarget_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)