> I have a question; I would appreciate if someone helps me. > > I’m using SDB and MySQL as tripe store in my application. With the following > commands I try to format the database and load data into it. > $ bin/sdbconfig --sdb=sdb.ttl --format > $ bin/sdbload --sdb=sdb.ttl example.owl > > When I was trying to load an ontology file with OWL syntax I got error > because of syntax.
Jena doesn't understand OWL syntax; you have to use one of the RDF syntaxes (RDF/XML or Turtle etc). These encode the syntax of the OWL using additonal "anonymous" resources. > Then I changed the syntax of same file to RDF/XML using Protégé. The output > is like this: > <owl:Class > rdf:about="http://www.semanticweb.org/example.owl#LowProfitService"> > <rdfs:subClassOf > rdf:resource="http://www.semanticweb.org/example.owl#ServiceWithComingPrice > Increase"/> </owl:Class> > <owl:Axiom> > <perm:visibleBy>l5</perm:visibleBy> > <owl:annotatedSource > rdf:resource="http://www.semanticweb.org/example.owl#LowProfitService"/> > <owl:annotatedTarget > rdf:resource="http://www.semanticweb.org/example.owl#ServiceWithComingPrice > Increase"/> <owl:annotatedProperty rdf:resource="&rdfs;subClassOf"/> > </owl:Axiom> This is the RDF/XML representation of the RDF encoding of your OWL syntax. > This time loading of data into database was successful. > > Then I tried to fetch data from database using the following code: > > SDBConnection conn = newSDBConnection(jdbcConnection); > > Store store = StoreFactory.create(storeDesc, conn); > > Model model = SDBFactory.connectDefaultModel(store); > > OntModel ont = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM,model); > > StmtIterator sIter = ont.listStatements(); > > StmtIterator iter = model.listStatements(); > > while(iter.hasNext()) { > ... > } What this does is show you the raw form of every RDF triple in the database which is used to encode your OWL. > Here is what I can observe for the same section of same file: (fx:snip) > Here you can see what I got from database for the same Axiom in the file > with OWL syntax. SDB API added some additional resources in order to load > data into database. Well, no, it didn't; those additonal resources (the "blank nodes" or "anonymouse resources" which don't have names (URIs), just internal label IDS like -5dace940:13cfc2fda51:-7fdc) are inherent in the RDF encoding of OWL and are created when the parser reads the RDF/XML input. SDB doesn't know about OWL at all and doesn't add additional resources that aren't in the RDF. > What can I do with this output? Read it, grep it, forget it. It's not the output you're looking for. > How can I run Reasoner on this output? You can't. You run reasoners on the internal model, not on the toString()ed form of the model's triples. On OntModel can do inference, if you create it correctly (and the docs tell you how). > How > can I get rid of additional resources (In this example: > -5dace940:13cfc2fda51:-7fdc)? You don't want to -- they tell the reasoner about OWL structures. For example, OWL restrictions are encoded as anonynous resources having properties which name the restricted property and the cardinality values, etc. > Can anyone provide any better solution for loading data with OWL syntax to > not have the output of database like this? You've loaded the data in a correct way. You have chosen to create output in a way that you don't like, so create different output. For example you can write the model out as RDF/XML again -- the unparser will use RDF/XML syntax that leaves the blank nodes implicit just as they were in the input. (A gotcha -- by default, models that do inference don't write out their inferred triples when you use the usual .write() method; you have to use .writeAll() instead.) (A note: if you show us RDF/XML it helps if you show complete files, not snippets, because the first thing some of us to with large [1] chunks of RDF/XML is to convert it to Turtle using rdfcat or somethign similar, to make it easier to read ...) Chris [1] large can be, oh, five lines ...
