Proposed: Ontology Serialization V0.2

Version History

Version

Date

Comment

Lead Editor

Contributors

Version

Date

Comment

Lead Editor

Contributors

0.1

 2024-04-05

First version

@Jim Logan

@Elisa Kendall

0.2

2024-05-15

Revision to add references

 

@Elisa Kendall

0.3

2024-07-18

Added more rules and Protege instructions

@Jim Logan

@Jim Logan

Contents

Overview

This document captures what are considered best practices for serializing ontologies, so that they can be version controlled most efficiently using git. Doing so requires a canonical ordering of lines within each ontology file.

The following rules MUST be followed when reviewing this document, these are taken from IETF RFC 2119 (simplified):

  1. MUST: This word means that the definition is an absolute requirement of the specification.

  2. MUST NOT: This phrase means that the definition is an absolute prohibition of the specification.

  3. SHOULD: This word means that there may exist valid reasons in particular circumstances to ignore a particular item, but the full implications MUST be understood and carefully weighed before choosing a different course.

  4. SHOULD NOT: This phrase means that there may exist valid reasons in particular circumstances when the particular behavior is acceptable or even useful, but the full implications should be understood and the case carefully weighed before implementing any behavior described with this label.

  5. MAY: This word means that an item is truly optional. One vendor may choose to include the item because a particular marketplace requires it or because the vendor feels that it enhances the product while another vendor may omit the same item.

Syntax

According to the OWL 2 Web Ontology Language Document Overview (Second Edition), the primary exchange syntax for OWL 2 is RDF/XML. Therefore, every IOF ontology MUST be serialized in the RDF/XML syntax, using more specific rules explained in the subsequent sections.

Base IRI

According to XML Base, W3C Recommendation., the xml:base attribute of an XML element determines an IRI prefix to be prepended to every relative IRI used in any nested XML element. The following provides a fictitious example of how this mechanism works:

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE rdf:RDF [ <!ENTITY bfo "http://purl.obolibrary.org/obo/"> ]> <rdf:RDF xml:base="https://spec.industrialontologies.org/ontology/core/Core/" xmlns:bfo="http://purl.obolibrary.org/obo/" xmlns:iof-core="https://spec.industrialontologies.org/ontology/core/Core/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" > <owl:Class rdf:about="AgentRole"> <rdfs:subClassOf rdf:resource="&bfo;BFO_0000023"/> </owl:Class> </rdf:RDF>

The value of the rdf:about attribute on line 10 would be appended to the xml:base attribute provided on line 5 to yield the IRI https://spec.industrialontologies.org/ontology/core/Core/AgentRole.

In order to ensure that the correct IRI is prepended to the value of every relative IRI in an IOF ontology, the xml:base attribute of the rdf:RDF XML element in every ontology file MUST have the ontology IRI as its value.

Default Namespace

Every IOF ontology MUST NOT declare a default namespace to ensure that no XML element is inadvertently put into the wrong namespace.

According to Namespaces in XML 1.0 (Third Edition), W3C Recommendation, the default namespace of an XML element determines the namespace of every nested XML element that does not have an explicit namespace. The following provides an example that is technically legal, but disallowed by this policy:

<rdf:RDF xml:base="https://spec.industrialontologies.org/ontology/systemsengineering/SystemsEngineering/" xmlns="http://www.w3.org/2002/07/owl#" xmlns:iof-se="https://spec.industrialontologies.org/ontology/systemsengineering/SystemsEngineering/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" > <Ontology rdf:about="https://spec.industrialontologies.org/ontology/systemsengineering/SystemsEngineering/"> </Ontology> <Class rdf:about="&iof-se;AbstractSyntax"> <rdfs:subClassOf rdf:resource="&iof-se;Syntax"/> </Class> </rdf:RDF>

Note that the default namespace declaration on line 2 technically make the elements Ontology (lines 6 and 7) and Class (lines 9 and 11) into the fully qualified IRIs http://www.w3.org/2002/07/owl#Ontology and http://www.w3.org/2002/07/owl#Class, respectively, however, the use of any other non-OWL, unqualified XML element would inadvertently put that element into the OWL namespace, which is a violation of best practices for data governance generally, and goes against practices outlined in various W3C Recommendations and other documents, including but not limited to Cool URIs for the Semantic Web .

In order to ensure that every XML element is put into the correct namespace, every IOF ontology MUST NOT declare a default namespace (such as the one on line 2, above). Expressed another way, every occurrence of “xmlns” MUST be followed by a colon (“:”) and a namespace prefix (such as the ones on lines 3 and 4).

Ontology Namespace Prefix

Every ontology MUST define a short, unique, meaningful, ontology-namespace prefix, such as “iof-se” on line 3, above.

Tools

Every local git repository (i.e., the one on your computer) that pushes changes to the IOF GitHub repository MUST have the EDM Council RDF Toolkit installed, such that every time an RDF/XML file is committed, that file will be automatically rewritten to conform to the policies in this document. The instructions for installing that toolkit can be found at that link.

What to do in Protégé

Protégé always saves an ontology with a default prefix of the ontology IRI, as shown in the following screen shot, and, by default, violates the Ontology Namespace Prefix rule, above. In order to conform to the rules in this document, press the circle icon in the upper right and give that prefix a name.

image-20240718-154515.png
An example default namespace that Protege has automatically created

Voting

Member

Vote

Comments

Member

Vote

Comments

1

 

 

 

2

 

 

 

3

 

 

 

4

 

 

 

5

 

 

 

6

 

 

 

7

 

 

 

8

 

 

 

9

 

 

 

10

 

 

 

11

 

 

 

12

 

 

 

13

 

 

 

14

 

 

 

15

 

 

 

16

 

 

 

17

 

 

 

18

 

 

 

19

Total

YES: 0, NO: 0, No Response: 0