Apache Ossie
Read an Apache Ossie ontology, as YAML or JSON, and produce the LinkML schema it describes. The opposite of ossie.
ohi get w3c/prov-o --format ossie-yamlohi linkml from ossie --schema-id https://example.org/prov \ --to prov.yaml prov-o.ossie.yamlfrom pathlib import Path
import ohi_linkml
result = ohi_linkml.from_ossie( Path("prov-o.ossie.yaml").read_text(), schema_id="https://example.org/prov",)import { readFileSync } from "node:fs";import { LinkML } from "@neverblink/linkml";
const result = LinkML.fromOssie( readFileSync("prov-o.ossie.yaml", "utf8"), { schema_id: "https://example.org/prov" },);import eu.neverblink.linkml.generator.options.OssieImporterOptionsimport eu.neverblink.linkml.generator.ossie.OssieImporter
import java.nio.file.{Files, Path}
val schema = OssieImporter().serializeFromString( Files.readString(Path.of("prov-o.ossie.yaml")), OssieImporterOptions(schemaId = Some("https://example.org/prov")),)#include <stddef.h>#include "ohi_linkml.h"
/* document is the text of prov-o.ossie.yaml. *//* The result is an ImportResult in JSON. */linkml_init_threads();char *error = NULL;char *result = linkml_from_ossie( document, "{\"schema_id\": \"https://example.org/prov\"}", &error);linkml_free(result);linkml_free(error);Options
Section titled “Options”formatJsonOutputFormatdefault yaml--formatThe serialization of the schema.
yamlYAML.jsonJSON.
full_urisbooleandefault false--full-urisScala fullUrisWhether to write URIs in full, instead of compacting them to CURIEs with the schema's prefixes.
schema_idstring--schema-idScala schemaIdThe id of the schema to produce. An Ossie ontology has none of its own, so by default it is a placeholder built from the ontology's name.
Mapping Ossie to LinkML
Section titled “Mapping Ossie to LinkML”The importer reads Apache Ossie ontologies (ontology/ontology.json, version 0.2.0.dev0). The Ossie generator does the reverse.
Document
Section titled “Document”| Ossie field | LinkML |
|---|---|
name |
name |
description |
description |
ontology |
A class, enum, or type per component. |
ai_context |
extensions.ai_context |
prefixes |
prefixes, declared after linkml. |
version, requires and ontology_mappings are not read. See IRIs for how prefixes and iri are handled.
By default, the importer invents an identifier for the LinkML schema as https://example.org/ + name in snake_case, unless the caller supplies schema_id.
Concept (OntologyComponent)
Section titled “Concept (OntologyComponent)”| Ossie field | LinkML |
|---|---|
concept |
Element name, with the original spelling in alias. |
type |
A class for EntityType, an enum or a type for ValueType. |
iri |
class_uri, enum_uri, or the type’s uri. See IRIs. |
description |
description |
extends |
Last entry is is_a, the rest are mixins. For a value type it is typeof, or string if the base is unknown. |
identify_by |
One entry, OneToOne, or scalar range → identifier. Otherwise unique_keys. |
requires |
Concept.relationship makes the slot required. For enums and types, see Expressions. Any other restriction is ignored. |
relationships |
One attribute each. |
derived_by is not read.
Relationship
Section titled “Relationship”| Ossie field | LinkML |
|---|---|
name |
Slot name in snake_case, original spelling in alias. |
iri |
slot_uri. See IRIs. |
verbalizes |
The phrase becomes the slot title, unless it is just the space-cased name. Only the first is read. |
description |
description |
roles |
The first role’s concept is the range. Any others are dropped. |
multiplicity |
Absent → multivalued: true. |
requires |
minimum_value, maximum_value and pattern, from expressions over the role. |
| (relationship order) | rank |
derived_by is not read.
Ranges
Section titled “Ranges”Ossie’s built-in concepts map onto LinkML types:
| Ossie | LinkML |
|---|---|
String |
string |
Integer |
integer |
Float |
float |
Decimal |
decimal |
Boolean |
boolean |
Date |
date |
DateTime |
datetime |
Any |
A class with class_uri: linkml:Any |
The generator maps several LinkML types to one Ossie concept, so a round trip changes them: a uri comes back as a string, and a double as a float.
Expressions
Section titled “Expressions”| Ossie | LinkML |
|---|---|
Concept.relationship |
required: true |
Ref IN ('a', 'b') |
permissible_values |
Ref >= v, Ref <= v |
minimum_value, maximum_value |
REGEXP_LIKE(Ref, 'p') |
pattern |
The importer copies the ontology’s prefixes into the schema, and expands each iri that is a QName, as a LinkML schema is read. The schema then writes the URI as a CURIE again, so iri: foaf:Agent becomes class_uri: foaf:Agent. The one exception is a linkml prefix that points anywhere other than https://w3id.org/linkml/. The schema needs linkml for its own imports, so that prefix is not copied, and any iri using it is written out as a full IRI instead.
A QName whose prefix the ontology doesn’t declare is expanded with the prefixes of the LinkML metamodel, so iri: skos:Concept is http://www.w3.org/2004/02/skos/core#Concept. Any other iri must be a full IRI, such as acme:Thing when acme isn’t a prefix. The import stops with an error for an iri, a schema id or a prefix namespace that isn’t a valid IRI, such as Person or John Doe.