Re: Validating Schemas

Hey James,

Thanks for starting this conversation!

> What may be a bit odd is that the serializer ignores the key / value pair, but there is probably a good reason for that or there is a parameter I am missing that would make it stricter.

Pretty sure this are being ignored simply because they're not in your context object/file--which is standard JSON-LD parsing behavior.

And yes, that means if you wanted to catch that typo, you'd have to do it at the JSON level, not RDF.

Lots of layers. :)

Cheers!
Benjamin
Co-Chair, W3C JSON-LD WG
---
http://bigbluehat.com/
________________________________
From: James Hudson <jameshudson3010@gmail.com>
Sent: Friday, March 27, 2020 8:32:00 AM
To: Håvard Ottestad <hmottestad@gmail.com>
Cc: Public Shacl W3C <public-shacl@w3.org>
Subject: Re: Validating Schemas

Hello Håvard,

Thank for your reply.

I am using https://github.com/RDFLib/rdflib-jsonld for my serialization. When it comes across "@ib" it will create a blank node, which makes sense. What may be a bit odd is that the serializer ignores the key / value pair, but there is probably a good reason for that or there is a parameter I am missing that would make it stricter. I will look into using sh:nodeKind. I believe there is a similar issue with "@type" and there is probably a sh:XXX related to that key.

I will take a closer look at as sh:closed and sh:minCount.

It does appear that SHACL is a viable solution to validating json-ld based schemas.

Regards,
James

On Thu, Mar 26, 2020 at 3:11 PM Håvard Ottestad <hmottestad@gmail.com<mailto:hmottestad@gmail.com>> wrote:
Hi,

Things I think you can do with SHACL:

> I have not typed "@Ib" instead of "@id". That there is a "@id" key for every object.

I think that would be hard. Depends what happens when there isn't an @id. If the parser generates an error, then that should solve it for you. If it generates a blank node, then you can use sh:nodeKind to validate for that.

> Additionally, that when I have declared something as a subclass, that the superclass exists and there are no typos in the superclass name.

You could do some form of sh:minCount and also possibly checking that the sh:class is an rdfs:Class.

Spelling mistakes for properties can be solved with sh:closed. Which will make sure that all properties used are specified in the SHACL shape.

Cheers,
Håvard




On Thu, Mar 26, 2020 at 7:58 PM Irene Polikoff <irene@topquadrant.com<mailto:irene@topquadrant.com>> wrote:
JSON-LD, Turtle, RDF/XML, etc. are all different alternative text serialization formats for RDF.  Is this what you meant by “alternative representation of RDF”?

SHACL does not validate at the level of “is this a valid RDF serialization”. It validates at the level “does this RDF data have the expected shape”.

I believe pretty much any RDF-based software already has the ability to successfully serialize and de-serialize standard text formats and report an error if the format is incorrect.

On Mar 26, 2020, at 2:43 PM, James Hudson <jameshudson3010@gmail.com<mailto:jameshudson3010@gmail.com>> wrote:

Hello,

Yes, I understand that. A json-ld document is an alternate representation of RDF.

Regards,
James
`

On Thu, Mar 26, 2020 at 2:35 PM Irene Polikoff <irene@topquadrant.com<mailto:irene@topquadrant.com>> wrote:
Hello James,

SHACL validates RDF. It does not validate text serializations of RDF to make sure that a serialized document/file itself is a syntactically valid sterilization of RDF.

So, I would think that first you'd need to have a document that is a valid serialization of RDF i.e., it can be successfully parsed and de-serialized. Then, you could use SHACL to ensure that RDF data corresponds to the SHACL shapes that describe it. I am using “RDF data” loosely, meaning any set of RDF triples, whether it is data or schema does not matter. By schema I mean the model of the data - classes, properties, allowed values for properties.

On Mar 26, 2020, at 1:33 PM, James Hudson <jameshudson3010@gmail.com<mailto:jameshudson3010@gmail.com>> wrote:

Hello,

Being rather new to the linked data world, I am at the point where I need to work out the best methods for validating schema's and the role that SHACL may or may not be able to play.

Since it is easier to discuss something real, I have created a sample schema in the json-ld format and have made it available here:

https://gist.github.com/James-Hudson3010/7deec4df32aa6b97509aeb490f1edf9b

It can be entered into the json-ld playground and visualized without error.

What I mean by validation of the schema, is that I would like to make sure it is valid json-ld document. I have not typed "@Ib" instead of "@id". That there is a "@id" key for every object. Additionally, that when I have declared something as a subclass, that the superclass exists and there are no typos in the superclass name.

Perhaps someone has already been working on to playing with shape files for json-ld schema's.

Perhaps I am ascribing capabilities to SHACL that it does not have.

Any thoughts or comments would be appreciated.

Additionally, for completeness, I have created an instance based on this schema and that can be found here:

https://gist.github.com/James-Hudson3010/227ffb77b853a29556be5b5c3a67c309

Regards,
James

Received on Saturday, 28 March 2020 02:18:58 UTC