Hi,

On 09/11/16 16:02, Jos Lehmann wrote:
Hi Dave & Lorenzo

thank you very much for your replies. I am still struggling with the code of the case 
with a singleton with "true" (CASE B below).

As in my code below, I (think I) can create the list with "true" as well an 
anonymous datatype. But then I can't link them by OWL.oneOf. In the code I am stalling from 
the lines marked ==>.

My intention would have been to define a link before the anonymous datatype and replace " 
OntClass.class " with " link " in the datatype definition. But that's not working.


CASE A

- in_category property should range over a singleton (Collection)
containing only #Bo,

You need to create an enumerated class (oneOf) containing #Bo (see
OntModel#createEnumeratedClass) and pass that class to the
allValuesFrom restriction.


CASE B

- is_XXX_type should  range over a singleton containing only the
Boolean value "true"
That's OWL2 which is not supported by Jena's convenience OntAPI. So
you'll need top do this at the RDF level - create an anonymous
instance of rdfs:Datatype, create a RDFList containing boolean true
then link them with an owl:oneOf property, then again pass that to
the allValuesFrom.


CODE

Individual thisInstance = (Individual) instances.next();

OntClass newClass = model2.createClass(thisInstance.toString());

DatatypeProperty is_XXX_type = 
model2.createDatatypeProperty("http://www._.net/ontologies/2016/XXXs_Ontology.owl#is_XXX_type";);
        
is_XXX_type.setRange(XSD.xboolean);
        
Literal tV = model2.createTypedLiteral(true);
        
RDFList list = model2.createList();           /* create a RDFList containing 
boolean true */
list = list.cons(tV);                                      /* create a RDFList 
containing boolean true */
                        
OntClass test = model2.createOntResource(OntClass.class, RDFS.Datatype,null);  
/* create an anonymous instance of rdfs:Datatype */

==> RDFNode link = list.getPropertyResourceValue(OWL.oneOf).as(RDFList.class);  
/* then link them with an owl:oneOf property */

Not sure I understand what you are trying to do with that link. I think you just want something like (untested):

    test.addProperty(OWL.oneOf, list);

Dave

Reply via email to