I'm writing a code generator that generate entities (POJO's in Java language) from the schema defined here http://schema.rdfs.org/all.ttl. I'm using Jena to parse the ttl file and retrieve the meta data that I need to generate them.
Jena parses the file successfully, however, for some reason it does not list all the attributes of a given entity, e.g., Person. I'm not sure whether I'm doing something wrong, using the wrong API, etc. Here's the code sample that recreates the scenario:
public class PersonParser {
public static void main(String[] args) {
OntModel model = ModelFactory.createOntologyModel();
URL url = Thread.currentThread().getContextClassLoader().getResource("schema_org.ttl");
model.read(url.toString(), "TURTLE");
OntClass ontclass = model.getOntClass("http://schema.org/Person");
Iterator<OntProperty> props = ontclass.listDeclaredProperties();
while (props.hasNext()) {
OntProperty p = props.next();
System.out.println("p:" + p.getLocalName());
}
}
}
Basically, I'm looking for only one class called Person and trying to list all its properties and what I get is:
p:alternateName
p:deathDate
p:alumniOf
p:sameAs
p:url
p:additionalName
p:homeLocation
p:description
p:nationality
p:sibling
p:follows
p:siblings
p:colleagues
p:memberOf
p:knows
p:name
p:gender
p:birthDate
p:children
p:familyName
p:jobTitle
p:workLocation
p:parents
p:affiliation
p:givenName
p:honorificPrefix
p:parent
p:colleague
p:additionalType
p:honorificSuffix
p:image
p:worksFor
p:relatedTo
p:spouse
p:performerIn
But if you look at http://schema.org/Person, it's got a bunch of properties that it did not list (for example address
). The declaration of schema:address
in http://schema.rdfs.org/all.ttl is:
schema:address a rdf:Property;
rdfs:label "Address"@en;
rdfs:comment "Physical address of the item."@en;
rdfs:domain [ a owl:Class; owl:unionOf (schema:Person schema:Place schema:Organization) ];
rdfs:range schema:PostalAddress;
rdfs:isDefinedBy <http://schema.org/Person>;
rdfs:isDefinedBy <http://schema.org/Place>;
rdfs:isDefinedBy <http://schema.org/Organization>;
.
Has anyone come across this? Should I be using a different Jena interface to parse the schema?