- From: Irene Polikoff <irene@topquadrant.com>
- Date: Mon, 17 Feb 2020 10:27:42 -0500
- To: Angelo Frozza <frozza@gmail.com>
- Cc: public-shacl@w3.org
- Message-Id: <AA63CE90-352C-455B-AD42-168FB12F02A2@topquadrant.com>
I would have expected the constraint to be specified for the Property Shape with the ex:germanLabel sh:path as opposed to the Node Shape that targets countries. Sent from my iPhone > On Feb 17, 2020, at 10:11 AM, Angelo Frozza <frozza@gmail.com> wrote: > > > You could take a copy of its code base and evolve it to your needs, or use the Java-based SHACL API. > > I'm using now the SHACL API. > > I copied the example JavaScript-based Constraint in 6.1 section from > https://www.w3.org/TR/shacl-js/ > > The Data Graph has 3 instances (2 wrongs). > ======== > @prefix ex: <http://www.test.com/ns#> . > > ex:ValidCountry a ex:Country ; > ex:germanLabel "Spanien"@de . > > ex:InvalidCountry a ex:Country ; > ex:germanLabel "Spain"@en . > > ex:InvalidCountry_2 a ex:Country ; > ex:germanLabel "Spain"@pt . > ======== > > The JavaScript function is: > ======== > function validateGermanLabel($this) { > var results = []; > var p = TermFactory.namedNode("http://example.org/ns#germanLabel"); > var s = $data.find($this, p, null); > for(var t = s.next(); t; t = s.next()) { > var object = t.object; > if(!object.isLiteral() || !object.language.startsWith("de")) { > results.push({ > value : object > }); > } > } > return results; > } > ======== > > And, the Shape Graph is: > ======== > @prefix sh: <http://www.w3.org/ns/shacl#> . > @prefix xsd: <http://www.w3.org/2001/XMLSchema#> . > @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . > @prefix ex: <http://www.test.com/ns#> . > @prefix dash: <http://datashapes.org/dash> . > @prefix sf: <http://www.opengis.net/ont/sf#> . > @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . > > ex:LanguageExampleShape > a sh:NodeShape ; > sh:targetClass ex:Country ; > sh:js [ # _:b1 > a sh:JSConstraint ; # This triple is optional > sh:message "Values are literals with German language tag." ; > > sh:jsLibrary [ sh:jsLibraryURL "http://54.201.29.21/shapes/SHACL-JS-W3C-Javascript.js" ] ; > > sh:jsFunctionName "validateGermanLabel" ; > ] . > ======== > > > All files can be found in http://54.201.29.21/shapes/. > > I use the following command to validate the Data Graph: > > sudo sh shacl-1.3.1/bin/shaclvalidate.sh -datafile myExamples/SHACL-JS-W3C-DataGraph.ttl -shapesfile myExamples/SHACL-JS-W3C-ShapeGraph.ttl > > But in the result it appeared as valid. > The 2 violations did not appear in the Data Graph. > > [ a <http://www.w3.org/ns/shacl#ValidationReport> ; > <http://www.w3.org/ns/shacl#conforms> > true > ] . > > I can't see where my error is, if it is in any of the files, in the command executed via terminal or if it can be my installation of the SHACL API. > > Hugs, > > -- > > ----- > Prof. Angelo Augusto Frozza, M.Sc. > angelo.frozza@ifc.edu.br > Doutorando PPGCC/UFSC > > Professor EBTT > IFC - Instituto Federal Catarinense - Campus Camboriú > http://about.me/tilfrozza > > Sugestões de leitura: > NoSQL DAiLY - https://paper.li/TilFrozza/1460718203 > STARTUP NEWS - http://paper.li/TilFrozza/1392231760 > A CAVERNA DO MESTRE - http://paper.li/TilFrozza/1392230815 > RESUMO DA SEMANA - http://paper.li/TilFrozza/1392231274 >
Received on Monday, 17 February 2020 15:28:00 UTC