You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SPARQL already has ENCODE_FOR_URI(str) which is useful when allocating new URIs based on some string content, for use with CONSTRUCT or INSERT:
BIND (IRI(concat(str(widget:), ENCODE_FOR_URI(?widgetID))) AS ?widgetURI)
But RDF supports IRIs, and in general SPARQL is good about IRI support, so it is hard to see why no IRI-compatible version of this function is provided.
IRIs in RDF (just like in web browsers) are allowed to contain the full range of international alphanumeric characters. With ENCODE_FOR_URI, anything outside of US-ASCII gets %-encoded, which is not acceptable to some users in i18n scenarios.
Previous work
None that I'm aware of. (At TQ we construct IRIs in app logic outside of SPARQL, which happened to be simpler than adding a custom function. We would use encodeForIRI if it existed.)
Proposed solution
encodeForIRI(str) would %-encode only the characters in the argument that are not allowed in an IRI path, and otherwise behave like ENCODE_FOR_IRI.
While I'm at it, let me also propose adding a new function encodeForURI as an alias for ENCODE_FOR_IRI, and deprecating the old spelling. It's the only function in SPARQL that uses SCREAMING_SNAKE_CASE and the inconsistency drives me mad 😁
Considerations for backward compatibility
None.
The text was updated successfully, but these errors were encountered:
Why?
SPARQL already has
ENCODE_FOR_URI(str)
which is useful when allocating new URIs based on some string content, for use withCONSTRUCT
orINSERT
:But RDF supports IRIs, and in general SPARQL is good about IRI support, so it is hard to see why no IRI-compatible version of this function is provided.
IRIs in RDF (just like in web browsers) are allowed to contain the full range of international alphanumeric characters. With
ENCODE_FOR_URI
, anything outside of US-ASCII gets %-encoded, which is not acceptable to some users in i18n scenarios.Previous work
None that I'm aware of. (At TQ we construct IRIs in app logic outside of SPARQL, which happened to be simpler than adding a custom function. We would use
encodeForIRI
if it existed.)Proposed solution
encodeForIRI(str)
would %-encode only the characters in the argument that are not allowed in an IRI path, and otherwise behave likeENCODE_FOR_IRI
.While I'm at it, let me also propose adding a new function
encodeForURI
as an alias forENCODE_FOR_IRI
, and deprecating the old spelling. It's the only function in SPARQL that usesSCREAMING_SNAKE_CASE
and the inconsistency drives me mad 😁Considerations for backward compatibility
None.
The text was updated successfully, but these errors were encountered: