Как проверить rdf: введите engine.validateNodesAgainstShape - PullRequest
0 голосов
/ 29 апреля 2020

В TopQuadrant shacl 1.3.2, я пытаюсь использовать

engine.validateNodesAgainstShape(focusNodes, shape.asNode());

с графиком формы:

bds:PersonNameShape  a  sh:NodeShape ;
    rdfs:label      "Person Name Shape"@en ;
    sh:property     bds:PersonNameShape-personNameLabel ;
    sh:targetClass  bdo:PersonName .

bds:PersonNameShape-personNameLabel
    a               sh:PropertyShape ;
    sh:datatype     rdf:langString ;
    sh:description  "this Person has a name given by the label."@en ;
    sh:maxCount     1 ;
    sh:minCount     1 ;
    sh:path         rdfs:label .

и графиком данных:

bdr:P707  a              bdo:Person ;
    bdo:hasFather        bdr:P705 ;
    bdo:hasParent        bdr:P705 ;
    bdo:isRoot           true ;
    bdo:kinWith          bdr:P705 ;
    bdo:note             bdr:NT08B650B715F414F1 ;
    bdo:personEvent      bdr:EVFD910DBE53BCE208 , bdr:EVD4758367CFC1276C ;
    bdo:personGender     bdr:GenderMale ;
    bdo:personName       bdr:NM0895CB6787E8AC6E , bdr:NM2463D933BA1F9A38 ,
                         bdr:NMEA2B380AF0BBFB1B , bdr:NMC2A097019ABA499F ;
    bdo:personStudentOf  bdr:P705 ;
    skos:prefLabel       "dri med 'od zer/"@bo-x-ewts ;
.

bdr:NMC2A097019ABA499F
    a           bdo:PersonPrimaryName ;
    rdfs:label  "dri med 'od zer/"@bo-x-ewts ;
.

bdr:NM0895CB6787E8AC6E
    a           bdo:PersonPrimaryTitle ;
    rdfs:label  "sprul sku dri med/"@bo-x-ewts ;
.

bdr:NM2463D933BA1F9A38
    a           bdo:PersonPrimaryTitle ;
    rdfs:label  "bdud 'joms gter sras dri med 'od zer/"@bo-x-ewts ;
.

bdr:NMEA2B380AF0BBFB1B
    a           bdo:PersonGterStonTitle ;
    rdfs:label  "pad+ma 'gro 'dul gsang sngags gling pa/"@bo-x-ewts ;
.

focusNodes и shape:

validating facets: 
    [http://purl.bdrc.io/resource/NM0895CB6787E8AC6E, 
     http://purl.bdrc.io/resource/NMEA2B380AF0BBFB1B, 
     http://purl.bdrc.io/resource/NMC2A097019ABA499F,
     http://purl.bdrc.io/resource/NM2463D933BA1F9A38] 
against shape: 
    http://purl.bdrc.io/ontology/shapes/core/PersonNameShape

Я ожидал получить отчет о проверке, показывающий нарушения PersonNameShape из-за отсутствия каких-либо утверждений в данных график, показывающий, что, например:

bdo:PersonPrimaryTitle rdfs:subClassOf bdo:PersonName .

, но я получаю пустой отчет:

[ a       sh:ValidationReport ] .

Если я изменю один из ресурсов PersonName для использования skos:prefLabel вместо rdfs:label, затем я получаю ожидаемый результат нарушения:

[ a          sh:ValidationReport ;
  sh:result  [ a                             sh:ValidationResult ;
               sh:focusNode                  bdr:NMC2A097019ABA499F ;
               sh:resultMessage              "Property needs to have at least 1 values, but found 0" ;
               sh:resultPath                 rdfs:label ;
               sh:resultSeverity             sh:Violation ;
               sh:sourceConstraintComponent  sh:MinCountConstraintComponent ;
               sh:sourceShape                bds:PersonNameShape-personNameLabel
             ]
] .

Я думал, что sh:targetClass bdo:PersonName в объявлении PersonNameShape было частью проверки, но, очевидно, Shacl spe c 2.1.3 :

Цели фигуры игнорируются всякий раз, когда узел фокуса предоставляется непосредственно в качестве входных данных для процесса проверки для этой фигуры.

указывает на то, почему Я не вижу ожидаемых (ожидаемых) нарушений. Поэтому мой вопрос заключается в том, как мне указать, что часть проверки должна проверять, что rdf:type каждого из focusNodes является (rdfs:subClassOf*) bdo:PersonName.

Я попытался добавить sh:property bds:PersonNameShape-personNameType ; до PersonNameShape с:

bds:PersonNameShape-personNameType
    a               sh:PropertyShape ;
    sh:class        bdo:PersonPrimaryTitle ;
    sh:description  "type class."@en ;
    sh:maxCount     1 ;
    sh:minCount     1 ;
    sh:path         rdf:type .

Я ожидал увидеть нарушения для bdr:NMC2A097019ABA499F и bdr:NMEA2B380AF0BBFB1B, но другие два должны подтвердить, я думал, так как они имеют rdf:type, bdo:PersonPrimaryTitle. Однако я вижу нарушения, которые не понимаю:

[ a          sh:ValidationReport ;
  sh:result  [ a                             sh:ValidationResult ;
               sh:focusNode                  bdr:NM2463D933BA1F9A38 ;
               sh:resultMessage              "Value must be an instance of bdo:PersonName" ;
               sh:resultPath                 rdf:type ;
               sh:resultSeverity             sh:Violation ;
               sh:sourceConstraintComponent  sh:ClassConstraintComponent ;
               sh:sourceShape                bds:PersonNameShape-personNameType ;
               sh:value                      bdo:PersonPrimaryTitle
             ] ;
  sh:result  [ a                             sh:ValidationResult ;
               sh:focusNode                  bdr:NMC2A097019ABA499F ;
               sh:resultMessage              "Value must be an instance of bdo:PersonName" ;
               sh:resultPath                 rdf:type ;
               sh:resultSeverity             sh:Violation ;
               sh:sourceConstraintComponent  sh:ClassConstraintComponent ;
               sh:sourceShape                bds:PersonNameShape-personNameType ;
               sh:value                      bdo:PersonPrimaryName
             ] ;
  sh:result  [ a                             sh:ValidationResult ;
               sh:focusNode                  bdr:NMEA2B380AF0BBFB1B ;
               sh:resultMessage              "Value must be an instance of bdo:PersonName" ;
               sh:resultPath                 rdf:type ;
               sh:resultSeverity             sh:Violation ;
               sh:sourceConstraintComponent  sh:ClassConstraintComponent ;
               sh:sourceShape                bds:PersonNameShape-personNameType ;
               sh:value                      bdo:PersonGterStonTitle
             ] ;
  sh:result  [ a                             sh:ValidationResult ;
               sh:focusNode                  bdr:NM0895CB6787E8AC6E ;
               sh:resultMessage              "Value must be an instance of bdo:PersonName" ;
               sh:resultPath                 rdf:type ;
               sh:resultSeverity             sh:Violation ;
               sh:sourceConstraintComponent  sh:ClassConstraintComponent ;
               sh:sourceShape                bds:PersonNameShape-personNameType ;
               sh:value                      bdo:PersonPrimaryTitle
             ]
] .

Я представляю, что это просто непонимание с моей стороны, но я этого не вижу.

Спасибо в заранее.

...