All Downloads are FREE. Search and download functionalities are using the official Maven repository.

template.dsproperty.rul Maven / Gradle / Ivy

Go to download

Corese is a Semantic Web Factory (triple store and SPARQL endpoint) implementing RDF, RDFS, SPARQL 1.1 Query and Update.

There is a newer version: 4.6.1
Show newest version





 

template sh:equals1 (?shape, ?sh, ?vis, ?s, ?p, ?q, ?o){
  sh:safe(?shape, ?sh, ?suc)
}
where {

  ?s ?p ?o  
  bind ( exists { ?s ?q ?o }   as ?suc)
    
  bind (st:report(sh:equals, ?sh, ?shape,  ?s, ?p, ?o, ?suc, ?vis) as ?b)
  
}

]]>





 

template sh:not (?shape, ?sh, ?vis, ?s, ?p, ?cst, ?o){
  sh:safe(?shape, ?sh, ?suc)
}
where {
  ?s ?p ?o 
  
  bind (! sh:hasProperty(?shape, ?cst, false, ?s, ?p, ?o) as ?suc)
  
  bind (st:report(sh:not, ?sh, ?shape, ?s, ?suc, ?vis) as ?b)
}

]]>





 

template sh:disjoint (?shape, ?sh, ?vis, ?s, ?p, ?q, ?o){
  sh:safe(?shape, ?sh, ?suc)
}
where {

  ?s ?p ?o 
  bind (not exists { ?s ?q ?o } as ?suc)
    
  bind (st:report(sh:disjoint, ?sh, ?shape, ?s,  ?p, ?o, ?suc, ?vis) as ?b)
  
}

]]>





 

template sh:equals2 (?shape, ?sh, ?vis, ?s, ?p, ?q, ?o){
  sh:safe(?shape, ?sh, ?suc)
}
where {
 
  ?s ?q ?o  
  bind ( exists { ?s ?p ?o }   as ?suc)  
    
  bind (st:report(sh:equals, ?sh, ?shape, ?s,  ?q, ?o, ?suc, ?vis) as ?b)
  
}

]]>





 

template sh:equals (?shape, ?sh, ?vis, ?s, ?p, ?q, ?o){
  if (bound(?o), 
    st:call-template(?oper, ?shape, ?sh, ?vis, ?s, ?p, ?q, ?o),
    st:call-template(?oper, ?shape, ?sh, ?vis, ?s, ?p, ?q))
}
where {

  values ?oper {sh:equals1 sh:equals2}

}

]]>





 

template sh:lessThanOrEquals (?shape, ?sh, ?vis, ?s, ?p, ?q, ?o){
  sh:safe(?shape, ?sh, ?suc)
}
where {
 
  ?s ?p ?o ; ?q ?v
  
  bind (coalesce(?o <= ?v, false) as ?suc)
    
  bind (st:report(sh:lessThanOrEquals, ?sh, ?shape,  ?s, ?q, ?o, ?suc, ?vis) as ?b)
  
}
 

]]>





 

template sh:hasValue (?shape, ?sh, ?vis, ?s, ?p, ?v, ?o){
  sh:safe(?shape, ?sh, ?suc)
}
where {

  bind (
    exists { ?s ?p ?o filter coalesce(?o = ?v, false) }
  as ?suc)
  
  bind (st:report(sh:hasValue, ?sh, ?shape,  ?s, ?p, ?v, ?suc, ?vis) as ?b)
}

]]>





 

template st:profile {}
where {}

function st:aggregate(?x) {
  st:agg_and(?x)
}

function st:optimize(?shape, ?sh){
    true
}








]]>





 

template sh:or (?shape, ?sh, ?vis, ?s, ?p, ?or, ?o) {
  sh:safe(?shape, ?sh, ?suc)
}
where {
   
    ?s ?p ?o
    
    bind (sh:or(sh:hasProperty, ?or, ?s, ?p, ?o, ?shape) as ?count)
	bind (! bound(?count) AS ?failure) .
	bind ( IF (?failure, false, ?count)  as ?suc)

    bind (st:report(sh:or, ?sh, ?shape, ?s,  ?suc, ?vis) as ?b)
  
}



]]>





 

template sh:pattern (?shape, ?sh, ?vis, ?s, ?p, ?exp, ?o) {
  sh:safe(?shape, ?sh, ?suc)
}
where {
  graph ?shape {  
    ?sh sh:pattern ?exp   
    optional { ?sh sh:flags ?flag }
  }
  
  ?s ?p ?o
  
  bind ( 
    coalesce(
        ! isBlank(?o) && 
        if (bound (?flag), regex(?o, ?exp, ?flag), regex(?o, ?exp)), 
        false) 
  as ?suc )

  bind (st:report(sh:pattern, ?sh, ?shape, ?s, ?p, ?o, ?suc, ?vis) as ?b)
}


]]>





 

