template.spintcbody.rul Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of corese-core Show documentation
Show all versions of corese-core Show documentation
Corese is a Semantic Web Factory (triple store and SPARQL endpoint) implementing RDF, RDFS, SPARQL 1.1
Query and Update.
template st:bound(?b, ?n) {
?suc
}
where {
bind (
(exists { ?b (sp:subject|sp:predicate|sp:object)/sp:varName ?n } ||
exists { ?b a sp:Bind ; sp:variable/sp:varName ?n } ||
exists { ?b a sp:Values ; sp:variables/rdf:rest*/rdf:first/sp:varName ?n } ||
exists {
?b a sp:Select
{ ?b sp:resultVariables/rdf:rest*/rdf:first/sp:varName ?n }
union
{ ?b sp:star true ; sp:where/(! sp:void)* ?bb
filter (st:call-template(st:bound, ?bb, ?n))
}
})
&&
not exists { ?m a sp:Minus . ?m (!sp:void)* ?b }
as ?suc)
}
]]>
template {
?suc
}
where {
?q (sp:orderBy|sp:groupBy)/rdf:rest*/rdf:first/(!sp:void)* ?v
?v sp:varName ?n
bind (st:call-template(st:bound, ?q, ?n) as ?suc)
filter (st:visit(st:fail, ?v, ?suc))
}
]]>
template {
?suc
}
where {
?a rdf:rest+ ?b
?b rdf:first ?f
?f a sp:Bind ; sp:variable ?v
?v sp:varName ?n
bind (
not exists {
?a rdf:rest* ?c
?c rdf:rest* ?b
filter (?b != ?c)
?c rdf:first ?d
filter st:call-template(st:bound, ?d, ?n)
}
as ?suc)
filter (st:visit(st:fail, ?f, ?suc))
}
]]>
template {
?suc
}
where {
?q sp:resultVariables ?sel
?sel rdf:rest*/rdf:first ?v
?v sp:varName ?n
bind (
exists { ?q sp:where/(! sp:void)+ ?b
filter (st:call-template(st:bound, ?b, ?n)) }
as ?bound)
bind (
if (exists { ?v sp:expression ?e }, ! ?bound, ?bound)
as ?suc)
filter (st:visit(st:fail, ?v, ?suc))
}
]]>
template {
?suc
}
where {
?minus a sp:Minus
?exp (sp:where|sp:elements)/rdf:rest*/rdf:first ?minus
?minus (! sp:void)*/(sp:subject|sp:predicate|sp:object) ?v
?v sp:varName ?n
bind( exists {
?exp (sp:where|sp:elements)/rdf:rest* ?r
?r rdf:first ?e
filter (?e != ?minus)
filter exists { ?r rdf:rest*/rdf:first ?minus }
bind (st:call-template(st:bound, ?e, ?n) as ?suc)
}
as ?suc)
filter(st:visit(st:fail, ?minus, ?suc))
}
]]>
template {
?suc
}
where {
?q (sp:where|sp:resultVariables)/(! sp:void)+ ?f
?f ?p ?v
?v sp:varName ?n
filter(strstarts(?p, sp:arg))
bind (
exists { ?q sp:where/(! sp:void)+ ?b
filter (st:call-template(st:bound, ?b, ?n)) }
as ?suc)
filter(st:visit(st:fail, ?v, ?suc))
}
]]>
template {
?suc
}
where {
?q sp:resultVariables ?sel
?sel rdf:rest*/rdf:first ?v
?v sp:expression ?e
?v sp:varName ?n
?sel rdf:rest*/rdf:first ?w
?w sp:varName ?n
filter (?v != ?w)
bind (false as ?suc)
filter(st:visit(st:fail, ?v, ?suc))
}
]]>
template {
?suc
}
where {
?q sp:fromNamed ?l
bind ( exists { ?q sp:where/(! sp:void)/rdf:type sp:NamedGraph } as ?suc)
filter(st:visit(st:fail, ?l, ?suc))
}
]]>
© 2015 - 2025 Weber Informatics LLC | Privacy Policy