skid skid - 2 months ago 14
Apache Configuration Question

SPARQL query to find only one value using the attribute

I need to get the only the English value from my rdfs:label tag

here is my sample code

<rdfs:label rdf:datatype="&xsd;string">English</rdfs:label>
<rdfs:label xml:lang="fr">French</rdfs:label>
<rdfs:label xml:lang="it">Italy</rdfs:label>


I am currently using Apache Jena Fuseki server to perform the SPARQL query when i tried to get the rdfs:label it return me all the three value.

Thanks in advance

Answer

You can filter by the language tag you desire in your result. A couple of ways to do this in SPARQL:

SELECT ?label
WHERE {
   ?s rdfs:label ?label .
   FILTER (lang(?label) = "en")
}

...or use SPARQL's langMatches:

SELECT ?label
WHERE {
   ?s rdfs:label ?label .
   FILTER langMatches(lang(?sn), "en")
}