@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix qudt: <http://qudt.org/schema/qudt/> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix sh: <http://www.w3.org/ns/shacl#> .

qudt:AllValuesMustHaveSameDataTypeShape a owl:Class,
        sh:NodeShape ;
    rdfs:label "All Values must have same DataType Shape" ;
    rdfs:isDefinedBy <http://qudt.org/3.2.0/schema/datatype>,
        <http://qudt.org/3.2.0/schema/shacl/datatype> ;
    sh:severity sh:Violation ;
    sh:sparql [ sh:message "Data Item {$this} has type {?valueType}." ;
            sh:prefixes <http://qudt.org/3.2.0/schema/shacl/datatype> ;
            sh:select """
        SELECT $this ?valueType
        WHERE {
              $this qudt:datatype/qudt:rdfsDatatype ?datatype .
              $this qudt:value ?valueList.
              ?valueList rdf:rest*/rdf:first ?value .
              BIND(datatype(?value) as ?valueType) .
              FILTER(?valueType != ?datatype)
        }
        """ ] ;
    sh:targetClass qudt:HomogeneousArray .

