在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 规范 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
]
] .
我想这只是我缺乏理解,但我没有看到。
提前致谢。