Getting xml: lang attribute with sparql request

I would like to know if it is possible to use the sparql query to get a language tag on some literals on my chart.

for example, I could have things like:

<skos:prefLabel xml:lang="fr">Bonjour</skos:definition> <skos:prefLabel xml:lang="en">Hello</skos:definition> 

and I would like to have a result set with each label and corresponding language.

+4
source share
1 answer

You can use the built-in "lang" function as described in the SPARQL specification (section 17.4.2.6 in the specification for SPARQL 1.1: http://www.w3.org/TR/sparql11-query/ ). So your query might look like this:

 PREFIX skos: <http://www.w3.org/2004/02/skos/core#> SELECT ?x ?label ?language WHERE { ?x skos:prefLabel ?label ; foaf:mbox ?mbox . BIND (lang(?label) AS ?language } 

Note that using BIND in this way requires SPARQL 1.1

+5
source

Source: https://habr.com/ru/post/1384282/


All Articles