Thanks for your answer :) Is there a way to validate the two files ( data.rdf and schema.rdf ) as .rdf? So without changing the schema... ? I tried with the jena reasoner and with adding ALLDifferent to deny the open world assumption, but that doesnt help.... ? Alex
Gesendet: Sonntag, 01. November 2020 um 12:13 Uhr Von: "Andy Seaborne" <[email protected]> An: [email protected] Betreff: Re: SHACL validation doesn't show an error SHACL uses shapes - not RDFS range and domain "rdfs:range iirds:Component ;" means the range "is of that class" not that there must be that triple because RDFS can be used to infer the fact and add it to the data. See the SHACL spec : https://www.w3.org/TR/shacl/ which has lots of examples of shapes. In this case: In schema.ttl: ------------ PREFIX iirds: <http://iirds.tekom.de/iirds#[http://iirds.tekom.de/iirds#]> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#[http://www.w3.org/1999/02/22-rdf-syntax-ns#]> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#[http://www.w3.org/2000/01/rdf-schema#]> PREFIX sh: <http://www.w3.org/ns/shacl#[http://www.w3.org/ns/shacl#]> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#[http://www.w3.org/2001/XMLSchema#]> PREFIX : <http://example/> :shape1 sh:targetObjectsOf iirds:has-component ; sh:class iirds:Component ; . ------------ and you'll get a violation Add the expected triple to metadata.ttl: ---- <http://iirds.docufy.de/topics/05d2c8268b68ff6444a49358ca7fe925/1/de-de[http://iirds.docufy.de/topics/05d2c8268b68ff6444a49358ca7fe925/1/de-de]> rdf:type iirds:Component . ---- and the violation goes away. >From the commandline (shell scripts): Jena SHACL engine: shacl v -s schema.ttl -d metadata.ttl or see the instructions on https://github.com/TopQuadrant/shacl[https://github.com/TopQuadrant/shacl] for TopQuadrant TopBraid SHACL API shaclvalidate -shapesfile schema.ttl -datafile metadata.ttl Andy On 01/11/2020 02:11, [email protected] wrote: > Hey guys, > i created an Issue one weeg ago and you recommended me to validate my schema > with jena shacl. I did this, but i still don't get the expected result... > What do i have to change or what mistake did i do ? (i am not allowed to > change the schema by the way). > Maybe you have some example code or another idea how to validate my > metadata.rdf ? > > The problem: > As you can see, i have a "topic" containing the property "has-component", but > my schema just allows (rdfs:domain and rdfs:range) a "component" with the > property "has-component". > The validation report says in both ways, that everything is confirm...... > > Thanks for you help:) > Greetings from Germany > Alex > > > > My schema is original an .rdf-schema, but i converted it into .ttl in order > to use shacl-shapes. It looks like the following: > > schema.ttl: > > @prefix schema: <http://schema.org/[http://schema.org/]> . > @prefix rdf: > <http://www.w3.org/1999/02/22-rdf-syntax-ns#[http://www.w3.org/1999/02/22-rdf-syntax-ns#]> > . > @prefix iirds: <http://iirds.tekom.de/iirds#[http://iirds.tekom.de/iirds#]> . > @prefix rdfs: > <http://www.w3.org/2000/01/rdf-schema#[http://www.w3.org/2000/01/rdf-schema#]> > . > iirds:Topic a rdfs:Class ; > rdfs:comment "A topic is a unit of information covering a single subject."@en > ; > rdfs:label "Topic"@en , "Topic"@de ; > rdfs:subClassOf iirds:InformationUnit ; > iirds:description "IRI: required"@en , "The resource of a topic is a file in > the iiRDS package."@en . > > iirds:has-component a rdf:Property ; > rdfs:comment "Relates to a component that is part of another component."@en , > "Verweist auf eine Kompoente, die Teil einer anderen Komponente ist."@de ; > rdfs:domain iirds:Component ; > rdfs:label "has component"@en , "hat Komponente"@de ; > rdfs:range iirds:Component ; > rdfs:subPropertyOf iirds:iirdsRelationConcept ; > iirds:description "Cardinality: > http://iirds.tekom.de/iirds#Component[http://iirds.tekom.de/iirds#Component] > [0..*]"@en , ""@en ; > schema:domainIncludes iirds:Component ; > schema:rangeIncludes iirds:Component . > > iirds:Component a rdfs:Class ; > rdfs:comment "Describes a component of the technical system that the > documentation refers to."@en ; > rdfs:label "Component"@en , "Komponente"@de ; > rdfs:subClassOf iirds:ProductMetadata ; > iirds:description "IRI: required"@en , "Components may have relations to > ot[...] The iirds#Component may also be used as a docking point for external > component definitions."@en . > > > > > > My metadata.rdf converted into metadata.ttl looks like the following: > > metadata.ttl: > > @prefix pifan: > <http://customer.docufy.de/pifan#[http://customer.docufy.de/pifan#]> . > @prefix rdf: > <http://www.w3.org/1999/02/22-rdf-syntax-ns#[http://www.w3.org/1999/02/22-rdf-syntax-ns#]> > . > @prefix iirds: <http://iirds.tekom.de/iirds#[http://iirds.tekom.de/iirds#]> . > @prefix rdfs: > <http://www.w3.org/2000/01/rdf-schema#[http://www.w3.org/2000/01/rdf-schema#]> > . > [...] > <http://iirds.docufy.de/topics/05d2c8268b68ff6444a49358ca7fe925/1/de-de[http://iirds.docufy.de/topics/05d2c8268b68ff6444a49358ca7fe925/1/de-de]> > a iirds:Topic ; > iirds:dateOfCreation "2020-08-06T12:24:07.285+02:00"@de-de ; > iirds:has-component > <http://iirds.docufy.de/metadata/85e7506eb2e33f90c0a802687f559f0c[http://iirds.docufy.de/metadata/85e7506eb2e33f90c0a802687f559f0c]> > ; > iirds:relates-to-component > <http://iirds.docufy.de/metadata/85e7506eb2e33f90c0a802687f559f0c[http://iirds.docufy.de/metadata/85e7506eb2e33f90c0a802687f559f0c]> > ; > iirds:relates-to-product-feature > <http://iirds.docufy.de/metadata/b63e4b15b2dc2d83c0a8026877f6aa88[http://iirds.docufy.de/metadata/b63e4b15b2dc2d83c0a8026877f6aa88]> > , > <http://iirds.docufy.de/metadata/10b4c299b2ddae19c0a8026824aa7410[http://iirds.docufy.de/metadata/10b4c299b2ddae19c0a8026824aa7410]> > , > <http://iirds.docufy.de/metadata/dbbb7334b2e2a9e5c0a8026860d20c17[http://iirds.docufy.de/metadata/dbbb7334b2e2a9e5c0a8026860d20c17]> > ; > iirds:title "Kontaktdaten"@de-de . > [...] > > > My code is the following: > > //try with jena shacl > Graph shapesGraph = RDFDataMgr.loadGraph("schema.ttl"); > Graph dataGraph = RDFDataMgr.loadGraph("metadata.ttl"); > Shapes shapes = Shapes.parse(shapesGraph); > ValidationReport report = ShaclValidator.get().validate(shapes, dataGraph); > ShLib.printReport(report); > System.out.println(); > RDFDataMgr.write(System.out, report.getModel(), Lang.TTL); > > //try with topbraid shacl > Model dataModel = org.topbraid.jenax.util.JenaUtil.createDefaultModel(); > dataModel.read("metadata.ttl"); > Model shapeModel = org.topbraid.jenax.util.JenaUtil.createDefaultModel(); > shapeModel.read("schema.ttl"); > Resource reportResource = ValidationUtil.validateModel(dataModel, shapeModel, > true); > File reportFile = new File("report.ttl"); > > > > > >
