On 8/5/2013 18:47, Andy Seaborne wrote:
How does TopQuadrant use initial bindings with update? Please give some
concrete examples.
A reasonably representative random choice from our SPARQL Web Pages library:
---
Input: ?this
INSERT {
?facet a search:PropertyFacet .
?facet search:property ?property .
?facet search:facetIndex
?facetIndex .
?this search:facet ?facet .
}
WHERE {
BIND
((COALESCE(spl:objectCount(?this, search:facet), 0) + 1) AS ?facetIndex) .
BIND (BNODE() AS ?facet) .
}
---
Input: ?resource
INSERT {
GRAPH ui:tempGraph {
swa:DestructorMetadata swa:delete ?child .
} .
}
WHERE {
?child (rdfs:subClassOf)* ?resource .
}
---
Input: ?resource
DELETE {
GRAPH ui:tempGraph {
swa:DestructorMetadata swa:delete ?child .
} .
}
WHERE {
?child (rdfs:subClassOf)+ ?resource .
?child (rdfs:subClassOf)+ ?other .
FILTER NOT EXISTS {
GRAPH ui:tempGraph {
swa:DestructorMetadata ?either ?other .
} .
} .
}
---
Input: ?label, ?labelLang, ?uri
INSERT {
?class a ?resourceType .
?class rdfs:label ?prefLabel .
?class rdfs:subClassOf ?contextResource .
}
WHERE {
BIND (IRI(str(?uri)) AS ?class) .
BIND (IF(bound(?labelLang), STRLANG(?label,
?labelLang), ?label) AS ?prefLabel) .
}
---
Input: ?search, ?searchGraph
INSERT {
GRAPH ?searchGraph {
?search a search:Search .
?search search:rootType ?rootType .
?search search:queryGraph ?queryGraph .
?search swa:loadId ?id .
} .
}
WHERE {
?search search:rootType ?rootType .
}
---
Input: ?searchGraph
DELETE WHERE {
GRAPH ?searchGraph {
?s ?p ?o .
} .
}
---
Input: ?searchGraph, ?first
INSERT {
GRAPH ?sessionGraph {
?resource ?p ?o .
} .
}
WHERE {
?first ?p ?o .
FILTER NOT EXISTS {
( ?rs 0 ) spr:colCells ?other .
FILTER ((?other != ?first) &&
NOT EXISTS {
?other ?p ?o .
}) .
} .
}
---
Input: ?this, ?targetGraph -------- This is the one that I am
currently stuck with
INSERT {
GRAPH ?targetGraph {
?this ?p ?o .
} .
}
WHERE {
?this ?p ?o .
}
Not sure if this is what you are looking for.
Holger