Home

MS Base

  • prefix: ms:
  • schema: b:

Categories (Data):

Categories (Governance):

values:

 
 

Schema element "b:UnitRef"

Type b:UnitRef is a reference to some b:unit.

Definitions

<simpleType name="UnitRef">
  <restriction base="string">
    <pattern value="[\p{IsCommon}-\p{IsSpace}]+" />
  </restriction>
</simpleType>

Description

Elements and attributes of type b:UnitRef refer to a b:unit instance. This can be in a namespace qualified form or in a relative form. The interpretation has some similarities with the HTTP URI syntax as defined by RFC3986.

When the reference matches with /^(\w+):/, it is an absolute reference: it starts with a namespace prefix. When the reference starts with a colon (:), it is a full path starting at the root of the namespace. Otherwise, it is a reference relative to the path to the Unit in which it is used.

Absolute and relative path resolution may pass through Units which have different Rules, for instance different path separators.

Fragment

The UnitRef can contain a fragment (# followed by a name), which refers to a b:has unit reference in the select unit (defaults to the current unit). This is useful when you need to add more details to the reference.

Advices

The prefix may not be known when the data is received: it SHOULD be linked to a namespace only when it is actually used by an application.

It is RECOMMENDED not to absolute references within the same Namespace (to use prefixes which refers to the context of the Unit itself). This will make a restructuring of a namespace harder, because Units may need to be rewritten for some changes.

WARNING: this reference is not the same as a xsd:IDREF, which MUST refer inside the XML document when the document is being read.

Examples

Absolute references

When your reference starts with a prefix, like pref: (some word characters followed by a colon), then the reference is absolute. Examples:

pref:                # refers to the root b:namespace unit
pref:a
pref:image/logo.png

You may recognize the .png as a filename extension. This does not have a meaning here: each Unit has a unit.type attribute which contains the (mime-)type of the contained data.

Even absolute references may contain ".." and "." path components.

Relative references

When the reference is not absolute, it is considered relative. In this case, there are two variations: when the reference starts with the path-separator of the root namespace, it will use that Unit as starting point of the address resolving. Otherwise, it will use the Unit in which the reference was found as start.

Examples, starting from the Unit at address pref:a/b:

  "owner" : "c"    --> pref:a/c  # relative
  "owner" : ":c"   --> pref:c    # absolute, same namespace
  "owner" : "my:c" --> my:c      # absolute, other namespace

Designed with mixed path-separators

Say, your Namespace describes DNS PTR records. You may design the top with separator '/' and two Collections with UnitIDs ipv4 and ipv6. For Collection ipv4 you use path-separator '.', in ipv6 you use separator ':'.

Within Collection ipv4, you create Collections named "127" and "192.168". For absolute reference, there is no difference between having a Collection "192" which contains a Unit (probably Collection) 168 or having a Unit with UnitID "192.168" at once.

When you expect a lot of Units, you probably want to have many Collections with each a complex (Access) configuration. In a small data-set, everything is in the root namespace. You will be able to reorganize the Collection structure in existing namespaces under fly.

Now, we can write a small program (not implemented yet):

my $ms = Meshy::Space->new;
$ms->prefix(net => 'https://example.org/network');

my $unit = $ms->getUnit("net:ipv4/192.168.12.1");
print $unit->type;  # --> "net:Type/Gateway"
print $unit->name;  # --> "Gateway for 192.168.12"

Be aware that b:unit objects have all and more features as DNS zone files, like cache expiration and distribution.


mark@overmeer.net      Web-pages generated on 2023-12-19