Comments (7)
Updating to latest version 3.7.1 gives the same error
from sparql.js.
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.
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.
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.
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.
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.
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)
- SPARQL Generator error "Cannot read property 'termType' of undefined" HOT 6
- Use this lib with Turtle in-memory HOT 1
- support for SPARQL query executer HOT 3
- Generate SPARQL queries without ";" or "," HOT 3
- Incorrect serialization of ADD, MOVE, COPY statements in SPARQL generator.
- Unary plus operator is not properly parsed
- The package does not work as CLI HOT 4
- FunctionCallExpression doesn't work with string function HOT 2
- Spec tests broken on Node 18 HOT 1
- Empty string as separator in Group Concat does not work HOT 1
- W3C test: Parser fails when a decimal ends with a dot HOT 2
- W3C test: DESCRIBE <u> fails with "cannot resolve relative IRI u because no base IRI was set" HOT 1
- W3C test: cannot parse CONSTRUCT { [ <s> ?s; <p> ?p; <o> ?o ] . }
- Serialising a double inverse property path results in a syntactically invalid query
- Update types on @DefinitelyTyped
- Prefixed IRIs with an escaped character in the local name get parsed incorrectly
- Parsing INSERT/DELETE queries with too much whitespace cause "too much recursion"
- Instructions for setting variables do not work
- Incorrect parsing of `PropertyListPathNotEmpty` HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sparql.js.