How do you concatenate strings in SPARQL?

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

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") )
  ...
}

Assignment

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

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

ARQ overload + as well:

"A"+"B"

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

http://jena.sourceforge.net/ARQ/library-function.html fn:concat(string, ...)

I just accomplished this using the ARQ functions:

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