sparna-git / Sparnatural

Sparnatural : visual knowledge graph explorer with SPARQL, in the browser, configurable with SHACL
http://sparnatural.eu
GNU Lesser General Public License v3.0
225 stars 41 forks source link

SPARQL targets : "double dot" error when the SPARQL string contains a final dot #628

Closed tfrancart closed 2 months ago

tfrancart commented 2 months ago

target SPARQL query:

SELECT $this
WHERE {
  $this a <https://www.ica.org/standards/RiC/ontology#RecordSet> .
  $this <https://www.ica.org/standards/RiC/ontology#hasRecordSetType> <http://vocab.performing-arts.ch/rsfnd> .
}

generated datasource SPARQL query to populate list (note the double dot)


PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> 
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> 
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> 
SELECT ?uri ?count (CONCAT(STR(?theLabel), ' (', STR(?count), ')') AS ?label)
WHERE {
  {
  SELECT ?uri ?count ?theLabel
  WHERE {
  {
    SELECT DISTINCT ?uri (COUNT(?domain) AS ?count)
    WHERE {
      ?domain a ?rrType_domain .
 VALUES ?rrType_domain {
 <https://www.ica.org/standards/RiC/ontology#Record>
 <https://www.ica.org/standards/RiC/ontology#RecordSet>
 <https://www.ica.org/standards/RiC/ontology#RecordPart>
 } .
      ?domain <https://www.ica.org/standards/RiC/ontology#isOrWasConstituentOf>?/<https://www.ica.org/standards/RiC/ontology#isOrWasIncludedIn>* ?uri .
      FILTER(isIRI(?uri))
      # range criteria
      ?uri a <https://www.ica.org/standards/RiC/ontology#RecordSet> .
 ?uri <https://www.ica.org/standards/RiC/ontology#hasRecordSetType> <http://vocab.performing-arts.ch/rsfnd> . .
    }
    GROUP BY ?uri
  }
  ?uri <https://www.ica.org/standards/RiC/ontology#name> ?theLabel .
  FILTER(lang(?theLabel) = "" || lang(?theLabel) = 'en')
  }
  ORDER BY UCASE(?theLabel)
  LIMIT 500
  }
}
ORDER BY UCASE(?label)

the SPARQL rewrite regex should take this into account. Right now, this means the SPARQL target definition MUST NOT use a final dot for the last criteria, e.g. in our example:

SELECT $this
WHERE {
  $this a <https://www.ica.org/standards/RiC/ontology#RecordSet> .
  $this <https://www.ica.org/standards/RiC/ontology#hasRecordSetType> <http://vocab.performing-arts.ch/rsfnd>
}