On 16/01/13 13:22, hlel emna wrote:
I add n-ary relation with this code:

[snip]

but, I do not know if this code is correct or not
Well, correctness is usually determined relative to a given set of requirements. Since you haven't said what the requirements are, we can't really say whether your code meets them or not.

However, I can make a couple of comments:

>  String ns ="http://www.w3.org/2002/07/owl#";
You should not do this. Only identifiers from the OWL standards documents (owl:Class, owl:ObjectProperty, etc) should use the OWL namespace.

>    OntClass d = m.createClass(ns+ "Date" );
Here you are creating your own representation for dates, rather than re-using the datatype (xsd:date) that is used by other RDF datasets. This isn't *wrong* per se, (see above), but it will make it harder to link your data with other datasets.

> Individual n1 = m.createIndividual( ns + "instance-n-ary", n );
By doing this, you are giving the n-ary instance an explicit URI. Again, this isn't *wrong* per se, but you have to create a new, different URI each time you assert the n-ary relation - otherwise, you'll end up with a horrible mess.

Better choices would be to use a bNode, like I did in my example gist, or generate a UUID, which will give you a new unique identifier each time you call it. For example:

String uuid = JenaUUID.generate().asURI();
Individual n1 = m.createIndividual( uuid, n );

Ian

Reply via email to