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

sttl.datashape.path.qualified.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
#
# ?ns sh:property ?sh 
# ?sh sh:path ?p ;
#     sh:qualifiedValueShape ?qsh
# ?s subject for path ?p
# compute subList of values of path ?s ?p that match qualifiedValueShape ?qsh
# subList size must match min and max
#
prefix sh:  

template sh:qualifiedValueShape (?shape, ?sh, ?vis, ?s, ?p, ?qsh, ?value) {
  sh:safe(?shape, ?sh, ?suc1 && ?suc2)
}
where {
    graph ?shape {  
        ?ns sh:property ?sh 
        ?sh sh:qualifiedValueShape ?qsh
        optional { ?sh sh:qualifiedMinCount ?min }
        optional { ?sh sh:qualifiedMaxCount ?max }
        optional { ?sh sh:qualifiedValueShapesDisjoint ?disjoint }
    }
            
  bind (sh:qualified(?shape, ?qsh, ?s, ?p) as ?list)
      
  # test disjointness with sibling shapes
  bind (
    if (coalesce(?disjoint, false), 
        # remove elements that are in sibling shapes
        mapfindlist(sh:disjoint, ?list, xt:list(?shape), ?qsh, ?s),
        ?list)
    as ?qlist)
    
  bind (xt:size(?qlist) >= coalesce(?min, 0) as ?suc1) 
  bind (xt:size(?qlist) <= coalesce(?max, xt:size(?qlist)) as ?suc2) 

  bind (st:report(sh:qualifiedMinCount, ?sh, ?shape, ?s, ?p, ?s, ?suc1, ?vis) as ?b1)
  bind (st:report(sh:qualifiedMaxCount, ?sh, ?shape, ?s, ?p, ?s, ?suc2, ?vis) as ?b2)
}

#
# test disjointness of subject ?s value ?o with ?qsh sibling shapes
# for each sibling shape ?sh, compute ?list of values and test ?o not in ?list
#
function sh:disjoint(?o, ?shape, ?qsh, ?s){
   for ((?sh, ?path) in st:cget(sh:sibling, ?qsh)){
        if (xt:member(?o, sh:qualified(?shape, ?sh, ?s, ?path))){
            return (false)
        }        
   } ;
   return (true)
}

#
# Return the list of value nodes that match qualified shape ?sh 
#
function sh:qualified(?shape, ?sh, ?s, ?p){
     let (?list = sh:path(?shape, ?s, ?p)) {
        mapfindlist(sh:qualifiedShape, ?list, xt:list(?shape), ?sh)
     }
}





© 2015 - 2025 Weber Informatics LLC | Privacy Policy