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

template.dsconstraint.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){
  sh:safe(?shape, ?sh, ?suc)
}
where {

  bind (sh:path(?shape, ?s, ?p) as ?l)

  bind (xt:member(?s, ?l) as ?suc) 
  
  bind (st:report(sh:equals, ?sh, ?shape, ?s, ?p, ?s, ?suc, ?vis) as ?b)
  
}
]]>





 

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

  bind (sh:path(?shape, ?s, ?p) as ?l)
  
  bind (! xt:member(?s, ?l) as ?suc) 
  
  bind (st:report(sh:disjoint, ?sh, ?shape, ?s, ?p, ?s, ?suc, ?vis) as ?b)
  
}
]]>





 

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

  bind (sh:path(?shape, ?s, ?p) as ?l)
  
  values ?m { unnest(?l) }
  
  bind (?s = ?m as ?suc)
  
  bind (st:report(sh:equals, ?sh, ?shape, ?s, ?p, ?m, ?suc, ?vis) as ?b)
  
}
]]>





 

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

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

]]>





 

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

  values ?oper {sh:equals1 sh:equals2}

}
]]>





 

template sh:class (?shape, ?sh, ?vis, ?s, ?c){
  sh:safe(?shape, ?sh, ?suc)
}
where {

  bind (exists { ?s rdf:type/rdfs:subClassOf* ?c } as ?suc)
  bind (st:report(sh:class, ?sh, ?shape,  ?s, rdf:type, ?s, ?suc, ?vis) as ?b)
}

]]>





 
template sh:sparql (?shape, ?sh, ?vis, ?s, ?cst) {
   sh:safe(?shape, ?sh, ?suc)
}
where {
    graph ?shape {  
        ?sh sh:sparql ?cst 
        ?cst sh:select ?q
        filter not exists { ?cst sh:deactivated true }
        
        # collect prefix definitions
        # TBD: do it once and record it
        {
            select ?cst 
              (group_concat(concat("prefix ", ?pr, ": <", str(?ns), ">") ;  separator="\n") 
              as ?define) 
            where {
                ?cst sh:prefixes ?ns
                [] sh:declare [ sh:prefix ?pr ; sh:namespace ?ns ] 
            }
            group by ?cst
        }
    }
    
    values ($this ?path ?value) { unnest(kg:sparql(concat(?define, ?q), "$this", ?s)) }

    # SPARQL query returns solutions that fail
    bind (false as ?suc)
    
    bind (st:report(sh:sparql, ?cst, ?shape, ?s, ?path, ?value, ?suc, ?vis) as ?b)
    
}


]]>





 

template st:profile {}
where {}

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

function st:default(?term){
    true
}

function st:defaultNamed(?term){
    true
}

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







]]>





 

template sh:datatype (?shape, ?sh, ?vis, ?s, ?d){
  sh:safe(?shape, ?sh, ?suc)
}
where {
  
  bind (sh:datatype(?s, ?d)  as ?suc)
  
  bind (st:report(sh:datatype, ?sh, ?shape, ?s, st:null, ?s, ?suc, ?vis) as ?b)
}
]]>





 

template (?shape, ?sh, ?vis, ?ls) {
    st:call-template(?q, ?shape, ?sh, ?vis, ?s, ?m)
}
where {
  graph ?shape {  
    values ?q { sh:class sh:pattern sh:disjoint sh:equals sh:sparql }
    ?sh ?q ?m            
  }
  
  values ?s { unnest(?ls) }
}


]]>





 

template (?shape, ?sh, ?vis, ?ls) {
  sh:safe(?shape, ?sh, ?suc)
}
where {
  graph ?shape {  
    values ?q { 
        sh:hasValue sh:datatype sh:minInclusive sh:minExclusive sh:maxInclusive sh:maxExclusive sh:minLength sh:maxLength sh:nodeKind sh:node sh:in sh:languageIn 
    }
    ?sh ?q ?m 
    #filter not exists { ?sh sh:path ?p }
 
  }
  
  values ?s { unnest(?ls) }
    
  bind (coalesce(sh:functioncall(?q, ?shape, ?s, ?m), false) as ?suc )
  
  bind (st:report(?q, ?sh, ?shape, ?s, st:null, ?s, ?suc, ?vis) as ?b)
}

]]>








© 2015 - 2025 Weber Informatics LLC | Privacy Policy