Describing your domain

Importing an RDF / OWL ontology

​
Overview

Many organisations already describe their domain in an OWL or RDF ontology. Taxi can import that ontology, so your systems can describe their data in the ontology’s terms.

The ontology stays the source of truth. Its owners don’t change anything. The importer writes Taxi packages from it, and you regenerate them when the ontology changes.

The importer reads Turtle, RDF/XML and N-Triples files. It doesn’t run a reasoner. If your applications depend on inferred statements, run a reasoner over the ontology first.

​
What becomes what

In the ontologyIn Taxi
owl:ClassA concept, carrying the class’s IRI in @Iri
rdfs:subClassOf a named classinherits (several parents are allowed)
rdfs:label, skos:definition, skos:altLabelDocs on the declaration
owl:DatatypePropertyA semantic type, such as type Isin inherits String
A restriction on a datatype propertyA member of the concept, such as Isin or MaturityDate?
rdfs:subPropertyOf between datatype propertiesType inheritance
owl:ObjectPropertyA relationship
A restriction on an object propertyA narrowing line in the concept, such as hasIssuer -> BondIssuer
A class whose individuals are a closed setAn enum (listed in the profile, or defined with owl:oneOf)
A class that only wraps a value, such as an identifierA semantic type (listed in the profile)
owl:OntologyA Taxi package, with its own taxi.conf

​
How many values

Cardinality comes from the restrictions on a class:

The ontology saysTaxi member
Exactly oneIsin
At most one, or the property is functionalIsin?
At least one, or owl:someValuesFromIsin[]
Nothing about how manyIsin[] (the profile can make this Isin?)
Any other numberIsin[], and the report says it was rounded

​
A worked example

This ontology has one class with a parent, two datatype properties and one object property:

@prefix fi:   <https://ontology.acme.example/fi/> .
@prefix owl:  <http://www.w3.org/2002/07/owl#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
@prefix xsd:  <http://www.w3.org/2001/XMLSchema#> .

<https://ontology.acme.example/fi/> a owl:Ontology ;
    rdfs:label "Acme financial instruments"@en ;
    owl:versionInfo "2026.3" .

fi:FinancialInstrument a owl:Class .
fi:LegalEntity a owl:Class .

fi:Bond a owl:Class ;
    rdfs:label "bond"@en ;
    skos:definition "A tradable debt instrument issued by a legal entity."@en ;
    rdfs:subClassOf fi:FinancialInstrument ,
        [ a owl:Restriction ; owl:onProperty fi:hasIsin ; owl:cardinality 1 ] ,
        [ a owl:Restriction ; owl:onProperty fi:hasMaturityDate ; owl:maxCardinality 1 ] .

fi:hasIsin a owl:DatatypeProperty ;
    rdfs:label "has ISIN"@en ;
    rdfs:range xsd:string .

fi:hasMaturityDate a owl:DatatypeProperty ;
    rdfs:range xsd:date .

fi:hasIssuer a owl:ObjectProperty , owl:FunctionalProperty ;
    rdfs:domain fi:FinancialInstrument ;
    rdfs:range fi:LegalEntity .

The importer writes this Taxi:

import lang.taxi.formats.rdf.Iri

namespace acme.fi {
   @Iri("https://ontology.acme.example/fi/FinancialInstrument")
   concept FinancialInstrument {}

   @Iri("https://ontology.acme.example/fi/LegalEntity")
   concept LegalEntity {}

   [[
   bond

   A tradable debt instrument issued by a legal entity.
   ]]
   @Iri("https://ontology.acme.example/fi/Bond")
   concept Bond inherits FinancialInstrument {
      Isin
      MaturityDate?
   }

   [[ has ISIN ]]
   @Iri("https://ontology.acme.example/fi/hasIsin")
   type Isin inherits String

   @Iri("https://ontology.acme.example/fi/hasMaturityDate")
   type MaturityDate inherits Date

   @Iri("https://ontology.acme.example/fi/hasIssuer")
   relationship hasIssuer: FinancialInstrument -> LegalEntity?
}

A few things to notice:

  • Names come from the IRI. A datatype property drops a leading has, so hasIsin becomes Isin. Relationships keep their name as it is, because it reads as a verb.
  • Every declaration carries the full IRI of its term in @Iri. The Taxi name is only a local alias.
  • hasIsin is exactly one, so the member is Isin. hasMaturityDate is at most one, so it’s MaturityDate?.
  • hasIssuer is functional, so its target is optional: LegalEntity?.

Your systems then describe their own data with these types, and say which concepts their models satisfy. See Concepts for how a model satisfies a concept.

​
Running the import

Use the taxi import rdf command:

taxi import rdf --profile ontology-import.conf --output generated/

It writes:

  • One directory per package, each with its taxi.conf and its sources under src/.
  • A taxi/rdf-annotations package that declares @Iri and the other annotations. Every generated package depends on it.
  • The import report, printed and saved as import-report.txt and import-report.json.
  • The lock file, ontology-import.lock.json, next to the profile.
OptionWhat it does
--profileThe profile file. Required.
--outputThe directory to write to. Required.
--lockThe lock file to read and write. Defaults to the one named in the profile.
--baseline-reportA JSON report from an earlier import. The command fails if more lines need a decision now.
--allow-breakingWrite the packages even when the ontology has breaking changes since the last import.

The command exits with an error when there are breaking changes you haven’t allowed, or when the baseline check fails. That makes it safe to run in CI.

​
The profile file

Everything the importer can’t work out from the ontology goes in a profile file. It’s a HOCON file, like taxi.conf. The ontology and the profile together decide the output.

