Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Query over BNodes doesn't work #110

Open
white-gecko opened this Issue · 1 comment

3 participants

@white-gecko

When I have some data with BNodes I experience a strange behavior of Virtuoso.

Here you see two TTL files (Data 1 with BNode fails, Data 2 with named node works).

Data 1:

@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 ex:     <http://example.com/> .

ex:a rdf:type        owl:Class ;
     rdfs:subClassOf ex:b ,
                     [
                        rdf:type owl:Restriction ;
                        ex:prop "hallo"
                     ] .

Data 2:

@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 ex:     <http://example.com/> .

ex:a rdf:type        owl:Class ;
     rdfs:subClassOf ex:b ,
                     ex:c .

ex:c rdf:type owl:Restriction ;
     ex:prop "hallo" .

The problem occurs, when querying Data 1:
If I send Query 1 I get the correct result as expected. But when I send Query 2 I get no result at all, and for Query 3 ?p and ?o are also empty. But as soon as I send Query 4 I see that the data I have queried for exists.

Query 1:

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX ex: <http://example.com/>

SELECT ?a ?b
WHERE {
    ?a rdfs:subClassOf ?b.
}

Query 2:

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX ex: <http://example.com/>

SELECT ?a ?b ?p ?o
WHERE {
    ?a rdfs:subClassOf ?b.
    ?b ?p ?o .
}

Query 3:

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX ex: <http://example.com/>

SELECT ?a ?b ?p ?o
WHERE {
    ?a rdfs:subClassOf ?b.
    OPTIONAL {
        ?b ?p ?o .
    }
}

Query 4:

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX ex: <http://example.com/>

SELECT ?a ?b ?p ?o
WHERE {
    {
        ?a rdfs:subClassOf ?b.
    } UNION {
        ?b a owl:Restriction ;
           ?p ?o .
    }
}

The same set of queries and data works with ARC2 and returns the expected results.

@HughWilliams
Collaborator

You need to use the Virtuoso inference context pragma which invokes an inference rule for these rdf classes as described at:

http://docs.openlinksw.com/virtuoso/rdfsparqlrule.html

@iv-an-ru iv-an-ru was assigned by openlink
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.