Giter Site home page Giter Site logo

Comments (7)

tfrancart avatar tfrancart commented on June 22, 2024

Updating to latest version 3.7.1 gives the same error

from sparql.js.

tfrancart avatar tfrancart commented on June 22, 2024

Could be related to the fact that ?count is the result of an aggregation, but also used in the expression (CONCAT(STR(?theLabel), ' (', STR(?count), ')') AS ?label)

from sparql.js.

RubenVerborgh avatar RubenVerborgh commented on June 22, 2024

That must be it, yes. Can't tell top of my head whether or not it is correct (would need to spend some spec time), but I am leaning towards no (don't think you can use a destination variable in the SELECT clause).

To speed this up, can you gather spec evidence as to whether this should be allowed? https://www.w3.org/TR/sparql11-query/

from sparql.js.

tfrancart avatar tfrancart commented on June 22, 2024

I think the interesting paragraph is https://www.w3.org/TR/sparql11-query/#aggregateRestrictions, but not sure how to interpret that. I think it reads "what you do aggregates, you cannot use functions on other selected variables".

Which makes me think that using a CONCAT + a COUNT in the SELECT clause (whether or not the CONCAT uses the counted variable), is not legal.

from sparql.js.

rubensworks avatar rubensworks commented on June 22, 2024

Some SPARQL engines are a bit more liberal on this, but strictly this is not allowed by the SPARQL spec indeed.
But you can disable this check like this: https://github.com/RubenVerborgh/SPARQL.js?tab=readme-ov-file#validation

from sparql.js.

RubenVerborgh avatar RubenVerborgh commented on June 22, 2024

So that brings the question down to whether ?x or ?count is the selected variable. Might be a good discussion for https://lists.w3.org/Archives/Public/public-sparql-dev/; okay to close here until more evidence comes along?

from sparql.js.

tfrancart avatar tfrancart commented on June 22, 2024

Some SPARQL engines are a bit more liberal on this

I would even say, all of those I have been using so far :-)

okay to close here until more evidence comes along?

OK to close, I need to rewrite the query as the following:

PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
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#> 
PREFIX skos: <http://www.w3.org/2004/02/skos/core#> 
PREFIX rico: <https://www.ica.org/standards/RiC/ontology#> 
SELECT ?uri (CONCAT(STR(?theLabel), ' (', STR(?count), ')') AS ?label) ?hasChildren ?count
WHERE {
  {
  SELECT ?uri ?theLabel ?hasChildren (COUNT(?x) AS ?count)
  WHERE {
    {
      SELECT DISTINCT ?uri ?theLabel ?hasChildren
      WHERE { <http://data.archives-nationales.culture.gouv.fr/documentaryFormTypes> skos:hasTopConcept|^skos:topConceptOf ?uri .
        ?uri skos:prefLabel ?theLabel .
        FILTER(isIRI(?uri))
        FILTER(lang(?theLabel) = '' || lang(?theLabel) = 'en' || lang(?theLabel) = 'fr')
        OPTIONAL {
          ?uri skos:narrower|^skos:broader ?children .
        }
        BIND(IF(bound(?children),true,false) AS ?hasChildren)
      }
    }

    OPTIONAL {
      ?x a <https://sparna-git.github.io/sparnatural-demonstrateur-an/ontology#Archives> .
      ?x <https://sparna-git.github.io/sparnatural-demonstrateur-an/ontology#aPourTypeDeDocument> ?uri .
      # no range criteria
      # ?uri a <https://sparna-git.github.io/sparnatural-demonstrateur-an/ontology#TypeDeDocument> .
    }
  }
  GROUP BY ?uri ?theLabel ?hasChildren
  }
} ORDER BY UCASE(?label)

from sparql.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.