source {
   files: ["ontologies/fi.ttl", "ontologies/party.ttl"]
   language: "en"
}

// Ontology namespace IRI to Taxi namespace
namespaces {
   "https://ontology.acme.example/fi/": "acme.fi"
   "https://ontology.acme.example/party/": "acme.party"
}

// Ontology modules grouped into Taxi packages
packages {
   "acme/ontology-fi": ["https://ontology.acme.example/fi/"]
   "acme/ontology-party": ["https://ontology.acme.example/party/"]
}
version: "1.0.0"

// Explicit names for specific terms
names {
   "https://ontology.acme.example/fi/FI_0000417": "CouponRate"
}
opaqueLocalName: "^[A-Za-z]+_[0-9]+$"

// Classes whose individuals are a closed set
enums: ["https://ontology.acme.example/fi/Currency"]

// Classes that only wrap a value
collapse: ["https://ontology.acme.example/fi/Identifier"]

// Properties to keep as one type, even when unrelated classes use them
keepGeneric: []

// The class to use when an object property has no domain or range
missingDomain: "https://ontology.acme.example/party/Party"
missingRange: "https://ontology.acme.example/party/Party"
SettingWhat it does
source.filesThe ontology files, relative to the profile.
source.languageLabels and definitions in this language become docs. Text with no language counts too. Defaults to en.
namespacesMaps each ontology namespace to a Taxi namespace.
packagesGroups ontology modules into packages. Without it, there’s one package per owl:Ontology.
versionThe package version when owl:versionInfo isn’t a version number.
namesGives a term a name of your choice. This always wins.
opaqueLocalNameLocal names that match this pattern carry no meaning, so the name is built from the label instead.
unstatedCardinalitymany (the default) or optional: used when the ontology doesn’t say how many values a property has.
enumsClasses to import as enums. Each named individual becomes a constant.
collapseClasses to import as semantic types. Their subclasses become subtypes.
keepGenericDatatype properties not to split into one subtype per class.
missingDomain, missingRangeA class to use when an object property has no usable domain or range. Without them, such properties aren’t imported.
allowBreakingChangesAllow breaking changes without the --allow-breaking option.

An enums, collapse or keepGeneric entry that isn’t in the ontology is an error, so stale entries get noticed.

​
Generic properties

Some properties are used by unrelated classes. For example, hasName might be used by both Person and LegalEntity. One Name type would make a person’s name and a company’s name interchangeable. So the importer makes a subtype for each class, such as PersonName and LegalEntityName, marked @Synthesized. List the property under keepGeneric to turn this off.

​
The import report

The report says where every term and axiom ended up. Each line is in one of four groups:

  • Emitted: written to Taxi.
  • Collapsed: folded into another declaration, such as a value class becoming a semantic type.
  • Dropped and counted: has no Taxi equivalent yet, so was left out.
  • Needs a decision: the importer made a choice someone should check. Usually a profile entry resolves it.

Every line lists the ontology IRIs behind it, and the Taxi names it produced. The JSON version also has counts per group and per code.

Statements no rule used are counted too, so nothing disappears silently.

​
Keeping names stable

The ontology will keep changing. Other projects depend on the generated names, so a new release mustn’t rename things by accident.

The lock file records the Taxi name of every term. On the next run, the importer takes names from the lock file before applying any naming rule. So if a label is reworded, the name stays the same. An entry in the profile’s names still wins.

When you import a new release, the report lists what changed since the last import:

  • Added terms.
  • Deprecated terms. A term marked owl:deprecated true is still written, with @Deprecated and a line in its docs. If the ontology names a replacement (dcterms:isReplacedBy, or OBO’s “term replaced by”), it’s included.
  • Unchanged names with a changed label.
  • Breaking changes: terms that were removed, renamed, or became a different kind of declaration.

The report suggests a version for each package. With a breaking change, that’s the next major version.

A run with breaking changes only writes its report. Pass --allow-breaking to write the packages anyway.

The same ontology, profile and lock file always give exactly the same files.

​
Annotations

The generated Taxi uses three annotations, declared in the lang.taxi.formats.rdf namespace:

AnnotationMeaning
@Iri(value)The full IRI of the ontology term a declaration was imported from.
@SynthesizedA declaration the importer created, with no term of its own in the ontology.
@Deprecated(replacedBy)The ontology marks the term as deprecated. replacedBy is the replacement’s IRI, if there is one.

@Iri doesn’t change how Taxi compiles or how queries are planned. It records where each declaration came from.

​
What isn't supported yet

Some OWL constructs have no Taxi equivalent yet. The importer leaves them out and counts them in the report:

  • Relationship hierarchies. rdfs:subPropertyOf between object properties isn’t kept. Each relationship is imported on its own, and takes its domain and range from its parent when it has none.
  • Inverses. owl:inverseOf isn’t kept. Both directions are imported as separate relationships.
  • A union in a range. There’s no root concept to point to, so the property isn’t imported, unless the profile names a missingRange. A union in a domain gives one relationship per member, such as hasObligorOfBond and hasObligorOfLoan.
  • Logic for reasoners, such as owl:disjointWith, owl:propertyChainAxiom, owl:hasValue and owl:sameAs. Transitive, symmetric and reflexive markers are dropped, but the relationship is still imported.
  • Named individuals of classes that aren’t listed as enums. These are instance data.

Inferred statements

A defined class (owl:equivalentClass with an intersection) is imported as if its parts were written with rdfs:subClassOf. Nothing is classified into it automatically. Run a reasoner first if you need inferred statements.

Previous
Relationships
Next
Querying