URL encoding of strings containing a url

I'm trying to generate a url encoded string using a sparql query. My goal is to have a link into the stardog webui, but this could be for any service that takes a URI as an argument. Here is an example query

select *
where {
    ?dataset a dcat:Dataset ;
    bind(concat("http://localhost:5820/mydb#!/browse/resource/", encode_for_uri(str(?dataset))) as ?kg)

The result that I am looking for is:


But what I get is:


Is there any built in function I am missing that will correctly encode a string that contains an http url?

Per the W3C REC [1], the ENCODE_FOR_URI returns a simple literal with the lexical form obtained from the lexical form of its input after translating reserved characters according to the fn:encode-for-uri function

So normally from your sample, you should get what you were expecting, http%3A%2F%2Ffoo.bar.com%2FmyIRI

[1] https://www.w3.org/TR/sparql11-query/#func-encode

@gatemezing, right but that is not the behavior I am observing in stardog.

Is anyone able to replicate my issue? For example using the following triple, query, and result:

<http://foo.bar.com> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> "some string" .
select ?s ?s1 ?o ?o1
where {
    ?s ?p ?o .
    bind(encode_for_uri(str(?s)) as ?s1)
    bind(encode_for_uri(str(?o)) as ?o1)

Hi Nolan,

We are able to reproduce this issue on our side, and I am creating a ticket to address it. Thanks for the report.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.