How to create an iri as object in linkml

30 Views Asked by At

I want to create: https://w3id.org/linkml/examples/personinfo/44
instead of: personinfo:mynr "44"^^xsd:anyURI . see also: What is the difference between "myURI.com"^^xsd:anyURI and <myURI.com>? How can i do so?

YAML schema File
=========
# linkml-convert -s testexample.yaml testexampledata.yaml -t ttl
# linkml-convert -s testexample.yaml testexampledata.yaml -t json-ld
id: https://w3id.org/linkml/examples/personinfo
name: personinfo
prefixes:
  linkml: https://w3id.org/linkml/
  personinfo: https://w3id.org/linkml/examples/personinfo/
  EX: https://example.com/
default_curi_maps:
  - semweb_context
imports:
  - linkml:types
default_prefix: personinfo
default_range: string

classes:
  Person:
    attributes:
      id:
        identifier: true
      full_name:
        required: true
        description: name of the person
      aliases:
        multivalued: true
        description: other names for the person
      phone:
        pattern: "^[\\d\\(\\)\\-]+$"
      age:
        range: integer
        minimum_value: 0
        maximum_value: 200
      mynr:
        range: uri
  Myclass:
    attributes:
      id:
        identifier: true
      persons:
        multivalued: true
        inlined_as_list: true
        range: Person

YAML DATA
=========
id: EX:44
persons:
  - id: EX:1234
    full_name: Clark Kent
    age: 33
    phone: 555-555-5555
  - id: EX:4567
    full_name: Lois Lane
    age: 34
    mynr: "44"
1

There are 1 best solutions below

0
Chris Mungall On

Currently in LinkML all base types (including uri) are modeled as literals , if you want to model this as a think then you will need to:

  • Create a LinkML Class for whatever personinfo:44 represents
  • Make the range of mynr that class.

For example:

id: https://w3id.org/linkml/examples/personinfo
name: personinfo
prefixes:
  linkml: https://w3id.org/linkml/
  personinfo: https://w3id.org/linkml/examples/personinfo/
  EX: https://example.com/
  _base: https://example.com/
default_curi_maps:
  - semweb_context
imports:
  - linkml:types
default_prefix: personinfo
default_range: string

classes:
  Person:
    attributes:
      id:
        identifier: true
      full_name:
        required: true
        description: name of the person
      aliases:
        multivalued: true
        description: other names for the person
      phone:
        pattern: "^[\\d\\(\\)\\-]+$"
      age:
        range: integer
        minimum_value: 0
        maximum_value: 200
      mynr:
        range: OtherClass
  OtherClass:
    attributes:
      id:
        identifier: true
  Myclass:
    attributes:
      id:
        identifier: true
      persons:
        multivalued: true
        inlined_as_list: true
        range: Person