Works for me as expected when doing
OntModel m = ModelFactory.createOntologyModel();
String uri = "http://ex.org/A";
OntClass cls = m.createClass(uri);
cls.createIndividual(uri);
m.write(System.out, "Turtle");Result is @prefix owl: <http://www.w3.org/2002/07/owl#> . @prefix rdf:
<http://www.w3.org/1999/02/22-rdf-syntax-ns#> . @prefix rdfs:
<http://www.w3.org/2000/01/rdf-schema#> . @prefix xsd:
<http://www.w3.org/2001/XMLSchema#> . <http://ex.org/A> rdf:type
<http://ex.org/A> , owl:Class .
On 20.10.21 11:39, Steve Vestal wrote:
I am creating an OntClass but also want to pun that IRI, so that I
have an Individual with that same IRI that can be a member of a
class. Here is an example of doing that in OFN (a class that contains
itself, sort of but not really as I understand it), which works in
Protege.
Declaration( Class( :myClass ) )
ClassAssertion( :myClass :myClass )
When I try the following two approaches, I get an
org.apache.jena.ontology.ConversionException. How do I make the above
declarations using the Jena APIs?
// punnedClass is an OntClass to be punned
// containingClass is an OntClass to contain the Individual
interpretation of punnedClass
model.createIndividual(punnedClass.getURI(), containingClass);
containingClass.createIndividual(punnedClass.getURI());