Skip to content

Commit

Permalink
PREFIX ex: defined
Browse files Browse the repository at this point in the history
  • Loading branch information
saumier committed Jun 5, 2022
1 parent 1923eab commit 76fe73e
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 11 deletions.
7 changes: 4 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
source 'https://rubygems.org'

gem 'rdf', git: 'https://github.com/ruby-rdf/rdf.git', branch: 'develop'
gem 'json-ld', git: 'https://github.com/ruby-rdf/json-ld.git', branch: 'develop'
gem 'json-ld', git: 'https://github.com/ruby-rdf/json-ld.git', branch: 'develop'
gem 'sparql', git: 'https://github.com/ruby-rdf/sparql.git', branch: 'develop'
gem 'sxp', git: 'https://github.com/dryruby/sxp.rb.git', branch: 'develop'
gem 'sxp' , git: 'https://github.com/dryruby/sxp.rb.git', branch: 'develop'
gem 'rdf-turtle', git: 'https://github.com/ruby-rdf/rdf-turtle.git', branch: 'develop'
gem 'shacl', git: 'https://github.com/ruby-rdf/shacl.git', branch: 'develop'
gem 'linkeddata', git: 'https://github.com/ruby-rdf/linkeddata.git', branch: 'develop'
gem 'linkeddata' , git: 'https://github.com/ruby-rdf/linkeddata.git', branch: 'develop'
gem 'rdf-aggregate-repo', git: 'https://github.com/ruby-rdf/rdf-aggregate-repo.git', branch: 'develop'
13 changes: 10 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ GIT
sparql (~> 3.2)
sparql-client (~> 3.2)

GIT
remote: https://github.com/ruby-rdf/rdf-aggregate-repo.git
revision: 559d5a0862f616ef584d0004c58436eb1ecd9e67
branch: develop
specs:
rdf-aggregate-repo (3.2.0)
rdf (~> 3.2)

GIT
remote: https://github.com/ruby-rdf/rdf-turtle.git
revision: 6c3a535b4f00b5304062c805ce0ccdda94ca0555
Expand All @@ -72,7 +80,7 @@ GIT

GIT
remote: https://github.com/ruby-rdf/shacl.git
revision: b8353ac0df3e885b58e50cae5d03141466392d07
revision: dd2925b24780effcdcf646a722b2824c288d6cac
branch: develop
specs:
shacl (0.2.1)
Expand Down Expand Up @@ -145,8 +153,6 @@ GEM
public_suffix (4.0.7)
racc (1.6.0)
rack (2.2.3)
rdf-aggregate-repo (3.2.0)
rdf (~> 3.2)
rdf-hamster-repo (3.2.1)
hamster (~> 3.0)
rdf (~> 3.2, >= 3.2.1)
Expand Down Expand Up @@ -228,6 +234,7 @@ DEPENDENCIES
json-ld!
linkeddata!
rdf!
rdf-aggregate-repo!
rdf-turtle!
shacl!
sparql!
Expand Down
20 changes: 17 additions & 3 deletions country-shacl.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,31 @@
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix schema: <http://schema.org/> .
@prefix ex: <http://example.com/ns#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .


# <http://example.com/ns#> sh:declare [
# rdf:type sh:PrefixDeclaration;
# sh:namespace "http://example.com/ns#"^^xsd:anyURI ;
# sh:prefix "ex"
# ] .


ex:LanguageExampleShape
a sh:NodeShape ;
sh:targetClass ex:Country ;
sh:property [sh:path ex:germanLabel ; sh:minCount 2 ];
sh:property [sh:path ex:germanLabel ; sh:minCount 2 ];

sh:sparql [
a sh:SPARQLConstraint ; # This triple is optional
sh:message "Values are literals with German language tag." ;
sh:message "Values are literals with German language tag. ?value" ;
sh:prefixes ex: ;
sh:select """
SELECT $this (ex:germanLabel AS ?path) ?value
PREFIX ex: <http://example.com/ns#>
SELECT $this ?value
WHERE {
$this ex:germanLabel ?value .
FILTER (!isLiteral(?value) || !langMatches(lang(?value), "de"))
Expand Down
2 changes: 1 addition & 1 deletion country.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ ex:ValidCountry a ex:Country ;
ex:germanLabel "Spanien"@de .

ex:InvalidCountry a ex:Country ;
ex:germanLabel "Spain"@en .
ex:germanLabel "Spain"@en .
12 changes: 12 additions & 0 deletions test-country-shacl.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# bundle exec ruby test-country.rb

require 'shacl'
require 'linkeddata'

puts "starting..."
graph = RDF::Graph.load("country-shacl.ttl")
shacl = SHACL.open("https://www.w3.org/ns/shacl-shacl") #, { logger: Logger.new(STDOUT) })
report = shacl.execute(graph)
puts report.conform?
puts report.to_s
#=> ValidationReport(conform?, results*)
2 changes: 1 addition & 1 deletion test-country.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

puts "starting..."
graph = RDF::Graph.load("country.ttl")
shacl = SHACL.open("country-shacl.ttl")
shacl = SHACL.open("country-shacl.ttl") #, { logger: Logger.new(STDOUT) })
report = shacl.execute(graph)
puts report.conform?
puts report.to_s
Expand Down

0 comments on commit 76fe73e

Please sign in to comment.