sparql - retrieving a blank node used as a type -


i have ontology like:

:indi_1 :segment; [ :builds {:indi_2}]; :hasid 1. 

now want find individual(s) indi_1 builds. made following query:

select distinct ?a {:indi_1 ?b. ?b _:blanknode} 

but still segment in results. plus can't reach inside blank node retrive indi_2.

how should build query?

i don't know why you'd expect ?b :blanknode require ?b blank node. :blanknode blank node, in sparql query acts variable, it's requiring ?b has type. query written isn't legal. looks want :indi_1 ?b . ?b _:blanknode instead (note ., not ;).

at rate, check whether blank node, @ sparql 1.1 spec, , notice there's isblank function. that's you'd use filter results. you'd have this:

select * {   ?a ?b    filter isblank(?b) } 

but if you're looking list of individuals, need bit more closely @ rdf serialization of data. don't care ?b blank, rather it's restriction right properties. axiom like:

    :a builds {:b, :c}

you end rdf this:

:a            owl:namedindividual , owl:thing ;               [                  owl:restriction ;                   owl:allvaluesfrom  [          owl:class ;                                        owl:oneof  ( :c :b )                                      ] ;                   owl:onproperty     :builds                 ] . 

so query be:

prefix :      <http://www.example.org/> 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#>  select ?x ?y {   ?x [ owl:allvaluesfrom [ owl:oneof/rdf:rest*/rdf:first ?y ] ] . } 
----------- | x  | y  | =========== | :a | :c | | :a | :b | ----------- 

you can clean little bit more property paths:

select ?x ?y {   ?x rdf:type/owl:allvaluesfrom/owl:oneof/rdf:rest*/rdf:first ?y . } 

owl isn't same rdf. sparql rdf query language. owl can serialized rdf, serialization isn't pretty, sparql isn't best way query owl, though owl can serialized rdf. it's kind of searching text in document searching specific bytes or bits in file. might work, if change character encoding, have same text, different bytes or bits, query might not work anymore.


Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -