Hi,

First I would like to appreciate this community where I am receiving a lot
of help.

I have a query would like to get answers but a variable predicate.

The dataset is:
```
# Insert Triples
sparql

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

insert data {
graph <urn:proptest> {
:PropB a owl:TransitiveProperty.
:PropB1 rdfs:subPropertyOf :PropB.
:PropB2 rdfs:subPropertyOf :propB1.

:b a :EntityB.
:b1 a :EntityB.
:b2 a :EntityB.
:aaa a :EntityB;
     :propB :b;
     :propB1 :b1;
     :propB2 :b2.
}
};
```
Basically there is "aaa" who is related to "b", "b1", "b2" with "PropB",
"PropB1", "PropB2". And they have a hierarchy as PropB2 is a sub property
of PropB1 that is a sub property of PropB.

However, below query does not return anything:
```
sparql
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 : <http://example.com#>

select ?s ?p ?o from <urn:proptest> where {
?p rdfs:subPropertyOf* :PropB.
?s ?p ?o.
};
```

So I added reasoning rules based on Kingsley's previous comment.

Here's the rule graph:
```
sparql
prefix owl: <http://www.w3.org/2002/07/owl#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix : <http://example.com#>

insert data {
graph <urn:proptest:rules> {
:PropB a owl:TransitiveProperty.
:PropB1 rdfs:subPropertyOf :PropB.
:PropB2 rdfs:subPropertyOf :propB1.
}
};
```

Then I inserted the rule with a command:
``rdfs_rule_set ('urn:proptest:rules', 'urn:proptest:rules') ;``

Then I enabled the rule in the query:
```
sparql
DEFINE input:inference 'urn:proptest:rules'
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 : <http://example.com#>

select ?s ?p ?o from <urn:proptest> where {
?p rdfs:subPropertyOf* :PropB.
?s ?p ?o.
};
```
But still it does not return anything.

I am not sure if the query is valid in SPARQL or there is something I miss
in Virtuoso.

If there is anything that I can learn about, please let me know.

Thank you!


With regards,
Jason Koh
cseweb.ucsd.edu/~jbkoh
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Virtuoso-users mailing list
Virtuoso-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/virtuoso-users

Reply via email to