zazuko / query-rdf-data-cube

Explore or query RDF Data Cubes with a JavaScript API, without writing SPARQL.
https://zazuko.github.io/query-rdf-data-cube/
9 stars 2 forks source link

Label languages handling #45

Open vhf opened 4 years ago

vhf commented 4 years ago

As expected, querying a datacube (A) without specifying a language and (B) with specifying "" as language do not behave the same way.

A

  OPTIONAL {
    ?raum (rdfs:label|skos:prefLabel) ?raumLabel.
  }

B

  OPTIONAL {
    ?raum (rdfs:label|skos:prefLabel) ?raumLabel_.
    FILTER((LANG(?raumLabel_)) = ""^^xsd:string)
  }
  BIND(COALESCE(?raumLabel_, ""^^xsd:string) AS ?raumLabel)

At the moment, B is correct but A isn't properly handled and instead outputs the following, which will always evaluate to the empty string as label:

  BIND(COALESCE(""^^xsd:string) AS ?raumLabel)
vhf commented 4 years ago

Probably related to this issue is this problematic SPARQL query:

# https://trifid-lindas.test.cluster.ldbar.ch/query
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX qb: <http://purl.org/linked-data/cube#>
PREFIX dc11: <http://purl.org/dc/elements/1.1/>
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
SELECT DISTINCT ?value ?label FROM <https://linked.opendata.swiss/graph/blv/animalpest>
WHERE {
  ?observation rdf:type qb:Observation;
    <http://ld.zazuko.com/animalpest/attribute/canton> ?value;
    qb:dataSet <http://ld.zazuko.com/animalpest/dataset>.
  OPTIONAL {
    ?value (rdfs:label|skos:prefLabel) ?label_de.
    # comment next line
    FILTER(LANGMATCHES(LANG(?label_de), "de"^^xsd:string))
  }
  BIND(COALESCE(?label_de, ""^^xsd:string) AS ?label)
}