skid
skid

Reputation: 31

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 RDF

<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 three values.

Thanks in advance

Upvotes: 1

Views: 1706

Answers (1)

scotthenninger
scotthenninger

Reputation: 4001

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(?label), "en")
}

Upvotes: 3

Related Questions