Re: How to set data type for OWL restriction using Apache Jena?

2016-10-11 Thread Darko Androcec
Thanks Dave, I managed to solve my problem by using the following code 
to add needed triples:


 MaxCardinalityRestriction restriction = 
model.createMaxCardinalityRestriction(null, existingDataProperty, 1);

restriction.removeAll(OWL.cardinality);
restriction.addLiteral(OWL2.maxQualifiedCardinality, 1);
restriction.addProperty(OWL2.onDataRange, XSD.xstring);
itemClass.addSuperClass(restriction);

Best regards,

Darko


On 9.10.2016. 18:17, Dave Reynolds wrote:


As that quote says, Jena doesn't support OWL 2 which is where 
DataRange is defined.


That just means there's not convenience functions but you can still 
achieve the desired affect by working at the RDF level, it's just 
verbose. Look up the OWL 2 specs to see what RDF triples are needed to 
represent your desired DataRange, then use the general Model API to 
assert those triples.


Dave






Re: How to set data type for OWL restriction using Apache Jena?

2016-10-09 Thread Dave Reynolds

On 08/10/16 22:15, Darko Androcec wrote:

Hi,

I have got this suggestion on StackOverFlow:

"OWL max cardinality is not a restriction on the datatype as you already
recognized. What you're after is known as OWL data range, in particular,
FacetRestriction: w3.org/TR/owl2-syntax/#Data_Ranges . Note, the
Ontology API is not complete for OWL 2 (at least that's what I read some
years ago). I can see an interface DataRange, but it has only support
for OneOf: jena.apache.org/documentation/javadoc/jena/org/apache/jena/… –
  I think, you should ask this on the Jena mailing list, maybe there is
also support for min, max, etc."

Do you maybe know whether Apache Jena has functionality to achieve what
I need to do in my case (described in my previous message and copied
bellow?


As that quote says, Jena doesn't support OWL 2 which is where DataRange 
is defined.


That just means there's not convenience functions but you can still 
achieve the desired affect by working at the RDF level, it's just 
verbose. Look up the OWL 2 specs to see what RDF triples are needed to 
represent your desired DataRange, then use the general Model API to 
assert those triples.


Dave


On 8.10.2016. 1:25, Darko Androcec wrote:

Hi,

I have one urgent problem with Apache Jena, I have posted my question
on StackOverflow
(http://stackoverflow.com/questions/39926809/how-to-set-data-type-for-owl-restriction-using-apache-jena?sem=2).
If someone knows answer, please answer it here or on StackOverflow.

The copied question is bellow:

I am using Apache Jena. I have created the data property, its range as
xsd:string and restriction that is added as a superclass to specific
(already created) class:

|DatatypeProperty dataProperty = model.createDatatypeProperty(baseURI
+ possibleProperty); dataProperty.setRange(XSD.xstring);
MaxCardinalityRestriction restriction =
model.createMaxCardinalityRestriction(null, dataProperty, 1);
itemClass.addSuperClass(restriction); |

When I open the generated ontology in Protege the mentioned
restriction looks like:

|DataProperty_Name max 1 Literal |

My aim is to get it with included data type (that is specified in the
range of the data property), e.g. I am expecting:

|DataProperty_Name max 1 string or |||DataProperty_Name max 1 decimal
etc.| |

Application that uses the ontology needs to know restriction's data
type. Do you maybe know what I need to change in my code to get data
type (e.g. string) in the restriction instead of Literal?

Thanks, Darko







Re: How to set data type for OWL restriction using Apache Jena?

2016-10-08 Thread Darko Androcec

Hi,

I have got this suggestion on StackOverFlow:

"OWL max cardinality is not a restriction on the datatype as you already 
recognized. What you're after is known as OWL data range, in particular, 
FacetRestriction: w3.org/TR/owl2-syntax/#Data_Ranges . Note, the 
Ontology API is not complete for OWL 2 (at least that's what I read some 
years ago). I can see an interface DataRange, but it has only support 
for OneOf: jena.apache.org/documentation/javadoc/jena/org/apache/jena/… –
  I think, you should ask this on the Jena mailing list, maybe there is 
also support for min, max, etc."


Do you maybe know whether Apache Jena has functionality to achieve what 
I need to do in my case (described in my previous message and copied bellow?


Thanks,

Darko


On 8.10.2016. 1:25, Darko Androcec wrote:

Hi,

I have one urgent problem with Apache Jena, I have posted my question 
on StackOverflow 
(http://stackoverflow.com/questions/39926809/how-to-set-data-type-for-owl-restriction-using-apache-jena?sem=2). 
If someone knows answer, please answer it here or on StackOverflow.


The copied question is bellow:

I am using Apache Jena. I have created the data property, its range as 
xsd:string and restriction that is added as a superclass to specific 
(already created) class:


|DatatypeProperty dataProperty = model.createDatatypeProperty(baseURI 
+ possibleProperty); dataProperty.setRange(XSD.xstring); 
MaxCardinalityRestriction restriction = 
model.createMaxCardinalityRestriction(null, dataProperty, 1); 
itemClass.addSuperClass(restriction); |


When I open the generated ontology in Protege the mentioned 
restriction looks like:


|DataProperty_Name max 1 Literal |

My aim is to get it with included data type (that is specified in the 
range of the data property), e.g. I am expecting:


|DataProperty_Name max 1 string or |||DataProperty_Name max 1 decimal 
etc.| |


Application that uses the ontology needs to know restriction's data 
type. Do you maybe know what I need to change in my code to get data 
type (e.g. string) in the restriction instead of Literal?


Thanks, Darko