rdf - SPARQL, Comma separated parameter into multiple query objects -


i have iri

http://localhost:8080/drinks/coke,pepsi,fanta

which automatically generated , want reformat in following objects query looks below

select *      {       ?person ?p <http://localhost:8080/drinks/coke> .       ?person ?p <http://localhost:8080/drinks/pepsi> .       ?person ?p <http://localhost:8080/drinks/fanta> .     } 

andys's answer right there's no convenient way this, there options if really have work iri 1 have. using regular expressions can explode string of iri have 1 contains iri strings of 3 iris want:

select ?url ?urls {   values ?url { <http://localhost:8080/drinks/coke,pepsi,fanta> }   bind(replace(str(?url), "(^.*/).*$","$1") ?prefix)   bind(concat(",",strafter(str(?url),?prefix)) ?parts)   bind(replace(?parts,",",concat(" ",?prefix)) ?urls) } 

---------------------------------------------------------------------------------------------------------------------------------------------------------------- | url                                             | urls                                                                                                       | ================================================================================================================================================================ | <http://localhost:8080/drinks/coke,pepsi,fanta> | " http://localhost:8080/drinks/coke http://localhost:8080/drinks/pepsi http://localhost:8080/drinks/fanta" | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- 

using this, query wherein can filter iri based on whether strign present in larger string. has potential fase positives, since substring register. can filter likk this:

?s ?p ?o . filter contains(?urls,str(?s)) 

Comments