W3C home > Mailing lists > Public > public-data-shapes-wg@w3.org > March 2016

Re: implementing paths for SHACL

From: Simon Steyskal <simon.steyskal@wu.ac.at>
Date: Thu, 24 Mar 2016 07:19:56 +0100
To: "Peter F. Patel-Schneider" <pfpschneider@gmail.com>
Cc: RDF Data Shapes Working Group <public-data-shapes-wg@w3.org>
Message-ID: <fdfc754b8647c96a5bec3f9c584c5c0f@wu.ac.at>
Hi!

> I had thought that implementing paths for SHACL would be hard, with 
> lots of
> changes required.   It turned out to be not nearly as hard as I 
> expected in my
> implementation.

I'm very happy to hear that!

Could you provide a minimal working example using paths?

regards,
simon

---
DDipl.-Ing. Simon Steyskal
Institute for Information Business, WU Vienna

www: http://www.steyskal.info/  twitter: @simonsteys

Am 2016-03-23 17:00, schrieb Peter F. Patel-Schneider:
> I had thought that implementing paths for SHACL would be hard, with 
> lots of
> changes required.   It turned out to be not nearly as hard as I 
> expected in my
> implementation.
> 
> The core of the implementation of paths is a function that converts a 
> path
> (however the syntax is defined) into a string that can be used as a 
> SPARQL
> path.  Then instead of using an IRI as the predicate in triple patterns 
> just
> use the result of this function.  I ended up with nine places where 
> this was
> needed, two each in sh:equals, sh:notEquals, sh:lessThan, and
> sh:lessThanOrEquals and one in sh:propValues.
> 
> There is a little bit more that has to be done if a path is used 
> elsewhere.
> 
> My conversion function ended up being roughly
> 
> def parttoSPARQL(g,part) :
>     result =  ("^"+g.value(part,SH.inverse).n3()) \
>               if (part,SH.inverse,None) in g else part.n3()
>     return result
> 
> def pathtoSPARQL(g,value) :
>     if (value,RDF.rest,None) in g :
>         path = [ parttoSPARQL(g,part) for part in listElements(g,value) 
> ]
>         return Literal("/".join(path))
>     else : return parttoSPARQL(g,value)
> 
> 
> peter
Received on Thursday, 24 March 2016 06:20:23 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 19:30:30 UTC