CURIE
The intention of the CURIE datatype is to provide Registers with a mechanism to link between them.
A CURIE datatype is a compact URL inspired by the CURIE Syntax 1.0 and essentially compatible with it. There are two key differences: only a subset of CURIEs are allowed and that the reference part complies with the URL specification instead of the URL/URI/IRI IETF specifications.
type Curie =
Prefix (Maybe Reference)
The CURIE serialised as string is expressed in ABNF as:
curie = prefix ":" [reference]
prefix = lowercase *(lowercase / DIGIT / "-" / "_")
reference = path-relative-scheme-less-url-string
lowercase = %x41-5A ; a-z
Where path-relative-scheme-less-url-string
is defined by
https://url.spec.whatwg.org/#path-relative-scheme-less-url-string.
For example, the following CURIEs are valid:
country:
country:GB
local-authority:ABC
example:foo/bar
example:/qux
And the following are invalid:
:GB
GB
country
Expansion to URL
To expand a CURIE into a URL, you need a prefix mapping typically found in the catalogue.
The mapping base URL MUST BE be a valid Record endpoint.
expand : Curie -> Mapping -> Maybe URL
The algorithm:
-
let curie be the CURIE to expand.
-
let mapping be a pair (prefix, base-url).
-
let url be null.
-
Parse the curie into its parts: curie-prefix and reference.
-
If curie-prefix equals prefix:
- Set url with the result of joining base-url with reference.
Otherwise terminate.
For example, a successful expansion for country:GB
could look like:
curie = Curie "country" (Just "GB") -- Parsed from "country:GB"
mapping = ("country", "https://country.register.gov.uk/records/")
url = expand curie mapping
url == Just "https://country.register.gov.uk/records/GB"
When the reference part of the Curie is empty the process is the same. For
example, given a CURIE country:
curie = Curie "country" Nothing -- Parsed from "country:"
mapping = ("country", "https://country.register.gov.uk/records/")
url = expand curie mapping
url == Just "https://country.register.gov.uk/records/"
When the prefixes in the mapping and the CURIE don't match, the result is a
failure. For example, a failed expansion for country:GB
could look like:
curie = Curie "country" "GB" -- Parsed from "country:GB"
mapping = ("example", "https://example.org/")
url = expand curie mapping
url == Nothing
© Crown copyright released under the Open Government Licence.