How to set prefix when building New Ontology with OWLReady2 for cleaner RDF/XML??

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How to set prefix when building New Ontology with OWLReady2 for cleaner RDF/XML??

MartyStache
I’m using OWLReady2 to build an Ontology from the ground up.

Is there a way to set the prefix for my onto namespace when building an ontology in OWLReady2? I would like my RDF/XML to generate like the desired output (so Equipment class looks tight with label and comment, no URIs), rather than the output I’m getting below. Would creating a blank/base RDF/XML file with the DOCTYPE and Prefix elements first on my file system and import that at the start accomplish what I need? I’m going to test myself to see, just thought there may be another method?

DESIRED OUTPUT:

<!DOCTYPE rdf:RDF [
     <!ENTITY ont  "http://test.org/ont#" >
     <!ENTITY owl  "http://www.w3.org/2002/07/owl#" >
     <!ENTITY xsd  "http://www.w3.org/2001/XMLSchema#" >
 ]>

<rdf:RDF
  xmlns     = "http://test.org/ont#"
  xmlns:ont = "http://test.org/ont#"
  xml:base  = "http://test.org/ont#"
  xmlns:owl = "http://www.w3.org/2002/07/owl#"
  xmlns:rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  xmlns:rdfs= "http://www.w3.org/2000/01/rdf-schema#"
  xmlns:xsd = "http://www.w3.org/2001/XMLSchema#">

 <owl:Ontology rdf:about="http://test.org/ont"/>

  <owl:Class rdf:ID="Equipment">
    <rdfs:label>Equipment</rdfs:label>
    <rdfs:comment>the necessary items for a particular purpose.</rdfs:comment>
  </owl:Class>
</rdf:RDF>

THIS IS THE CURRENT CODE AND OUTPUT from OWLReady2:

CURRENT CODE:

from owlready2 import *

onto = get_ontology("http://test.org/ont") # this is a fictituous URI so I can build ontology from scratch. I’m not indicating prefix anywhere

with onto:
        class Equipment(Thing):
                pass
        Equipment.comment=["the necessary items for a particular purpose."]

CURRENT OUTPUT:

<rdf:RDF xmlns="http://test.org/ont#"
     xml:base="http://test.org/ont"
     xmlns:="http://test.org/ont#"
     xmlns:owl="http://www.w3.org/2002/07/owl#"
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
     xmlns:xml="http://www.w3.org/XML/1998/namespace"
     xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
     xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
     
    <owl:Ontology rdf:about="http://test.org/ont"/>
   
    <owl:Class rdf:about="http://test.org/ont#Equipment">
        <rdfs:comment rdf:datatype="http://www.w3.org/2001/XMLSchema#string">the necessary items for a particular purpose.</rdfs:comment>
    </owl:Class>
</rdf:RDF>
Reply | Threaded
Open this post in threaded view
|

Re: How to set prefix when building New Ontology with OWLReady2 for cleaner RDF/XML??

Jiba
Administrator
Hi,

Currently, Owlready uses arbitrary prefixes.

Creating a blank/base RDF/XML file with the desired prefixes is not a solution, because prefixes are not RDF triples and thus they are not read and stored.

Probably we need to add a "prefixes" parameter to the save() method.

Jiba