I found the solution. 

The key is : 
val MaryTojohnClaimOnto = model.createOntology(ontoName)

here is what i did:

        val ontoName                     = 
"http://www.people.usi.ch/okouyad/Mary_to_john_Claim_01.owl";
        val model                                = 
ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM)            
        val MaryTojohnClaimOnto = model.createOntology(ontoName)
                

        private val MaryRepoOntoPrefix = 
"http://www.people.usi.ch/okouyad/MaryRepositoryOntology.owl#";
        private val payDeliverPrefix        = 
"http://www.people.lu.unisi.ch/okouyad/PayDeliveryOntology.owl#";

        model.setNsPrefix("", ontoName + "#")
        model.setNsPrefix("MaryRepoOnto", MaryRepoOntoPrefix)
        model.setNsPrefix("PayDelivery", payDeliverPrefix)

                
                        
        private val indiv                  = 
model.createResource(MaryRepoOntoPrefix  + "Lord_of_the_Ring")
        private val hasPriceProperty = model.createProperty(payDeliverPrefix    
+ "hasPrice")
                
                
        indiv.addLiteral(hasPriceProperty, 15)

        //model.write(System.out);
        RDFDataMgr.write(System.out, model, Lang.TTL)



Meanwhile i get this and i write it down: 

@prefix :      <http://www.people.usi.ch/okouyad/Mary_to_john_Claim_01.owl#> .
@prefix rdfs:  <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xsd:   <http://www.w3.org/2001/XMLSchema#> .
@prefix owl:   <http://www.w3.org/2002/07/owl#> .
@prefix rdf:   <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix PayDelivery: 
<http://www.people.lu.unisi.ch/okouyad/PayDeliveryOntology.owl#> .
@prefix MaryRepoOnto: 
<http://www.people.usi.ch/okouyad/MaryRepositoryOntology.owl#> .

MaryRepoOnto:Lord_of_the_Ring
        PayDelivery:hasPrice  "15"^^xsd:long .

<http://www.people.usi.ch/okouyad/Mary_to_john_Claim_01.owl>
        a       owl:Ontology .


I find it weird that the ontology triple comes at the end. If i create an 
analogue file with protege and loads it, and write it down, the ontology 
declaration triple get written at the beginning as everyone would expect. I 
think it is a code smell. 

Any idea ? is something going wrong ?


-- 
Daniel Maatari Okouya
Sent with Airmail
From: Daniel Maatari Okouya Daniel Maatari Okouya
Reply: [email protected] [email protected]
Date: January 4, 2014 at 4:40:59 PM
To: [email protected] [email protected]
Subject:  How to create a jena Model with a specific URI ?  
Hi,   

I would like to know how to create a Jena Ontology model with a given URI.   

all the example are about loading a model and getting the urL from it. I would 
like to do the contrary, create the model with a specific URI and save it with 
that URI.   

a.k.a with the rdfabout or owlOntology tag properly set with the URI that i 
want: the IRI/URI of my ontology  

Any help ?  

--   
Daniel Maatari Okouya  
Sent with Airmail

Reply via email to