I am _no_ SPARQL guru, but I think you might be able to do this without inference, with property paths:
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX owl: <http://www.w3.org/2002/07/owl#> PREFIX modelica: <http://mind-tap.net/kbswt/modelica#> SELECT ?instance ?label WHERE { ?instance rdf:type ?type. ?type rdfs:subClassOf+ modelica:BinaryExpression . ?type rdfs:label ?label. } --- A. Soroka The University of Virginia Library > On Dec 22, 2015, at 11:41 AM, Chris Snyder <[email protected]> wrote: > > I’m using the Jena OWL reasoner with this ontology: > http://www.mind-tap.net/kbswt/simple_no_inheritance.ttl > > I want to get the named individuals that are instances of a > modelica:BinaryExpression along with the rdfs:label of the class directly > implemented by the named individual. > > I hope there is a SPARQL guru who can help identify what I need to do. If > adding a Jena rule to the reasoner would help I have no problem going that > route either. > > In essence: > c subClassOf b > b subClassOf a > > c rdfs:label “class c” > b rdfs:label “class b” > a rdfs:label “class a” > > x typeOf c > x rdfs:label “instance x” > > I need to run a query to get: > “instance x”, “class c” > > but my SPARQL gives me: > “instance x”, “class c” > “instance x”, “class b” > “instance x”, “class a” > > I’ve tried some filter expressions but they wind up filtering out all the > results. I was thinking there is some path modifier that might work but > haven’t been successful going down that route either. > > My starter SPARQL: > > PREFIX modelica: <http://mind-tap.net/kbswt/modelica#> > PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> > PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> > PREFIX : <http://mind-tap.net/kbswt/simple_no_inheritance#> > > select distinct * { ?s rdfs:subClassOf modelica:BinaryExpression ; > rdfs:label ?equationName . > ?i a ?s. > } > ORDER BY ?i > > Thanks in advance, > Chris > >
