You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Jos Lehmann <Jo...@bauhaus-luftfahrt.net> on 2016/11/08 14:02:57 UTC

How to create restrictions that range on singleton collections or singleton datatypes

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,

- is_XXX_type should  range over a singleton containing only the Boolean value "true"



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






AW: AW: How to create restrictions that range on singleton collections or singleton datatypes

Posted by Jos Lehmann <Jo...@bauhaus-luftfahrt.net>.
Hi Dave

> Not sure I understand what you are trying to do with that link. 

Yeah... I was just modifying preexisting code.

> I think you just want something like (untested):
>     test.addProperty(OWL.oneOf, list);

That's what I was trying to do & it works. 

Thanks, Jos

Re: AW: How to create restrictions that range on singleton collections or singleton datatypes

Posted by Dave Reynolds <da...@gmail.com>.
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

AW: How to create restrictions that range on singleton collections or singleton datatypes

Posted by Jos Lehmann <Jo...@bauhaus-luftfahrt.net>.
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 */

==> Restriction restriction = model2.createAllValuesFromRestriction(null, is_XXX_type, test); /* then again pass that to the allValuesFrom. */
	        	        
newClass.addSuperClass(restriction);




Suggestions welcome. 

Cheers, Jos


-----Ursprüngliche Nachricht-----
Von: Lorenz B. [mailto:buehmann@informatik.uni-leipzig.de] 
Gesendet: Mittwoch, 9. November 2016 11:14
An: users@jena.apache.org
Betreff: Re: How to create restrictions that range on singleton collections or singleton datatypes

Ah, I didn't look at the RDF/XML snippet. Yes, then it's clear and your solution should work perfectly.

Cheers,
Lorenz
> Hi Lorenz,
>
> On 09/11/16 09:17, Lorenz B. wrote:
>> Hello Dave,
>>
>> my question would be whether he ask how to set this singleton 
>> enumeration as
>>
>> a) the range of the property or
>>
>> b) used in a class expression with
>>
>> b1) owl:hasValue or
>>
>> b2) like you suggested to use owl:allValuesFrom
>
> The example "desired output" RDF/XML seemed fairly clear that the goal 
> is to create an allValuesFrom restriction.
>
> Cheers,
> Dave
>
>>
>>
>>
>> Cheers,
>> Lorenz
>>
>>> 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:f
>>>> irst>
>>>>
>>>>
>>>> ==>                                <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/XXX
>>>> s_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_XX
>>>> X_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
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>
>
--
Lorenz Bühmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center



Re: How to create restrictions that range on singleton collections or singleton datatypes

Posted by "Lorenz B." <bu...@informatik.uni-leipzig.de>.
Ah, I didn't look at the RDF/XML snippet. Yes, then it's clear and your
solution should work perfectly.

Cheers,
Lorenz
> Hi Lorenz,
>
> On 09/11/16 09:17, Lorenz B. wrote:
>> Hello Dave,
>>
>> my question would be whether he ask how to set this singleton
>> enumeration as
>>
>> a) the range of the property or
>>
>> b) used in a class expression with
>>
>> b1) owl:hasValue or
>>
>> b2) like you suggested to use owl:allValuesFrom
>
> The example "desired output" RDF/XML seemed fairly clear that the goal
> is to create an allValuesFrom restriction.
>
> Cheers,
> Dave
>
>>
>>
>>
>> Cheers,
>> Lorenz
>>
>>> 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
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>
>
-- 
Lorenz Bühmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center



Re: How to create restrictions that range on singleton collections or singleton datatypes

Posted by Dave Reynolds <da...@gmail.com>.
Hi Lorenz,

On 09/11/16 09:17, Lorenz B. wrote:
> Hello Dave,
>
> my question would be whether he ask how to set this singleton enumeration as
>
> a) the range of the property or
>
> b) used in a class expression with
>
> b1) owl:hasValue or
>
> b2) like you suggested to use owl:allValuesFrom

The example "desired output" RDF/XML seemed fairly clear that the goal 
is to create an allValuesFrom restriction.

Cheers,
Dave

>
>
>
> Cheers,
> Lorenz
>
>> 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
>>>
>>>
>>>
>>>
>>>
>>>
>>

Re: How to create restrictions that range on singleton collections or singleton datatypes

Posted by "Lorenz B." <bu...@informatik.uni-leipzig.de>.
Hello Dave,

my question would be whether he ask how to set this singleton enumeration as

a) the range of the property or

b) used in a class expression with

b1) owl:hasValue or

b2) like you suggested to use owl:allValuesFrom



Cheers,
Lorenz

> 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
>>
>>
>>
>>
>>
>>
>
-- 
Lorenz Bhmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center


Re: How to create restrictions that range on singleton collections or singleton datatypes

Posted by Dave Reynolds <da...@gmail.com>.
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
>
>
>
>
>
>