How to get the data property assertion value using SPARQL?

343 Views Asked by At

I tried to make the below ontology. I want the data property assertion value using SPARQL.

I tried to make the query:

prefix ab:<http://www.semanticweb.org/bhuiyanh/ontologies/2019/8/untitled-ontology-38#>

SELECT ?AV ?lane
WHERE {
  ?AV ab:Driving ab:N_Time_1.
  ab:N_Time_1 ab:Driving ?lane.
}

I want the result like this:

AV  Lane
AV1  1
1

There are 1 best solutions below

0
user0221441 On

I do not have enough reputation to comment, so here's what could work.

Try casting the lane variable as an integer, because literals of the form "1"^^xsd:integer are often written as 1

prefix ab:<http://www.semanticweb.org/bhuiyanh/ontologies/2019/8/untitled-ontology-38#>
SELECT ?AV ?lane WHERE 
{ ?AV ab:Driving ab:N_Time_1. 
 ab:N_Time_1 ab:lane ?_lane. 
 bind( xsd:integer(?_lane) as ?lane )
}

OR try the string function:

SELECT ?AV ?lane WHERE 
{ ?AV ab:Driving ab:N_Time_1. 
 ab:N_Time_1 ab:lane ?_lane. 
 bind( str(?_lane) as ?lane )
}