diff --git a/docs/dsp-tools-create-ontologies.md b/docs/dsp-tools-create-ontologies.md index 61611afcf..e7226b5b7 100644 --- a/docs/dsp-tools-create-ontologies.md +++ b/docs/dsp-tools-create-ontologies.md @@ -905,5 +905,5 @@ it is necessary to reference entities that are defined elsewhere. The following [prefixes](dsp-tools-create.md#prefixes-object) and the prefix must be identical to the ontology's `name`. - A different ontology defined in the same file: Within one data model file, multiple ontologies can be defined. These will be created in the exact order they appear in the `ontologies` array. Once an ontology has been created, - it can be referenced by the following ontologies, provided it is added in the - [prefixes](dsp-tools-create.md#prefixes-object). + it can be referenced by the following ontologies via its name: `first-onto:hasName`. It is not necessary to add + `first-onto` to the prefixes. diff --git a/docs/dsp-tools-create.md b/docs/dsp-tools-create.md index 4cfc724f6..58d6bae06 100644 --- a/docs/dsp-tools-create.md +++ b/docs/dsp-tools-create.md @@ -66,8 +66,8 @@ full qualified IRI each time it is used. So, instead of writing a property calle } ``` -Note that prefixes can be defined for the ontologies defined in this file, but this is only necessary if the ontology -needs to be referred to explicitly by another ontology within the same file. +It is not necessary to define prefixes for the ontologies that are defined in this file. Ontologies in the same +file can refer to each other via their name. See also [here](./dsp-tools-create-ontologies.md#referencing-ontologies). ### "$schema" object diff --git a/knora/dsplib/models/helpers.py b/knora/dsplib/models/helpers.py index 25b7a4acd..300e9eb3e 100644 --- a/knora/dsplib/models/helpers.py +++ b/knora/dsplib/models/helpers.py @@ -162,7 +162,7 @@ def __init__(self, context: Optional[dict[str, str]] = None): # add ontologies from context, if any if context: for prefix, onto in context.items(): - self._context[prefix] = OntoInfo(onto.removesuffix('#'), onto.endswith('#')) + self._context[prefix] = OntoInfo(onto.removesuffix('#'), onto.endswith('#') or onto.endswith('/v2')) # add standard ontologies (rdf, rdfs, owl, xsl) for k, v in self.base_ontologies.items(): diff --git a/knora/dsplib/utils/onto_create_ontology.py b/knora/dsplib/utils/onto_create_ontology.py index 63ab3f6af..f6f917192 100644 --- a/knora/dsplib/utils/onto_create_ontology.py +++ b/knora/dsplib/utils/onto_create_ontology.py @@ -398,6 +398,7 @@ def create_ontology(input_file: str, project=project, label=ontology["label"], name=ontology_name).create() + context.add_context(new_ontology.name, new_ontology.id + ('#' if not new_ontology.id.endswith('#') else '')) last_modification_date = new_ontology.lastModificationDate if verbose: print(f"Created ontology '{ontology_name}'.")