Wednesday, May 30, 2007

Default Namespaces considered harmful

In RDF, default namespaces are typically used to minimize the length of resource names. For example, if you have a resource http://www.aldi.de/products.owl#Haferflocken and define everything up to the # as your default namespace, then you can abbreviate the whole URI with "Haferflocken" only.

While this is very convenient in simple ontologies, things become quickly very confusing if you are building modular ontologies that span multiple namespaces and files. For our NASA work, we are dealing with ontologies that consist of 80 or more modules, all of which have their own namespaces. In such settings, using default namespaces is problematic because the same resources will be called under different names when you switch between files. For example if you are working in SPARQL and store your queries as part of a string-based query library, then the queries may reference resources sometimes as :Haferflocken and sometimes as aldi:Haferflocken, depending on whether a namespace is used or not. Depending on which is the main file, the queries may not work. Another problem is that if only a default namespace exists, and another file imports your ontology, then it is unclear what prefix to use for the external namespace. This leads to situations in which the same namespace is sometimes abbreviated "aldi" and sometimes "products".

Our recommended practice is to not use any default namespaces, but instead explicitly declare a prefix for that namespace inside of the file so that when someone wants to import your model you all have consistent namespaces. This prepares your models to be imported in a modular fashion down the road.

0 Comments:

Post a Comment

<< Home