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

sttl.datashape.path.sparql.rq 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
#
# SPARQL Based Constraint
# Evaluate SPARQL query with pre-bind of variable $this with focus nodes
# SPARQL query returns solutions that fail the Constraint
#
prefix sh:  
template  sh:sparql (?shape, ?sh, ?vis, ?s, ?p, ?cst, ?o) {
   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
        }
    }
    
    bind (sh:path(?shape, ?s, ?p) as ?list)
    
    values ?o { unnest(?list) }  
    
    values ($this ?path ?value) { unnest(kg:sparql(concat(?define, ?q), "$this", ?o)) }

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






© 2015 - 2025 Weber Informatics LLC | Privacy Policy