query-e663f0a7c6f3edf8610e8416c705abf7

rq turtle/ttl

title: All of Katrineholm's online accounts and if not available a direct search link SELECT DISTINCT ?propertyLabel ?account WHERE { BIND(wd:Q508140 AS ?org) # Katrineholm Municipality

?property wdt:P31 wd:Q105388954 ; wikibase:directClaim ?wdt .

OPTIONAL { ?property wdt:P4354 ?searchEndpoint }

OPTIONAL { ?org ?wdt ?value }

BIND(IF((!BOUND(?value) && BOUND(?searchEndpoint)), IRI(CONCAT(SUBSTR(?searchEndpoint,1,STRLEN(?searchEndpoint)-2), ?orgLabel)), ?value) AS ?account) SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" . # make sure to change the lanuage to optimize the search queries ?org rdfs:label ?orgLabel . ?property rdfs:label ?propertyLabel } } ORDER BY ?property

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX bd: <http://www.bigdata.com/rdf#>
#title: All of Katrineholm's online accounts and if not available a direct search link
SELECT DISTINCT ?propertyLabel ?account WHERE {
  BIND(wd:Q508140 AS ?org) # Katrineholm Municipality

  ?property wdt:P31 wd:Q105388954 ;
            wikibase:directClaim ?wdt .

  OPTIONAL { ?property wdt:P4354 ?searchEndpoint }

  OPTIONAL { ?org ?wdt ?value }

  BIND(IF((!BOUND(?value) && BOUND(?searchEndpoint)), IRI(CONCAT(SUBSTR(?searchEndpoint,1,STRLEN(?searchEndpoint)-2), ?orgLabel)), ?value) AS ?account)
  SERVICE wikibase:label {
    bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" . # make sure to change the lanuage to optimize the search queries
    ?org rdfs:label ?orgLabel .
    ?property rdfs:label ?propertyLabel
   }
} ORDER BY ?property

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v6("?account"):::projected v2("?org") v7("?orgLabel") v1("?property") v8("?propertyLabel"):::projected v4("?searchEndpoint") v5("?value") v3("?wdt") c2(["wd:Q105388954"]):::iri c6(["bd:serviceParam"]):::iri c8(["#91;AUTO_LANGUAGE#93;,en"]):::literal bind0[/"'wd:Q508140'"/] bind0 --as--o v2 v1 --"wdt:P31"--> c2 v1 --"wikibase:directClaim"--> v3 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v1 -."wdt:P4354".-> v4 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v2 -->v3--> v5 end bind1[/"if(not bound(?value)bound(?searchEndpoint),concat(substring(?searchEndpoint,'1^^xsd:integer',string-length(?searchEndpoint) + '-2^^xsd:integer'),?orgLabel),?value)"/] v5 --o bind1 v4 --o bind1 v7 --o bind1 bind1 --as--o v6 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c6 -."wikibase:language".-> c8 v2 --"rdfs:label"--> v7 v1 --"rdfs:label"--> v8 end