Re: Validating Schemas

It does sound like you need to be confident with normal JSON-LD validation before worrying about the RDF graph shapes, which is what SHACL is for.

Double parsing (JSON-LD -> in memory RDF 2 times in separate graphs) and comparing the RDF through an isomorphic graph comparator, as included in rdflib, would perhaps ferret out any Blank Nodes and similar incorrect syntax but non-error throwing parsing issues.

Perhaps become a bit more familiar with what the rdflib-jsonld tool will and won’t choke on and just lodge any issues the tool’s issue tracker if you think things could be improved! There has been some recent activity with the tool to handle JSON-LD 1.1 so people are watching the tool.

Unless you are hand typing out loads of JSON-LD though, the ilexanple issues you gave, @ib etc., don’t seem hard to avoid.

— 
Dr Nicholas Car
Data Systems Architect
SURROUND Australia
0477 560 177
nicholas.car@surroundaustralia.com

> On 27 Mar 2020, at 10:32 pm, James Hudson <jameshudson3010@gmail.com> wrote:
> 
> 
> 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> 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> 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> 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> 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> 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 00:36:51 UTC