rdf - Multiple statements query SPARQL 1.1 property-paths Virtuoso 7.2.X -


a sample rdf dataset has entries owl#namedindividual grouped owl#class , custom relation named ismemberof. when try obtain list of results segregated type, works moment add way obtain corresponding ismemberof don't expected results.

here 3 sparql 1.1 queries gave virtuoso (sample dataset below):

query 1

sparql select * <test> { #if uncomment next line don't proper results #  ?s <ismemberof> ?member_of.   ?s rdfs:label ?name.   {     ?s rdf:type/rdfs:subclassof* <livingthings>.   } union {     ?s <rock>.   } }; 

query 2

sparql select * <test> { #if uncomment next line no results @ #   ?s <ismemberof> ?member_of.     ?s rdfs:label ?name.     ?s rdf:type/rdfs:subclassof* <livingthings>. }; 

query 3

sparql select * <test> {   ?s <ismemberof> ?member_of.   ?s rdfs:label ?name.   ?s rdf:type <dog>. #if replace previous line next line no results @ # ?s rdf:type/rdfs:subclassof* <livingthings>. }; 

this how data grouped:

livingthings ->mammal --->dog ----->doggy_the_dog ----->fido_the_dog --->cat ---->katy_the_cat --->elephant ----->eli_the_elephant ->reptile --->snake ----->snakey_the_snake nonlivingthings ->rock --->rocky_the_rock --->ralf_the_rock  group_a ->rocky_the_rock ->ralf_the_rock ->snakey_the_snake ->doggy_the_dog group_b ->fido_the_dog ->katy_the_cat group_c ->eli_the_elephant 

finaly here data used

sparql create silent graph <test>; sparql insert graph <test> {   <nonlivingthings> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#class>.   <nonlivingthings> <http://www.w3.org/2000/01/rdf-schema#label> "non-living things".   <rock> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#class>.   <rock> <http://www.w3.org/2000/01/rdf-schema#label> "rock".   <rock> <http://www.w3.org/2000/01/rdf-schema#subclassof> <nonlivingthings>.   <rocky_the_rock> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#namedindividual>.   <rocky_the_rock> <ismemberof> <group_a>.   <rocky_the_rock> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <rock>.   <rocky_the_rock> <http://www.w3.org/2000/01/rdf-schema#label> "rocky rock".   <ralf_the_rock> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#namedindividual>.   <ralf_the_rock> <ismemberof> <group_a>.   <ralf_the_rock> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <rock>.   <ralf_the_rock> <http://www.w3.org/2000/01/rdf-schema#label> "ralf rock".     <livingthings> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#class>.   <livingthings> <http://www.w3.org/2000/01/rdf-schema#label> "living things".   <mammal> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#class>.   <mammal> <http://www.w3.org/2000/01/rdf-schema#label> "mammal".   <mammal> <http://www.w3.org/2000/01/rdf-schema#subclassof> <livingthings>.   <reptile> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#class>.   <reptile> <http://www.w3.org/2000/01/rdf-schema#label> "reptile".   <reptile> <http://www.w3.org/2000/01/rdf-schema#subclassof> <livingthings>.   <dog> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#class>.   <dog> <http://www.w3.org/2000/01/rdf-schema#label> "dog".   <dog> <http://www.w3.org/2000/01/rdf-schema#subclassof> <mammal>.   <cat> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#class>.   <cat> <http://www.w3.org/2000/01/rdf-schema#label> "cat".   <cat> <http://www.w3.org/2000/01/rdf-schema#subclassof> <mammal>.   <elephant> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#class>.   <elephant> <http://www.w3.org/2000/01/rdf-schema#label> "elephant".   <elephant> <http://www.w3.org/2000/01/rdf-schema#subclassof> <mammal>.   <snake> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#class>.   <snake> <http://www.w3.org/2000/01/rdf-schema#label> "snake".   <snake> <http://www.w3.org/2000/01/rdf-schema#subclassof> <reptile>.   <snakey_the_snake> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#namedindividual>.   <snakey_the_snake> <ismemberof> <group_a>.   <snakey_the_snake> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <snake>.   <snakey_the_snake> <http://www.w3.org/2000/01/rdf-schema#label> "snakey snake".   <doggy_the_dog> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#namedindividual>.   <doggy_the_dog> <ismemberof> <group_a>.   <doggy_the_dog> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <dog>.   <doggy_the_dog> <http://www.w3.org/2000/01/rdf-schema#label> "doggy dog".   <fido_the_dog> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#namedindividual>.   <fido_the_dog> <ismemberof> <group_b>.   <fido_the_dog> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <dog>.   <fido_the_dog> <http://www.w3.org/2000/01/rdf-schema#label> "fido dog".   <katy_the_cat> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#namedindividual>.   <katy_the_cat> <ismemberof> <group_b>.   <katy_the_cat> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <cat>.   <katy_the_cat> <http://www.w3.org/2000/01/rdf-schema#label> "katy cat".   <eli_the_elephant> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#namedindividual>.   <eli_the_elephant> <ismemberof> <group_c>.   <eli_the_elephant> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <elephant>.   <eli_the_elephant> <http://www.w3.org/2000/01/rdf-schema#label> "eli elephant". }; 

why following incomplet result when uncomment ?s <ismemberof> ?member_of. in query one?

s               member_of   name rocky_the_rock  group_a     rocky rock ralf_the_rock   group_a     ralf rock 

all of results under <livingthings> class left out. because of bug in virtuoso or way sparql query formed?

virtuoso seems handle user defined relation oddly in query when mixed property path.

here virtuoso specific way address issue.

query 1 answer

sparql select * <test> {   ?s rdfs:label ?name.   {     ?s <ismemberof>{1} ?member_of.     ?s rdf:type/rdfs:subclassof* <livingthings>.   } union {     ?s <ismemberof>{1} ?member_of.     ?s <rock>.   } }; 

query 2 answer

sparql select * <test> {     ?s <ismemberof>{1} ?member_of.     ?s rdfs:label ?name.     ?s rdf:type/rdfs:subclassof* <livingthings>. }; 

applying explicit property path user defined relation such ?s <ismemberof>{1} ?member_of. gives expected results.

in query 1 line ?s <ismemberof>{1} ?member_of. applied each term inside each union element. if not results not desired. solve issue bit nonsensical. why i'll leave question open few days see if can provide logical explanation why things way in virtuoso. if it's bug i'll contact them via mailing list.


Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -