Mirror of the Rel4tion website/wiki source, view at <http://rel4tion.org>
Clone
HTTPS:
git clone https://vervis.peers.community/repos/yEzqv
SSH:
git clone USERNAME@vervis.peers.community:yEzqv
Branches
Tags
02-plref.mdwn
[[!meta title=“4.3.2 | Prefix-Label References”]]
Prefix-Label References
Prefix-label references, or PLrefs, are part of Idan’s human language interface. This interface provides a way to tag resources with names, and group them into logical units. The details are in another section, and this section only deals briefly with the PLrefs themselves.
Concept
The human interface system assigns labels to resources, and arranges them in namespaces. A namespace may contain sub-namespaces, thus forming a hierarchy of namespaces. It’s technically possible for a namespace to have more than one parent namespace, but the hierarchy is generally indeed a tree, with labels being the leaves.
A PLref is a sequence of alphanumeric names, representing a path in the tree, starting at the top, and ending with a leaf. The PLref refers to the resource to which the leaf label belongs.
Resolution
The sequence consists of at least 2 names. The first name in the sequence is a namespace prefix. The other names are labels. The algorithm for resolving a PLref (i.e. determining to which resource Uid it refers) can be described in two parts, resolvePair and resolveRef, explained below. However the description below isn’t accurate because it doesn’t take languages into account, and several other elements. A more accurate algorithm is presented in the section about the namespace-label system.
First, the resolvePair algorithm:
- Suppose we have a pair
(u, l)
whereu
is a Uid andl
is a label. - If
u
is a namespace which contains a labell
, andl
is the label of a resourcez
, then returnz
. - If
u
isn’t a namespace or doesn’t containl
, resolution has failed.
Then, the resolveRef algorithm:
- Suppose we have a sequence of names
(a_1, a_2, ... a_n)
wherea >= 2
. - Find a namespace resource
u
whose prefix isa_1
. If failed, the resolution has failed. - Apply resolvePair to
(u, a_2)
. If failed, resolution has failed. Otherwise, denote the result withz
. - If we already used all the
n
items ofa
, returnz
. - Pick the next unused
a_i
and apply resolvePair to(z, a_i)
. If failed, resolution has failed. Otherwise, the result is the new value ofz
. - Jump tp step 4.
Here is a more intuitive description. The sequence consists of a single prefix, followed by a sequence of one or more labels. After resolving the prefix, each resoltion step finds the label in a namespace and picks the resource it belongs to, which is itself a namespace, to which the next label is matched, and so on. See below for examples.
Syntax
PLrefs can be used as subjects, predicates and objects - not identifiers. > PLref parts are separated by colons (:
). For example, suppose there is a namespace containing definitions related to people, and we assign it a prefix ppl
. It contains a label Person
which refers to the Person class, the class of all people. Then a PLref ppl:Person
can be used to refer to that class:
<%> smaoin:is_a ppl:Person
In this example there is also a namespace smaoin
, and a property with label is_a
, which is a member of it. PLrefs with more parts are possible too, e.g. animals:mammals:Human
.
When the default prefix is used in a PLref, it may be omitted, in which case the PLref begins with a colon. For example :mammals:Human
.
Note that this syntax doesn’t cover the case of referring to a declared namespace itself. This is covered in the next section.