This repository was archived by the owner on Feb 17, 2025. It is now read-only.
Repository navigation
Scaffolding SPARQL update
Efimster edited this page Mar 26, 2014
·
7 revisions
- Create function for update RDF source that takes update string and returns arbitrary object (could be result of update)
Func<string, object> UpdateFunc;
- Create a dynamic object
dynamic dyno = DynamicSPARQL.CreateDyno(..,updateFunc, [other parameters]);
see dynamic object creation topic [here]
(https://github.com/Efimster/DynamicSPARQL/wiki/Dynamic-object)
3. Make an updates:
- DELETE DATA
//DELETE DATA
dyno.Delete(
prefixes: new[] {
SPARQL.Prefix("dc", "http://purl.org/dc/elements/1.1/")
},
delete: SPARQL.Triple(s: "", p: new[] { @"dc:title ""David Copperfield""",
@"dc:creator ""Edmund Wells""" })
);
- INSERT DATA
//INSERT DATA
dyno.Insert(
prefixes: new[] {
SPARQL.Prefix("dc", "http://purl.org/dc/elements/1.1/")
},
insert: SPARQL.Triple(s: "", p: new[] { @"dc:title ""David Copperfield""",
@"dc:creator ""Edmund Wells""" })
);
- DELETE/INSERT
//DELETE/INSERT
dyno.Update(
prefixes: new[] {
SPARQL.Prefix("foaf", "http://xmlns.com/foaf/0.1/")
},
delete: SPARQL.Triple("?person foaf:givenName Bill"),
insert: SPARQL.Triple("?person foaf:givenName William"),
where: SPARQL.Triple("?person foaf:givenName Bill")
);
- DELETE(informative)
//DELETE(informative)
dyno.Delete(
prefixes: new[] {
SPARQL.Prefix("dc", "http://purl.org/dc/elements/1.1/"),
SPARQL.Prefix("xsd","http://www.w3.org/2001/XMLSchema#")
},
delete: SPARQL.Triple("?book ?p ?v"),
where: SPARQL.Group(
SPARQL.Triple("?book dc:date ?date"),
SPARQL.Filter(@"?date > ""1970-01-01T00:00:00-02:00""^^xsd:dateTime"),
SPARQL.Triple("?book ?p ?v")
)
);
- INSERT(informative)
//INSERT(informative)
dyno.Insert(
prefixes: new[] {
SPARQL.Prefix("foaf","http://xmlns.com/foaf/0.1/")
},
insert: SPARQL.Group(
SPARQL.Triple("?person foaf:name2 ?name"),
SPARQL.Triple("?person foaf:mbox2 ?email")
),
where: SPARQL.Group(
SPARQL.Triple("?person foaf:name ?name"),
SPARQL.Optional("?person foaf:mbox ?email")
)
);
- DELETE WHERE
//DELETE WHERE
dyno.Delete(
prefixes: new[] {
SPARQL.Prefix("foaf", "http://xmlns.com/foaf/0.1/")
},
where: SPARQL.Triple(s:"?person",p:new[]{"foaf:givenName Fred", "?property ?value"})
);