
template.cdn.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.
The newest version!
prefix ft:
template cn:body(?c) {
format { ft:body.html
st:call-template(cn:rowtitle, ?c)
st:call-template(cn:table, ?min, ?max)
}
}
where {
?c cn:start ?min ; cn:finish ?max
}
]]>
template cn:img(?i) {
"
"
}
where {
# bind(?u as ?uri)
# bind(?t as ?text)
}
]]>
prefix foaf:
prefix ft:
template cn:table(?min, ?max) {
format {
ft:date.html
st:call-template(cn:wikidate, ?d)
st:call-template(cn:row, ?d)
}
}
where {
{select distinct ?d where {
values ?p { cn:date cn:begin }
?uri ?p ?d
}}
filter(?min <= ?d && ?d <= ?max)
}
order by asc(?d)
]]>
prefix db:
template st:start {
if (?uri = st:global,
st:call-template(cn:global),
st:call-template(st:substart, ?uri))
}
where {
bind (coalesce(st:get(st:uri), cn:XIV) as ?uri)
}
]]>
template cn:hlink(?u, ?t) {
format { "%s" ?u ?t}
}
where {
}
]]>
prefix o:
template cn:href(?r, ?u, ?t, ?i) {
""
if (?img,
concat(st:call-template(cn:img, ?i), "
"),
"")
if (isURI(?r) && ?isp,
st:call-template(st:navlab, ?r, ?t),
st:call-template(cn:hlink, ?u, ?t))
""
}
where {
bind ( exists { ?r a ?tt . filter (?tt in (foaf:Person, o:Place))
} as ?isp )
bind (bound(?i) && strstarts(?i, "http://") as ?img)
}
]]>
prefix foaf:
template cn:date(?date, ?topic) {
group { ?uri ; separator = "
" }
}
where {
graph ?g { [] cn:topic ?topic .
{ ?uri cn:date ?date } union { ?uri cn:begin ?date }
}
}
]]>
template st:profile {
}
where {}
function st:process(?x) {
if (isLiteral(?x), xsd:string(?x), st:apply-templates(?x))
}
function st:default(?x) {
xsd:string(?x)
}
function st:misc(?name) {
st:protocol(
concat(st:get(st:service), "?name=", st:get(st:server), ?name, "&profile=st:sparql"))
#"&transform=st:sparql%23core&profile=st:dbpedia"))
}
#
# Generation of HTML table
#
function us:table(list, size) {
let (table = us:split(list, size)) {
st:format(ft:table.html,
letdyn (n = 0){
us:mapconcat (lambda(row) {
st:format(ft:tr.html,
set(n = n + 1),
us:mapconcat (lambda(cell) { st:format(ft:td.html, cell) }, row ) )
}, table)
}
)
}
}
function us:mapconcat(fun, exp) {
reduce(rq:concat, maplist(fun, exp))
}
function us:split(?list, ?n) {
let (?table = xt:list()) {
xt:add(?table, xt:list());
for (?e in ?list) {
if (xt:size(xt:first(?table)) = ?n) {
xt:add(?table, 0, xt:list())
} ;
xt:add(xt:first(?table), ?e)
} ;
return (xt:reverse(?table))
}
}
]]>
prefix ft:
template cn:sign {
st:call-template(cn:icon, cn:icon)
format { ft:sign.html }
now()
}
where {
}
]]>
prefix foaf:
template cn:global {
st:call-template(cn:head, cn:XX, "XX")
us:table(aggregate(?cell), 10)
}
where {
{select * where {
graph ?g { [] cn:topic ?topic .
{ ?uri cn:date ?date } union { ?uri cn:begin ?date }
}
}
order by ?date ?topic
}
filter xt:print(?uri, ?date)
bind (st:apply-templates(?uri) as ?cell)
}
]]>
prefix ft:
template cn:icon {
format {
ft:icontable.html
group {
format {
ft:icon.html
?i ?i
}
}
}
}
where { }
values ?i {
#
#
}
]]>
template st:navlab(?u, ?t) {
format {
"%s"
st:plink(?u, st:dbpedia)
?t
}
}
where {
}
]]>
Query
"""
st:get(st:service)
st:get(st:query)
}
}
where {
}
]]>
prefix db:
template st:substart(?cent) {
st:call-template(cn:content, ?cent)
# st:call-template-with(st:d3, st:frame, us:dbclean)
st:call-template(cn:sign, cn:sign)
}
where {
}
@public
function us:dbclean(?s) {
if (isURI(?s) && strstarts(?s, db:), replace(?s, db:, "db:"),
if (contains(?s, ".gif") || contains(?s, ".JPG") || contains(?s, ".jpg") || contains(?s, ".jpeg") || contains(?s, ".svg") || contains(?s, ".png"), "icon", ?s))
}
]]>
template cn:row(?d) {
format {
"%s "
group {
st:call-template(cn:date, ?d, ?topic)
}
}
}
where {
values ?topicList { unnest(st:get(st:topic)) }
bind (kg:number() as ?n)
values ?topic { unnest(?topicList) }
}
group by ?topicList
order by ?n
]]>
template st:servlet {
st:get(st:service)
"?query="
}
where {
}
]]>
prefix ft:
template cn:tail(?c, ?title) {
format {
ft:tail.html
st:call-template(cn:index, ?title)
}
}
where {
}
]]>
prefix ft:
template cn:index(?title) {
format {
ft:indextable.html
if (bound(?before),
st:format(ft:before.html, st:plink(?before)),
"")
st:call-template(cn:elem, ?title)
if (bound(?after),
st:format(ft:after.html, st:plink(?after)),
"")
}
st:call-template(cn:list)
}
where {
?century rdfs:label ?title ;
cn:start ?min
bind (if (?min = 1, 0, ?min) - 100 as ?be)
bind (if (?min = -100, -99, ?min) + 100 as ?af)
bind (coalesce(st:get(st:min), -1000) as ?fst)
bind (coalesce(st:get(st:max), 3000) as ?rst)
optional { ?before cn:start ?be filter (?be >= ?fst) }
optional { ?after cn:start ?af filter (?af <= ?rst) }
}
]]>
template cn:content(?c) {
st:call-template(cn:head, ?c, ?title)
st:call-template(cn:body, ?c)
st:call-template(cn:tail, ?c, ?title)
}
where {
?c rdfs:label ?title
}
]]>
prefix ft:
template cn:elem(?title) {
format {
ft:index.html
st:plink(?century)
if (?show, "bold", "undefined")
?date
}
}
where {
bind (coalesce(st:get(st:min), -1000) as ?fst)
bind (coalesce(st:get(st:max), 3000) as ?rst)
?century cn:start ?min ; cn:finish ?max ; rdfs:label ?date
filter (?min >= ?fst && ?max <= ?rst)
bind (?date = ?title as ?show)
}
order by ?min
]]>
prefix foaf:
template cn:wikidate(?d) {
format {
"%s"
?d ?d
}
}
where {
}
]]>
prefix foaf:
prefix o:
prefix w:
prefix r:
template cn:test(?p) {
"" str(?p) "
"
}
where {
service {
select * where {
?p a ?t
} limit 1
}
}
pragma {kg:query kg:detail true}
]]>
prefix foaf:
prefix o:
template cn:geticon {
?ic
}
where {
service {
?in o:thumbnail ?ic
# ?in foaf:depiction ?ic
}
}
]]>
template cn:rowtitle(?c) {
format {
"%s "
if (?label = "Antiquité",
if (?max <= 500, str(?label), " "),
str(?label))
}
}
where {
?c cn:start ?min ; cn:finish ?max
bind (unnest(st:get(st:text)) as ?label)
}
]]>
prefix ft:
template cn:list {
format {
ft:listtable.html
st:plink(, st:dbpedia)
st:format(" %s ", st:plink(st:global), "Global")
group {
format {
ft:list.html
st:misc(?query)
str(?title)
}
}
}
}
where {
}
values (?query ?title){
("/data/query/cdnplace.rq" "Lieu")
("/data/query/cdnperson.rq" "Personne")
("/data/query/cdnfr.rq" "France")
("/data/query/cdneds.rq" "Savoie")
("/data/query/cdnmisc.rq" "Autre")
}
]]>
prefix ft:
template cn:head(?c, ?title) {
format {
ft:head.html
str(?title)
?title
"" #st:call-template(cn:icon, cn:icon)
st:call-template(cn:index, ?title)
}
}
where {
}
]]>
template cn:style(?in) {
if (?d <= 1000, "s09",
if (?d <= 1100, "s10",
if (?d <= 1200, "s11",
if (?d <= 1300, "s12",
if (?d <= 1400, "s13",
if (?d <= 1500, "s14",
if (?d <= 1600, "s15",
if (?d <= 1700, "s16",
if (?d <= 1800, "s17",
if (?d <= 1900, "s18", "s19"))))))))))
}
where {
bind(?in as ?d)
}
]]>
prefix foaf:
template {
if (bound(?lnk),
st:call-template(cn:href, ?lnk, ?c),
?c)
}
where {
?in rdf:rest*/rdf:first ?elem
{ ?elem rdfs:label ?c ; cn:link ?lnk }
union
{ ?elem rdfs:comment ?c }
}
]]>
prefix foaf:
prefix o:
prefix w:
prefix r:
template {
st:call-template(cn:href,
?in, coalesce(?link, ?in), ?mds, ?ic)
coalesce(str(?cc), "")
}
where {
?in cn:begin ?d ; rdfs:label ?mds .
optional { ?in cn:link ?lnk }
optional { ?in st:icon ?ii }
optional { ?in rdfs:comment ?cc }
bind (
if (bound(?ii), ?ii,
if (isURI(?in), st:call-template(cn:geticon, ?in), ""))
as ?ic)
bind (
if (isURI(?in) && strstarts(?in, r:),
concat(w:, (substr(?in, strlen(r:) + 1))),
?lnk)
as ?link)
}
]]>
prefix foaf:
prefix o:
prefix w:
prefix r:
template {
if (bound(?link),
st:call-template(cn:href, ?in, ?link, ?ctx, ?ic),
?ctx)
" " ?c " " ?l
}
where {
?in cn:date ?d ; rdfs:label ?ctx .
optional { ?in cn:link ?lnk }
optional { ?in rdfs:comment ?c }
optional { ?in cn:list ?l }
optional { ?in st:icon ?ii }
bind (
if (bound(?ii), ?ii,
if (isURI(?in), st:call-template(cn:geticon, ?in), ""))
as ?ic)
bind (
if (isURI(?in) && strstarts(?in, r:),
concat(w:, (substr(?in, strlen(r:) + 1))),
?lnk)
as ?link)
}
]]>
© 2015 - 2025 Weber Informatics LLC | Privacy Policy