- From: Holger Knublauch <holger@topquadrant.com>
- Date: Tue, 18 Feb 2020 09:22:32 +1000
- To: public-shacl@w3.org
- Message-ID: <56336621-3159-3b57-313d-3d5ee3383b8c@topquadrant.com>
Hi Angelo, there is a small mismatch in the URIs: - the data uses http://www.example.org/ns#germanLabel - the constraint JS code uses http://example.org/ns#germanLabel Once you align those (add the www.) it should work (I tried by running it from TBC) HTH Holger On 18/02/2020 01:11, Angelo Frozza 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 shshacl-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 <mailto: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 23:22:57 UTC