On 08/11/16 14:02, Jos Lehmann wrote:
Hi there
I am new to jena and I'm trying the write the two following restrictions into
an owl (rdf/xml) ontology:
- 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.
- 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.
Dave
My code (below) cannot write the parts of the desired output (below) marked with
==>.
So far, I have been working to achieve the second part of the desired output
(i.e. the #is_XXX_type part), and that's my priority, but suggestions on the
first part would be welcome.
DESIRED OUTPUT
<owl:Class rdf:about="http://www._.net/ontologies/2016/XXXs_Ontology.owl#B7">
<rdfs:subClassOf
rdf:resource="http://www._.net/ontologies/2016/XXXs_Ontology.owl#B"/>
<rdfs:subClassOf
rdf:resource="http://www._.net/ontologies/2016/XXXs_Ontology.owl#T"/>
<rdfs:subClassOf>
<owl:Restriction>
<owl:onProperty
rdf:resource="http://www._.net/ontologies/2016/XXXs_Ontology.owl#in_category"/>
<owl:allValuesFrom>
==> <owl:Class>
==> <owl:oneOf rdf:parseType="Collection">
==> <rdf:Description
rdf:about="http://www._.net/ontologies/2016/XXXs_Ontology.owl#Bo"/>
==> </owl:oneOf>
==> </owl:Class>
</owl:allValuesFrom>
</owl:Restriction>
</rdfs:subClassOf>
<rdfs:subClassOf>
<owl:Restriction>
<owl:onProperty
rdf:resource="http://www._.net/ontologies/2016/XXXs_Ontology.owl#is_XXX_type"/>
<owl:allValuesFrom>
==> <rdfs:Datatype>
==> <owl:oneOf>
==> <rdf:Description>
==> <rdf:type
rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#List"/>
==> <rdf:first
rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">true</rdf:first>
==> <rdf:rest
rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"/>
==> </rdf:Description>
==> </owl:oneOf>
</rdfs:Datatype>
</owl:allValuesFrom>
</owl:Restriction>
</rdfs:subClassOf>
</owl:Class>
MY CODE (note: the new class is derived from an existing individual)
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);
Restriction restriction =
model2.createAllValuesFromRestriction(null, is_ XXX_type, XSD.xboolean);
newClass.addSuperClass(restriction);
MY PRESENT OUTPUT FOR THE is_XXX_type CASE:
<owl:Class rdf:about="http://www._.net/ontologies/2016/XXXs_Ontology.owl#B7">
<rdfs:subClassOf>
<owl:Restriction>
<owl:allValuesFrom
rdf:resource="http://www.w3.org/2001/XMLSchema#boolean"/>
<owl:onProperty>
<owl:DatatypeProperty
rdf:about="http://www._.net/ontologies/2016/XXXs_Ontology.owl#is_XXX_type"/>
</owl:onProperty>
</owl:Restriction>
</rdfs:subClassOf>
</owl:Class>
Thank you in advance for the advice.
Jos Lehmann
Knowledge Management
Bauhaus Luftfahrt e.V.
GERMANY