1

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

scotthenninger
  • 3,921
  • 1
  • 15
  • 24
skid
  • 31
  • 5
  • What's the query you tried? Can you (re)present your data in Turtle, which aligns better to SPARQL -- and may show you your error? – TallTed Sep 20 '16 at 19:36
  • That's not a legal RDF file (though it could be a snippet of one). There's not enough there to actually specify any triples. – Joshua Taylor Sep 21 '16 at 14:26
  • 1
    The answer to [Extract all types and their labels in English from DBPedia](http://stackoverflow.com/q/18733225/1281433) explains how to do this. – Joshua Taylor Sep 21 '16 at 14:28

1 Answers1

3

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")
}
scotthenninger
  • 3,921
  • 1
  • 15
  • 24