Re: library to convert shacl property paths to sparql property paths

Hi Niels,
In the python world, there is a helper function in PySHACL to do SHACL paths to SPARQL paths.
https://github.com/RDFLib/pySHACL/blob/master/pyshacl/helper/path_helper.py
And there was a similar function added in RDFLib last year for SHACL to SPARQL:
https://github.com/RDFLib/rdflib/pull/2699
Finally, recently a SPARQL to SHACL companion was added to RDFLib:
https://github.com/RDFLib/rdflib/pull/2990

Regards,
Ashley Sommer

________________________________
From: Thomas Francart <thomas.francart@sparna.fr>
Sent: Tuesday, 4 February 2025 11:19 PM
To: tomasz@t-code.pl <tomasz@t-code.pl>
Cc: Niels Vandekeybus <niels@vandekeybus.eu>; public-shacl@w3.org <public-shacl@w3.org>
Subject: Re: library to convert shacl property paths to sparql property paths

Hello

We have in Java:

  *   SHACL to SPARQL : https://github.com/sparna-git/shacl-play/blob/9e9c471ac465dcc03a75cf66406890d2d8a87c93/shacl-commons/src/main/java/fr/sparna/rdf/jena/ModelRenderingUtils.java#L136
  *   SPARQL to SHACL : https://github.com/sparna-git/xls2rdf/blob/0ac663a88bc3e3c97441024b6d5b33396b5440d1/xls2rdf-lib/src/main/java/fr/sparna/rdf/xls2rdf/SparqlPropertyPathToShaclPropertyPathConverter.java#L89 (using RDF4J parser)

Thomas

Le mar. 4 févr. 2025 à 13:42, tomasz@t-code.pl<mailto:tomasz@t-code.pl> <tomasz@t-code.pl<mailto:tomasz@t-code.pl>> a écrit :
Hello Niels

I have implemented the SHACL-SPARQL direction in https://www.npmjs.com/package/clownface-shacl-path
More recently, I implemented a SPARQL Property Paths parser using antl4r: https://www.npmjs.com/package/sparql-path-parser

IIRC, there is no conversion back to SHACL Property Path triples (JS representation is used) but that would be easy to add.

Best,
Tom

From: Niels Vandekeybus <niels@vandekeybus.eu<mailto:niels@vandekeybus.eu>>
Date: Tuesday, 4 February 2025 at 13:30
To: public-shacl@w3.org<mailto:public-shacl@w3.org> <public-shacl@w3.org<mailto:public-shacl@w3.org>>
Subject: library to convert shacl property paths to sparql property paths

Hi everyone,

I hope this is the right channel to ask. For a project I need to convert shacl property paths to sparql property paths (and back). I was wondering if anyone knows of a library to do this? For my use case javascript would be ideal.  If none exists I could write my own (the spec explains the conversion quite well), but I'm a bit surprised this doesn't exist yet. Hoping for some pointers that I missed :).

Kind regards,

Niels


--

Thomas Francart - SPARNA
linked data | domain ontologies | knowledge graphs
blog : blog.sparna.fr<http://blog.sparna.fr>, site : sparna.fr<http://sparna.fr>, linkedin : fr.linkedin.com/in/thomasfrancart<https://fr.linkedin.com/in/thomasfrancart>
tel :  +33 (0)6.71.11.25.97

Received on Tuesday, 4 February 2025 22:09:48 UTC