template sh:maxCount (?shape, ?sh, ?vis, ?s, ?p, ?m, ?o){
  sh:safe(?shape, ?sh, ?suc)
}
where {

  bind (sh:count(?s, ?p) as ?val)
  bind (?val <= ?m as ?suc)
  bind (st:report(sh:maxCount, ?sh, ?shape, ?s, ?p, ?val, ?suc, ?vis) as ?b)
}


]]>





 

template sh:uniqueLang (?shape, ?sh, ?vis, ?s, ?p, ?l, ?o){
  sh:safe(?shape, ?sh, ?suc)
}
where {

  ?s ?p ?o
  bind (lang(?o) as ?lang)
  filter (bound(?lang) && ?lang != "")
  
  bind (not exists { ?s ?p ?v  filter (?v != ?o && lang(?v) = ?lang) }    as ?suc)

  bind (st:report(sh:uniqueLang, ?sh, ?shape, ?s, ?p, ?o, ?suc, ?vis) as ?b)
}

]]>





 

template sh:and (?shape, ?sh, ?vis, ?s, ?p, ?and, ?o) {
  sh:safe(?shape, ?sh, ?suc)
}
where {

    ?s ?p ?o

    bind (sh:and(sh:hasProperty, ?and, ?s, ?p, ?o, ?shape) as ?count)
	bind (! bound(?count) AS ?failure) .
	bind ( IF (?failure, false, ?count)  as ?suc)

    bind (st:report(sh:and, ?sh, ?shape, ?s,  ?suc, ?vis) as ?b)
}



]]>





 

template sh:minCount (?shape, ?sh, ?vis, ?s, ?p, ?m, ?o){
  sh:safe(?shape, ?sh, ?suc)
}
where {

  bind (sh:count(?s, ?p) as ?val)
  bind (?val >= ?m as ?suc)
  bind (st:report(sh:minCount, ?sh, ?shape, ?s, ?p, ?val, ?suc, ?vis) as ?b)
}


]]>





 

template sh:lessThan (?shape, ?sh, ?vis, ?s, ?p, ?q, ?o){
  sh:safe(?shape, ?sh, ?suc)
}
where {
  
  ?s ?p ?o ; ?q ?v
  
  bind (coalesce(?o < ?v, false) as ?suc)
    
  bind (st:report(sh:lessThan, ?sh, ?shape, ?s, ?q, ?o, ?suc, ?vis) as ?b)
  
}
 

]]>





 

template (?shape, ?sh, ?vis, ?ls, ?p, ?o) {
  if (bound(?o), 
    st:call-template(?oper, ?shape, ?sh, ?vis, ?s, ?p, ?b, ?o),
    st:call-template(?oper, ?shape, ?sh, ?vis, ?s, ?p, ?b))
}
where {
    graph ?shape {  
        values ?oper { 
            sh:equals sh:maxCount sh:minCount sh:pattern sh:uniqueLang 
            sh:hasValue 
            sh:lessThanOrEquals sh:lessThan sh:disjoint sh:and sh:or sh:not 
        }
        ?sh ?oper ?b    
    }
    
    values ?s { unnest(?ls) }
}
         

]]>





 property, ?o is not bound
# case property boolean, ?o is bound
# ?sh = [ sh:predicate ?p ; sh:class ?m ]
# ?ls = list of target nodes of ?sh
#
prefix sh:  

template (?shape, ?sh, ?vis, ?ls, ?p, ?o) {
  sh:safe(?shape, ?sh, ?suc)
}
where {
  graph ?shape {  
    values ?q { 
        sh:minLength sh:maxLength sh:datatype sh:stem 
        sh:minInclusive sh:minExclusive sh:maxInclusive sh:maxExclusive 
        sh:nodeKind sh:class sh:in sh:languageIn sh:shape
    }
    ?sh ?q ?m 
  }
  values ?s { unnest(?ls) }  
  ?s ?p ?o

  bind (
  coalesce(
    if (?q in (sh:in, sh:languageIn, sh:shape), 
        funcall(?q, ?shape, ?o, ?m), funcall(?q, ?o, ?m)), 
    false) 
  as ?suc )
  
  bind (st:report(?q, ?sh, ?shape, ?s,  ?p, ?o, ?suc, ?vis) as ?b)
}


]]>








© 2015 - 2025 Weber Informatics LLC | Privacy Policy