Is there a way to concatenate strings in SPARQL? For example:

?concatvar = ?var + "append_text" Assign string variable to another string variable plus concatenated text.

Specifically, I am using Jena and ARQ.

Thank you

asked 27 May '10, 17:08

fish0398's gravatar image

accept rate: 0%

Firstly you need fn:concat(string, string, ...), where fn is http://www.w3.org/2005/xpath-functions#. See the ARQ library function documentation for more information.

Secondly you need to assign the result. There is no way (currently) in SPARQL to do this, but ARQ provides the following syntax extensions: (You will need to use the Syntax.syntaxARQ option)

SELECT ( fn:concat(?var, "append_text") AS ?concatvar ) WHERE ....

Select expressions

SELECT ?concatvar WHERE {
  LET ( ?concatvar := fn:concat(?var, "append_text") )


The former, and perhaps the latter, will appear in SPARQL 1.1.

permanent link

answered 27 May '10, 18:14

Comment%20Bot's gravatar image

Comment Bot
accept rate: 42%

edited 19 Feb '11, 19:04

SPARQL 1.1 has BIND.

(11 Apr '12, 11:47) AndyS ♦ AndyS's gravatar image

I have found that for me Comment Bot answer was good but only when I have removed "fn:" prefix. For example

 SELECT DISTINCT  ?similar ( CONCAT(?var, "append_text") AS ?var_concat)
permanent link

answered 11 Apr '12, 09:04

filipni's gravatar image

accept rate: 0%

SPARQL 1.1 adds CONCAT(...) which is fn:concat from XPtha/XQuery functions and operators.

ARQ overload + as well:


but that is a legal extension, not part of the base SPARQL standard.

permanent link

answered 11 Apr '12, 11:48

AndyS's gravatar image

AndyS ♦
accept rate: 33%

permanent link

answered 27 May '10, 17:49

Girts%20Niedra's gravatar image

Girts Niedra
accept rate: 0%

I just accomplished this using the ARQ functions:

   ?concat <http://jena.hpl.hp.com/ARQ/property#concat> ("<a href='" ?url "'>Link Text</a>") .
permanent link

answered 27 May '10, 18:32

fish0398's gravatar image

accept rate: 0%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 27 May '10, 17:08

question was seen: 12,333 times

last updated: 11 Apr '12, 11:48