R3000
(R3000)
October 2, 2019, 1:33pm
1
Trying to be nice to my Tableau dashboard developer. Let's say we have a few triples such as:
PREFIX b: <http://books/>
PREFIX a: <http://authors/>
INSERT DATA
{ a:author1 rdf:type "Author" ;
rdfs:label "John".
};
INSERT DATA
{ b:book3 rdf:type "Book" ;
rdfs:label "A new book" ;
b:hasAuthor a:author1 .
};
The defautl select * where {?s ?p ?o) brings URIs which dashboard developer doesn't like:
One ugly way to get rid of the URIs is to use replace functions (see below). But even that doesn't take care of all URIs...
select (replace(str(?s), "http://books/", "") as ?id) ?p ?o where{?s ?p ?o}
Any better way to get rid of URIs in the results?
Also to unquote the double qotes in the ?o column....
Thanks,
Radu
pavel
(Pavel Klinov)
October 2, 2019, 2:16pm
2
If you want to transform IRIs in ?p
and ?o
, too, then you should apply functions to them as well. You may try to use the built-in localname
function:
prefix sdf: <tag:stardog:api:functions:>
select (sdf:localname(?s) as ?subject) (if(isIRI(?o), sdf:localname(?o), ?o) as ?object) { ?s ?p ?o }
R3000
(R3000)
October 2, 2019, 5:43pm
3
Pavel,
Thanks! That works just fine.
The only challenge now is to get rid of double quotes.
Thanks,
Radu
I don't think you have many options there other than maybe a postprocessing step. Sparql doesn't really know that they're there. You might try serializing the results as CSV and they might get consumed by whatever csv parser you use to read it. I'm not sure exactly what the CSV serilizaer does with quotes so you'll need to see whta it does.
system
(system)
Closed
October 16, 2019, 6:06pm
5
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.