add RDFS inference rules support in endpoint SPARQL

803 views Asked by At

I have create an endpoint SPAQL on OpenLink Virtuoso. All work well, but i have to access on the data in a Container, in particular a rdf:Seq.

I have a Seq like this:

 <myrdf:has_stoptimes>
  <rdf:Seq rdf:about="http://test.com/343">
    <rdf:li>
      <myrdf:StopTime rdf:about="http://test.com/StopTime/434">
           ...
      </ns0:StopTime>
    </rdf:li>
    <rdf:li>
      <myrdf:StopTime rdf:about="http://test.com/StopTime/435">
           ...
      </ns0:StopTime>
    </rdf:li>
  </rdf:Seq>

Now i see that to access data in a container i can use rdfs:member or FILTER (strstarts(str(?prop), str(rdf:_)) how is explained here

But for my project i have to adopt the first solution because i'm working with Silk and i will use the code syntax like ?a/myrdf:has_stoptimes/rdfs:member without use of "complex" filter.

I have tried to follow this guide but querying the endpoint nothing work how i hoped.

So my question is: how can i query ?a/myrdf:has_stoptimes/rdfs:member on a Virtuoso endpoint SPARQL?Which inference rule i have to add in endpoint SPARQL?

Thank you in advance


UPDATE

I have created the following inference rules in Virtuoso:

ttlp (' @prefix rdfs:  .
        @prefix rdf:  .
  rdfs:Container rdf:type rdfs:Class ; rdfs:subClassOf rdfs:Resource .
  rdfs:ContainerMembershipProperty a rdfs:Class ; rdfs:subClassOf rdf:Property .
  rdf:Seq rdf:type rdfs:Class ; rdfs:subClassOf rdfs:Container .
  rdfs:member rdf:type rdf:Property ; rdfs:domain rdfs:Resource ; rdfs:range rdfs:Resource .
  ', '', 'http://localhost:8890/schema/test') ;

Nothing work querying the SPARQL endpoint like:

define input:inference "http://localhost:8890/schema/property_rules1"

       SELECT *
        FROM 
        WHERE {?sep a rdf:Seq.
        ?seq rdfs:member ?p}

After i tried adding the follow line to the ttl file: rdf:_1 rdfs:subPropertyOf rdfs:member . In this way it work but obviously the results are only for the first element of the container. So is very unconvenient add a line for all of rdf:_n, and i think this is only a temporary solution, it is not correct.

I have tried to add an RDF dump on SILK 2.6.1, and on the section SPARQL of the data source if i run the query:

 SELECT *
    FROM 
    WHERE {?sep a rdf:Seq.
    ?seq rdfs:member ?p}

I obtain the correct result, without specify any inference rules. So i think that in this functionality of SILK there is something that i’m missing in my endpoint SPARQL or am i saying nonsense things?

1

There are 1 answers

10
Joshua Taylor On

You can't use variables in property paths, so you can't actually do

?x ?a/has_stoptimes/rdfs:member ?y

Instead, you have to use another variable or blank node in between:

?x ?a ?z . ?z has_stoptimes/rdfs:member ?y

?x ?a [ has_stoptimes/rdfs:member ?y ] .