W3C home > Mailing lists > Public > public-rdf-shapes@w3.org > May 2017

Re: uniqueLang and minCount

From: Florian Kleedorfer <florian.kleedorfer@austria.fm>
Date: Thu, 01 Jun 2017 00:53:04 +0200
To: Håvard Mikkelsen Ottestad <haavard.ottestad@acando.no>
Cc: public-rdf-shapes@w3.org
Message-ID: <7e61fae8c06a2b10de2a73bb81662e09@austria.fm>
Hi,

Thanks for this riddle - I'm new to SHACL and it got me curious. Two 
tricks: 1. without language, the value is sh:datatype xsd:string. 2. You 
are not restricting ALL values with a property shape, only SOME values 
with one shape and SOME with another, so you can't use sh:and (or sh:or 
or sh:xone), you have to use the sh:qualifiedValueShape feature.

Took me some time to figure that out because I tried with 
sh:or/and/xone. I did not find the definition of sh:or/and/xone in the 
spec too helpful. It says 'sh:or specifies the condition that each value 
node conforms to at least one of the provided shapes.' But I would have 
been much faster solving this if it had sad 'sh:or specifies the 
condition that the set of all value nodes conforms to at least one of 
the provided shapes'

Anyway, here's the shape graph:

@prefix skos:   <http://www.w3.org/2004/02/skos/core#> .
@prefix sh: 	<http://www.w3.org/ns/shacl#> .
@prefix xsd:    <http://www.w3.org/2001/XMLSchema#> .
@prefix rdf: 	<http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix :       <http://example.com/ex#> .

:shape
         a sh:NodeShape ;
         sh:targetNode :target;
         sh:property [
             sh:path  skos:prefLabel ;
             sh:qualifiedValueShapesDisjoint true ;
             sh:qualifiedMaxCount 1 ;
             sh:qualifiedValueShape [ sh:datatype xsd:string ]
         ];
         sh:property [
             sh:path skos:prefLabel ;
             sh:qualifiedValueShapesDisjoint true ;
             sh:uniqueLang true ;
             sh:qualifiedValueShape [ sh:datatype rdf:langString ]
         ].

data graph:

@prefix skos:   <http://www.w3.org/2004/02/skos/core#> .
@prefix sh: 	<http://www.w3.org/ns/shacl#> .
@prefix xsd:    <http://www.w3.org/2001/XMLSchema#> .
@prefix rdf: 	<http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix :       <http://example.com/ex#> .

:target
     skos:prefLabel             "Tree" ;
     skos:prefLabel             "Arbre"@fr ;
     skos:prefLabel             "Tree"@en ;
     skos:prefLabel             "Baum"@de.

HTH,
Florian

Am 2017-05-31 21:32, schrieb Håvard Mikkelsen Ottestad:
> Hi,
> 
> I’m trying to make shapes for DCAT and one of things I have run into
> is trying to force things to have skos:prefLabel such that:
> 
>  	* There is max one per language
> 	* And max one without language
> 
> I can solve the first one with sh:uniqueLang, but how do I solve the
> second?
> 
> Regards,
> 
> Håvard M. Ottestad
Received on Wednesday, 31 May 2017 22:53:35 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 17:02:50 UTC