As the title suggests, I have preferred labels in english and german. I am trying to extract each label by it's language and bind to a (newly created) variable.
SELECT ?copyC ?enLabel ?defaultLabel
WHERE {
?targetC skos:prefLabel ?prefUri .
?prefUri skosxl:literalForm ?b
# handle languages - english and german
bind(if(langMatches(lang(?b),"en"),?b,?_) as ?enLabel)
bind(if(langMatches(lang(?b),"de"),?b, ?_) as ?defaultLabel)
####
.
# create some uris
BIND(IRI(CONCAT("http://example.com/", REPLACE(STR(?enLabel), "\\W", "", "i") )) AS ?copyC ) .
BIND(IRI(CONCAT("http://example.com/", REPLACE(STR(?enLabel), "\\W", "", "i"),"_prefLabel_en" )) AS ?enLabelc ) .
BIND(IRI(CONCAT("http://example.com/", REPLACE(STR(?defaultLabel), "\\W", "", "i"),"_prefLabel_de" )) AS ?defaultLabelc ) .
####
}
A toy example model:
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
@prefix skosxl: <http://www.w3.org/2008/05/skos-xl#> . <http://example_copy.com/thing1> a skos:Concept ;
skosxl:prefLabel <http://example_copy.com/some_german_label>, <http://example> <http://example_copy.com/some_german_label> a skosxl:Label ;
skosxl:literalForm "some german label"@de . <http://example_copy.com/some_english_label> a skosxl:Label ;
skosxl:literalForm "some english label"@en .
results:
?c ?enLabel ?defaultLabel
1 <http://example.com/thing1> <http:/example.com/some_english_label>
2 <http:/example.com/some_german_label>
above query follows this post: SPARQL filter language if possible in multiple value context
The ?englishLabelc is correctly associated to the bound ?copyC variable but the ?defaultLabelc is not. My desire is that both the english and german label will correctly be associated uri bound to ?copyC. I assume there is a scope problem in how I am "BIND"ing the ?copyC variable but I am not sure how to go about troubleshooting. If I simply use the ?b variable to create ?copyC two concepts will be created - one for the english and one for the german label which is what I want. Can someone help me figure this out?