Pre-release. Until the official launch, content may change, including published files.
Skip to content

Source: https://datamodels.jp/en/guide/names · Text CC BY 4.0

Your own names ​

Often the model fits but a name does not match how people talk. The catalog says assignee; one city calls the response team responsibleTeam. You do not need a new model: in JSON-LD a name is only a label, and the @context says what it means. Give your own name the catalog's meaning, and the model stays the same. This is called an alias.

responsibleTeamyour nameassigneethe catalog's nameone meaning…/ns/task/assignee

The example below uses Saigai for Project and responsibleTeam for assignee from task management:

json
{
  "@context": [
    "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context-v1.8.jsonld",
    {
      "tm": "https://datamodels.jp/ns/task/",
      "Saigai": "tm:Project",
      "responsibleTeam": { "@id": "tm:assignee", "@type": "@id" }
    }
  ]
}

Copy an attribute's whole definition, not only its name: assignee points to another entity ("@type": "@id"), so responsibleTeam must say so too, or a team's id is read as plain text.

Data written with responsibleTeam means exactly the same as data written with assignee. An NGSI-LD broker stores an attribute by its IRI (the standard requires it), so it stores both as one attribute, and queries, subscriptions and other clients see no difference. A client that sends this @context gets responsibleTeam and Saigai back.

Rules ​

  • Short attribute names use ASCII letters, digits and _. NGSI-LD does not require this, but GeonicDB checks short attribute names against ^[A-Za-z0-9_]+$ and rejects a name in Japanese script. A full IRI is accepted too.
  • One name per meaning in your @context. If you take the catalog's @context and add an alias, one meaning has two names, and JSON-LD returns the shorter one. To always get your names back, write your @context as a complete list of the names you use, without the catalog's. Copying the catalog's @context and renaming is the quick way.
  • A type alias is not a separate type. Saigai and Project have the same meaning, so a broker stores and matches them as one type, and access rules treat them as one. A type that must be separate (to control access by type, or to add attributes) is a subclass, not an alias: it has its own meaning and keeps the parent's attributes (a schema's x-subclass-of; Rules for models).