SPARQL select literals with a given language tag

Hi all,

Is there a way of selecting only literals with a given language tag? My use case is a graph with the triples

:jperez foaf:name "José Pérez"@es .
:jperez foaf:name "Jose Perez"@en .

from which I'd like to return only the English version of the name in the query

SELECT ?name
WHERE { :jperez foaf:name ?name . }

Thanks in advance!

Hi @janoma,

Yes, SPARQL includes the langMatches function (see http://www.w3.org/TR/rdf-sparql-query/#func-langMatches) for exactly this purpose:

SELECT ?name
WHERE { 
    :jperez foaf:name ?name . 
    FILTER(langMatches(lang(?name), "EN"))
}