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 ontology | In Taxi |
|---|---|
owl:Class | A concept, carrying the class’s IRI in @Iri |
rdfs:subClassOf a named class | inherits (several parents are allowed) |
rdfs:label, skos:definition, skos:altLabel | Docs on the declaration |
owl:DatatypeProperty | A semantic type, such as type Isin inherits String |
| A restriction on a datatype property | A member of the concept, such as Isin or MaturityDate? |
rdfs:subPropertyOf between datatype properties | Type inheritance |
owl:ObjectProperty | A relationship |
| A restriction on an object property | A narrowing line in the concept, such as hasIssuer -> BondIssuer |
| A class whose individuals are a closed set | An enum (listed in the profile, or defined with owl:oneOf) |
| A class that only wraps a value, such as an identifier | A semantic type (listed in the profile) |
owl:Ontology | A Taxi package, with its own taxi.conf |
How many values
Cardinality comes from the restrictions on a class:
| The ontology says | Taxi member |
|---|---|
| Exactly one | Isin |
| At most one, or the property is functional | Isin? |
At least one, or owl:someValuesFrom | Isin[] |
| Nothing about how many | Isin[] (the profile can make this Isin?) |
| Any other number | Isin[], 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, sohasIsinbecomesIsin. 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. hasIsinis exactly one, so the member isIsin.hasMaturityDateis at most one, so it’sMaturityDate?.hasIssueris 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.confand its sources undersrc/. - A
taxi/rdf-annotationspackage that declares@Iriand the other annotations. Every generated package depends on it. - The import report, printed and saved as
import-report.txtandimport-report.json. - The lock file,
ontology-import.lock.json, next to the profile.
| Option | What it does |
|---|---|
--profile | The profile file. Required. |
--output | The directory to write to. Required. |
--lock | The lock file to read and write. Defaults to the one named in the profile. |
--baseline-report | A JSON report from an earlier import. The command fails if more lines need a decision now. |
--allow-breaking | Write 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"| Setting | What it does |
|---|---|
source.files | The ontology files, relative to the profile. |
source.language | Labels and definitions in this language become docs. Text with no language counts too. Defaults to en. |
namespaces | Maps each ontology namespace to a Taxi namespace. |
packages | Groups ontology modules into packages. Without it, there’s one package per owl:Ontology. |
version | The package version when owl:versionInfo isn’t a version number. |
names | Gives a term a name of your choice. This always wins. |
opaqueLocalName | Local names that match this pattern carry no meaning, so the name is built from the label instead. |
unstatedCardinality | many (the default) or optional: used when the ontology doesn’t say how many values a property has. |
enums | Classes to import as enums. Each named individual becomes a constant. |
collapse | Classes to import as semantic types. Their subclasses become subtypes. |
keepGeneric | Datatype properties not to split into one subtype per class. |
missingDomain, missingRange | A class to use when an object property has no usable domain or range. Without them, such properties aren’t imported. |
allowBreakingChanges | Allow 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 trueis still written, with@Deprecatedand 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:
| Annotation | Meaning |
|---|---|
@Iri(value) | The full IRI of the ontology term a declaration was imported from. |
@Synthesized | A 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:subPropertyOfbetween 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:inverseOfisn’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 ashasObligorOfBondandhasObligorOfLoan. - Logic for reasoners, such as
owl:disjointWith,owl:propertyChainAxiom,owl:hasValueandowl: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.