weso / shapes-rs

RDF data shapes implementation in Rust
https://www.weso.es/shapes-rs/
Apache License 2.0
23 stars 1 forks source link

Output a SHACL #38

Closed MarcAntoine-Arnaud closed 3 weeks ago

MarcAntoine-Arnaud commented 1 month ago

Hi,

Is it possible to output an SHACL Schema in turtle for example ?

Best regards, Marc-Antoine

labra commented 1 month ago

I think it is not yet implemented, but is something that is definitely important to have.

MarcAntoine-Arnaud commented 1 month ago

I have found:

  let mut writer: ShaclWriter<SRDFGraph> = ShaclWriter::new();

  let mut buffer = std::io::BufWriter::new(Vec::new());
  writer.write(&schema).unwrap();
  writer.serialize(RDFFormat::Turtle, &mut buffer).unwrap();

  let bytes = buffer.into_inner().unwrap();
  println!("{}", String::from_utf8(bytes).unwrap());

I can output a Turtle, containing <http://example.org/AddressShape> a <http://www.w3.org/ns/shacl#PropertyShape> . I will try to add more to see if everything works.

labra commented 1 month ago

Yes, the idea is that it should work, but the support for SHACL was added very recently and is still work in progress...well, most of the project is work in progress at this moment.

I was very busy with my teaching duties in the last months, but my plan is to resume the work in these libraries in the next weeks, so I hope this situation can improve...and of course, if you want to contribute it would be greatly appreciated.

labra commented 3 weeks ago

I noticed you already advanced in this issue...is the work already finished so we could close this issue?

One enhacement for which we may wat to create a different issue is that the generated blanknodes are a bit ugly...but nevertheless it's great that it works.

I added this page to the HowTo guides that shows how we can now read a SHACL file in one format and convert it to another format.

MarcAntoine-Arnaud commented 3 weeks ago

Yes I have a first version that works. In my use case I have another library that parse an Ontology (in turtle) and I generate the SHACL based on it. by using the pyshacl, I'm able to validate data along the SHACL so I can validate the data face to the Ontology.