Convert blank node in URI in sparql

193 Views Asked by At

I would like to convert blank nodes into URIs using a SPARQL query. Imagine something like:

_:N58f332639cbd46d6a5ec9410e5d875a7 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://schema.org/WebSite> .
_:N3b2eed756126458582bba185ab0fdb0b <http://schema.org/name> "Chefkoch.de" .
_:N3b2eed756126458582bba185ab0fdb0b <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://schema.org/Organization> .

then I would like a query like:

SELECT (func(?s) as ?s1) ?p ?o where {
    ?s ?p ?o
}

and func should convert the blank nodes in some URIs.

I find it quite a frequent use case but could not find a solution ....

1

There are 1 best solutions below

1
On
DELETE {
?subject ?predicate ?o.

    }
INSERT {
?newUri ?predicate ?o .

}    
WHERE { select * where {
?subject ?predicate ?o .
BIND(IRI(CONCAT(STR("https://domain.nl/resource"), "/", STRAFTER(STR(?subject), "_:"))) AS ?newUri)
FILTER(isBlank(?subject)) 
}
}