开发者

How to load an in-memory model based on an ontology using Jena framework?

I am wondering how to, from an ontology using Jena framework, load a model in which I will retrieve the exact same semantic defined in the ontology. I found about Jean ontology API giving the possibility to work on ontology models, classes, etc.

Then giving the following example :

<owl:Class rdf:ID="DigitalCamera">
  <rdf:type owl:ObjectProperty />
</owl:Class>

It is possible to do :

Resource r = myModel.getResource( myNS + "DigitalCamera" );
OntClass cls = (OntClass) r.as( OntClass.class );

However I am searching to get my hands directly on DigitalCamera class/instances and not passing through OntClass开发者_StackOverflow or Resource as followed :

DigitalCamera camera = new DigitalCamera();

Then when searching for a certain property of that camera, I could access directly it and stay focus on the semantic of the datas like a DSL. Does Jena propose this kind of dedicated (generated ?) framework representing whatever ontology?

Thanks


There's a conceptual problem doing what you are asking for, which is that a strength of RDF is that the data model is malleable. This is sometimes expressed as "anyone can say anything about anything". In other words, your application state is entirely defined by what is in the graph at any one time. Suppose resource r currently has rdf:type foaf:Person, it's perfectly possible and legal for that graph to change so that r has, say, rdf:type skos:Concept instead. Or, indeed, to be both. Hence using some sort of ORM to represent a resource as an unchanging Java class Person or Concept risks becoming incomplete or stale. This is (partly) why Jena doesn't do that: state in Jena is entirely based on what's in the RDF graph.

That said, if you are willing to accept this risk, or you know that in your application there is little or no chance that the mapping from resource URI's to Java object classes will change radically, there are some Jena extensions that can help you. I'd suggest looking at JenaBean as one example.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