w3c / data-shapes

RDF Data Shapes WG repo
87 stars 33 forks source link

How to validate that a predicate is atleast provided in English? #144

Closed danielbeeke closed 1 year ago

danielbeeke commented 1 year ago

Hello,

I am trying to have the situation where schema:name is required in English and other languages may also be supplied. Is this possible with SHACL?

Kind regards Daniel

My SHACL tryout that does not work.

    sh:property [
        sh:path schema:name ;
        sh:datatype rdf:langString ;
        sh:minCount 1 ;
        sh:xone (
        [ 
            sh:path schema:name ;
            sh:inLanguage ("en") ;
            sh:uniqueLang true ;
            sh:minCount 1 ;
            sh:maxCount 1 ;
        ] 
        [ 
            sh:path schema:name ;
            sh:uniqueLang true ;
        ] ) ;
    ] .

Examples of what would validate:

<ex:thing1> schema:name "test"@en

<ex:thing1> schema:name "test"@de, "test"@en

Would not validate:

<ex:thing1> schema:name "test"@de

<ex:thing1> schema:name "test"@de, "test"@nl
danielbeeke commented 1 year ago

It might be this use case (I think): https://w3c.github.io/data-shapes/data-shapes-ucr/#dfn-uc21

HolgerKnublauch commented 1 year ago

What you are looking for is a qualified cardinality restriction. For example (untested):

sh:property [
    sh:path schema:name ;
    ...
    sh:qualifiedMinCount 1 ;
    sh:qualifiedMaxCount 1 ;
    sh:qualifiedValueShape [
        sh:languageIn ( "en" )
    ]
]

(You had sh:inLanguage which should be sh:languageIn)

danielbeeke commented 1 year ago

Thanks! Great somehow I have looked over that one when I read the docs.

HolgerKnublauch commented 1 year ago

If your question has been answered, would you mind closing the ticket? Thanks.

danielbeeke commented 1 year ago

Yes it has been answered thanks!