- 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>
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