Open Rahien opened 10 years ago
Hi Karel,
What is the error the first query returns, as when I try to run either query I get an error even against the live v6 instance:
Virtuoso 37000 Error SP030: SPARQL compiler, line 3: Missing
in PREFIX declaration at 'http:' before '/'
I have made a copy of the v7 database I can run on a different port to test so as to not affect anything being done on the live instance you setup ...
I have the same issue with another query on virtuoso 6.1.8
The query in question:
prefix dcat:<http://www.w3.org/ns/dcat#>
SELECT
?s ?p ?o
WHERE {
?s a dcat:Dataset.
?s dcterms:publisher ?o.
{
{FILTER (!isIRI(?o)).}
UNION
{ OPTIONAL {?o ?type <http://xmlns.com/foaf/0.1/Agent> }
FILTER (!BOUND(?type)).
}
}
BIND(dcterms:publisher AS ?p).
}
If I copy the pattern matching ?o
into the union
it works
prefix dcat:<http://www.w3.org/ns/dcat#>
SELECT
?s ?p ?o
WHERE {
?s a dcat:Dataset.
{
{?s dcterms:publisher ?o. FILTER (!isIRI(?o)).}
UNION
{ ?s dcterms:publisher ?o. OPTIONAL {?o a <http://xmlns.com/foaf/0.1/Agent>.?o ?type <http://xmlns.com/foaf/0.1/Agent>}
FILTER (!BOUND(?type)).
}
}
BIND(dcterms:publisher AS ?p).
}
I just got a notification on this issue and I noticed that I didn't post the error message that virtuoso reports. For the query above, it would be:
Virtuoso 37000 Error SP031: SPARQL compiler: Variable 'o' is used in subexpressions of the query but not assigned
@nvdk, @Rahien - I have a feeling that the answer to #681 will also be relevant to you, primarily --
If you uncheck the Strict checking of void variables option in the SPARQL Query Form page, which disables this action by the SPARQL optimizer, then the query should run ...
@HughWilliams, @Rahien - The queries in the initial post here had significant syntax errors. All URIs were unwrapped -- i.e., there was no < >
around them -- and this was the source of the error @HughWilliams reported in the initial response.
@Rahien - The instance in question appears to have been taken down or relocated, so I cannot currently test the corrected queries there.
Original problem query, with corrected URI wrapping --
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX dct: <http://purl.org/dc/terms/>
PREFIX prov: <http://www.w3.org/ns/prov>
PREFIX comp: <http://schema.my-company.com/>
PREFIX bibo: <http://purl.org/ontology/bibo/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX metalex: <http://www.metalex.eu/metalex/2008-05-02#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
select distinct ?law ?shortTitle ?abbrev ?title ?graph ?issued ?related where {
GRAPH ?graph { ?law dct:source <http://vocabulary.my-company.com/origin/eu> .
FILTER ( ?law != <http://resource.my-company.com/legislation/unbekannt> )
OPTIONAL { ?law comp:abbreviation ?abbrev . }
OPTIONAL { ?law bibo:shortTitle ?shortTitle . }
FILTER(lang(?shortTitle) = "de")
OPTIONAL { ?law dct:title ?title . }
FILTER(lang(?title) = "de")
OPTIONAL { ?law dct:issued ?issued . }
FILTER ( regex(?title, "recht", "i") || regex(?abbrev, "recht", "i") || regex(?shortTitle, "recht", "i") ) }
OPTIONAL { SELECT ?law ( count(?cellar) AS ?related)
WHERE { ?law prov:hadPrimarySource ?cellar . }
}
} ORDER BY ?issued ?title
Query with explicit BIND
--
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX dct: <http://purl.org/dc/terms/>
PREFIX prov: <http://www.w3.org/ns/prov>
PREFIX comp: <http://schema.my-company.com/>
PREFIX bibo: <http://purl.org/ontology/bibo/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX metalex: <http://www.metalex.eu/metalex/2008-05-02#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
select distinct ?law ?shortTitle ?abbrev ?title ?graph ?issued ?related where {
GRAPH ?graph { ?law dct:source <http://vocabulary.my-company.com/origin/eu> .
FILTER ( ?law != <http://resource.my-company.com/legislation/unbekannt> )
OPTIONAL { ?law comp:abbreviation ?abbrev . }
OPTIONAL { ?law bibo:shortTitle ?shortTitle . }
FILTER(lang(?shortTitle) = "de")
OPTIONAL { ?law dct:title ?title . }
FILTER(lang(?title) = "de")
OPTIONAL { ?law dct:issued ?issued . }
FILTER ( regex(?title, "recht", "i") || regex(?abbrev, "recht", "i") || regex(?shortTitle, "recht", "i") ) }
BIND(?law as ?newlaw)
OPTIONAL { SELECT ?newlaw ( count(?cellar) AS ?related)
WHERE { ?newlaw prov:hadPrimarySource ?cellar . }
}
} ORDER BY ?issued ?title
Hi, In virtuoso-opensource-7, commit db77b79d243321312107ef3d8147d67e61f16ba9, I have a variable in a
GRAPH
statement that is not accessible to a neighboring subquery statement (the?law
variable):I got around this issue by doing an explicit bind of this variable: