Well ... I was close!  Thanks for the correction, I'll put that into play
-- would the same structure also be true for sh:ask?  Thanks also for
reminding me of the tutorial page, I should revisit that; I'm anxiously
awaiting the first publication of "SHACL for Dummies" ;)

As a side question, what strategy do people use for documenting shacl
rules?  I've been using rdfs:comment, but I'm open to best-practice
suggestions.

On Tue, Jul 28, 2020 at 6:58 PM Holger Knublauch <hol...@topquadrant.com>
wrote:

> Hi Gary,
>
> I have attached a (slightly) corrected version. Use sh:sparql instead of
> sh:propertyValidator. And for the prefixes I have just pointed at the dash
> namespace, which defines the correct things for the common namespaces such
> as xsd - I couldn't see if your declarations were correct as the example is
> a snippet only. Also I have used ?value as return variable in the SELECT
> because then it will be picked up by the validation report.
>
> This may help
> https://www.topquadrant.com/technology/shacl/tutorial-sparql-constraints/
> and of course the spec
> https://www.w3.org/TR/shacl/#sparql-constraints-example
>
> HTH
> Holger
>
> On 29/07/2020 06:54, Gary Murphy wrote:
>
> I am hoping to master the fine art of sh:sparql and sh:ask validators, and
> I have a situation where the source data can have geocoordinates as
> strings, eg "99.91°N"  - the following sparql code correctly detects values
> out of range:
>
> SELECT *
> WHERE {
>   BIND("99.91°N" as ?value)
>   BIND(abs(xsd:float(replace(str(?value),"[a-zA-Z°]",""))) as ?lat)
>   FILTER( ?lat > "90.0"^^xsd:float )
> }
>
> So with a source graph schema:Geocoordinate
>
> ex:BobPoint
>   a schema:GeoCoordinates ;
>   schema:latitude "-144.75N" ;
>   schema:longitude "172" ;
> .
>
> I am expecting to detect that bad latitude with the following bit of
> shacl using sh:sparql to clean the ?value and cast it to float for
> comparison, just as with the above sparql code.  But it doesn't work ...
>
> hmshape:GeoCoordinates-latitude-limits
>   a sh:PropertyShape ;
>   sh:path schema:latitude ;
>   sh:propertyValidator [
>         a sh:SPARQLSelectValidator ;
>       sh:prefixes schema: ;
>       sh:prefixes xsd: ;
>       sh:select """
> SELECT $this ?lat
> WHERE {
>   $this $PATH ?value .
>   BIND(abs(xsd:float(replace(str(?value),\"[a-zA-Z° ]\",\"\"))) AS ?lat)
>   FILTER( xsd:float(?lat) > xsd:float(90.0) )
> }""" ;
>     ] ;
> .
> hmshape:GeoCoordinatesShape
>   a sh:NodeShape ;
>   sh:property hmshape:GeoCoordinates-latitude-limits ;
>   sh:targetClass schema:GeoCoordinates ;
> .
>
> Unfortunately, this rule always approves whatever value I give it, no
> warnings or errors.  I've tried variations, casting to xsd:float or not,
> using sh:validator with sh:ask, but it still accepts any value.  Just to be
> sure, I added sh:minCount 2 to assure myself the rule was being reached,
> and it is.
>
> What am I missing?
>
> Also, is this the correct use of sh:prefixes?  these are defined in the
> hmshape owl:Ontology with sh:declare bnodes
> --
> Gary Lawrence Murphy <g...@schemaapp.com> - Hunch Manifest, 15 Wyndham N
> 'C', Guelph
> --
> You received this message because you are subscribed to the Google Groups
> "TopBraid Suite Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to topbraid-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/topbraid-users/CADnyxpu7Fsf%3DN0vc%2BmWG2%2BnkiMD%3DHH5-uXwditHvF5zABGqYrA%40mail.gmail.com
> <https://groups.google.com/d/msgid/topbraid-users/CADnyxpu7Fsf%3DN0vc%2BmWG2%2BnkiMD%3DHH5-uXwditHvF5zABGqYrA%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
> --
> You received this message because you are subscribed to the Google Groups
> "TopBraid Suite Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to topbraid-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/topbraid-users/b2c75635-b510-59d3-f2af-4dfcb3ae9860%40topquadrant.com
> <https://groups.google.com/d/msgid/topbraid-users/b2c75635-b510-59d3-f2af-4dfcb3ae9860%40topquadrant.com?utm_medium=email&utm_source=footer>
> .
>


-- 
Gary Lawrence Murphy <g...@schemaapp.com> - Hunch Manifest, 15 Wyndham N
'C', Guelph

-- 
You received this message because you are subscribed to the Google Groups 
"TopBraid Suite Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to topbraid-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/topbraid-users/CADnyxpv5VWfWGCdY%2Bt4gEtmba5i0itJVSmR4%3D92HvrhJ0fWB6g%40mail.gmail.com.

Reply via email to