Skip to content

External Ontologies

OWL ontologies frequently reference external vocabularies via owl:imports statements or namespace prefixes. OWL-SDA can automatically fetch, parse, and cache these external models so that the reasoner and SHACL generator have access to all imported definitions.

Configuration

yaml
extract:
  connect-timeout-ms: 2000
  read-timeout-ms: 5000
  max-retries: 1
  follow-redirects: true
  user-agent: "owlsda/1.0"
  cache-enabled: true
  cache-ttl-ms: 3600000      # 1 hour
  cache-max-entries: 100
  cache-dir: "target/cache/ontology-extract-external"
  cache-format: "TURTLE"
  mirrors: []
KeyTypeDefaultDescription
connect-timeout-msint2000HTTP connection timeout in milliseconds.
read-timeout-msint5000HTTP read timeout in milliseconds.
max-retriesint1Number of additional attempts after the first failure.
follow-redirectsbooleantrueWhether HTTP redirects are followed automatically.
user-agentstringowlsda/1.0User-Agent header sent with HTTP requests.
cache-enabledbooleantrueEnable on-disk caching of resolved ontologies.
cache-ttl-mslong3600000Maximum age of a cached entry in milliseconds. 0 = never expire.
cache-max-entriesint100Maximum number of entries in the in-memory cache.
cache-dirstringtarget/cache/…Directory for on-disk cached ontology files.
cache-formatstringTURTLERDF serialisation format used for the on-disk cache.
mirrorslist[]URI-to-mirror mappings. See Mirrors below.

How It Works

When the ontology is loaded, OWL-SDA scans for:

  1. owl:imports triples — direct ontology imports declared in the file.
  2. Namespace prefix URIs — all namespace prefixes defined in the ontology.

For each URI it tries to resolve a model in this order:

  1. In-memory cache (within the current run).
  2. On-disk file cache (cache-dir).
  3. HTTP fetch (with retry and redirect support).

Successfully fetched models are written to the on-disk cache for future runs.

Mirrors

Some ontology URIs are unreliable or offline. You can map any URI to one or more mirror URLs:

yaml
extract:
  mirrors:
    - uri: "http://www.w3.org/ns/prov#"
      mirrors:
        - "https://www.w3.org/ns/prov-o"
    - uri: "http://xmlns.com/foaf/0.1/"
      mirror: "https://xmlns.com/foaf/spec/index.rdf"

Both mirrors (list) and mirror (single string) are accepted. Prefix matching is also supported, so a mirror entry for http://example.org/ applies to any URI starting with that prefix.

Supported Formats

The extractor recognises the Content-Type header returned by the server and falls back to filename extension heuristics:

Content-TypeExtensionFormat
text/turtle, application/x-turtle, application/turtle, text/ttl(default)Turtle
application/ld+json, application/json.jsonld, .jsonJSON-LD
application/rdf+xml, application/xml, text/xml.rdf, .xmlRDF/XML
application/n-triples, application/ntriples, text/plain.nt, .ntriplesN-Triples
text/n3.n3N3

The two heuristics are independent. The Content-Type header is tried first; if it is missing or unrecognised, the extension is used instead. A reference matching no extension is parsed as Turtle. If parsing produces an empty model the extractor retries with the other formats, so a server that mislabels its content usually still works.

Released under the GNU General Public License v3.0.