ARC supports all SPARQL Query Language features (to a certain extent), and we are also working on a number of pragmatic extensions such as aggregates (AVG / COUNT / MAX / MIN / SUM) and write mechanisms. We try to keep the changes to the SPARQL specification at a minimum, so that the existing grammar parser and store functionality can be re-used, and also to stick to ARC's flat learning curve.
This page documents the core differences between SPARQL and what is called "SPARQL+" in ARC2.
Note that the alias (... AS ...) has to be specified.
If you have more than a single result variable, you also have to provide GROUP BY information:
ARC can extract triples from a variety of formats such as RDF/XML, Turtle, and HTML (eRDF, RDFa, microformats, basic Dublin Core data, OpenID Hooks, Feed links).
It is possible to add data to an existing graph
(LOAD in SPARQL+ is syntactically compatible with SPARUL.)
In this INSERT form the triples have to be fully specified, variables are not allowed.
It is possible to dynamically generate the triples that should be inserted:
This is a simple extension to SPARQL's existing CONSTRUCT query type. It adds the triples generated in the construction step to the specified graph. Note: The CONSTRUCT keyword was made optional with the Jan 7th, 2008 revision, to increase the compatibility with SPARUL.
Each specified triple will be deleted from the RDF store. It is possible to specify variables as wildcards, but they can't be used to build connected patterns. Each triple is handled as a stand-alone pattern.
FROM can be used to restrict the delete operations to selected graphs. It's also possible to not specify any triples. The whole graph will then be deleted.
DELETE can (like INSERT) be combined with a CONSTRUCT query (the CONSTRUCT keyword was made optional with the Jan 7th, 2008 revision):
This page documents the core differences between SPARQL and what is called "SPARQL+" in ARC2.
Aggregate Example
SELECT COUNT(?contact) AS ?contacts WHERE {
<#me> foaf:knows ?contact .
}
ORDER BY DESC(?contacts)If you have more than a single result variable, you also have to provide GROUP BY information:
SELECT ?who COUNT(?contact) AS ?contacts WHERE {
?who foaf:knows ?contact .
}
GROUP BY ?whoLOAD Example
LOAD <http://example.com/>
It is possible to add data to an existing graph
LOAD <http://example.com/> INTO <http://example.com/archive>
INSERT Example
INSERT INTO <http://example.com/> {
<#foo> <bar> "baz" .
}It is possible to dynamically generate the triples that should be inserted:
INSERT INTO <http://example.com/inferred> CONSTRUCT {
?s foaf:knows ?o .
}
WHERE {
?s xfn:contact ?o .
}DELETE Example
DELETE {
<#foo> <bar> "baz" .
<#foo2> <bar2> ?any .
}FROM can be used to restrict the delete operations to selected graphs. It's also possible to not specify any triples. The whole graph will then be deleted.
DELETE FROM <http://example.com/archive>
DELETE can (like INSERT) be combined with a CONSTRUCT query (the CONSTRUCT keyword was made optional with the Jan 7th, 2008 revision):
DELETE FROM <http://example.com/inferred> {
?s rel:wouldLikeToKnow ?o .
}
WHERE {
?s kiss:kissed ?o .
}SPARQL Grammar Changes and Additions
Query ::= Prologue ( SelectQuery | ConstructQuery | DescribeQuery | AskQuery | LoadQuery | InsertQuery | DeleteQuery )
SelectQuery ::= 'SELECT' ( 'DISTINCT' | 'REDUCED' )? ( Aggregate+ | Var+ | '*' ) DatasetClause* WhereClause SolutionModifier
Aggregate ::= ( 'AVG' | 'COUNT' | 'MAX' | 'MIN' | 'SUM' ) '(' Var | '*' ')' 'AS' Var
LoadQuery ::= 'LOAD' IRIref ( 'INTO' IRIref )?
InsertQuery ::= 'INSERT' 'INTO' IRIref 'CONSTRUCT'? ConstructTemplate DatasetClause* WhereClause? SolutionModifier
DeleteQuery ::= 'DELETE' ( 'FROM' IRIref )* 'CONSTRUCT'? ConstructTemplate? DatasetClause* WhereClause? SolutionModifier
SolutionModifier ::= GroupClause? OrderClause? LimitOffsetClauses?
GroupClause ::= 'GROUP' 'BY' Var ( ',' Var )*Changelog
- 2008-01-07: CONSTRUCT keyword in INSERT and DELETE queries is now optional
