问题描述
我正在根据 TopQuadrant 的 example 并使用 Zazuko SHACL Playground 进行一些测试。
我正在尝试针对期望属性为列表的形状验证数据,我的目标是检索无效属性的路径。
这是我使用的数据:
@prefix dash: <http://datashapes.org/dash#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-Syntax-ns#> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix ex: <http://www.example.com/rdf#> .
ex:MyTrafficLight
a ex:TrafficLight ;
ex:label 'myTrafficLight';
ex:id 'TL12345';
ex:colors [
rdf:first "red" ;
rdf:rest [
rdf:first "yellow" ;
rdf:rest [
rdf:first "green" ;
rdf:rest rdf:nil ;
]
]
] .
以及它测试的形状:
@prefix dash: <http://datashapes.org/dash#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-Syntax-ns#> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix ex: <http://www.example.com/rdf#> .
ex:TrafficLightShape
a sh:NodeShape ;
sh:targetClass ex:TrafficLight ;
sh:property [
sh:path ex:label;
sh:datatype xsd:string;
];
sh:property [
sh:path ex:id;
sh:datatype xsd:string;
];
sh:property [
sh:path ex:colors ;
sh:node dash:ListShape ;
sh:property [
sh:path ( [ sh:zeroOrMorePath rdf:rest ] rdf:first ) ;
sh:datatype xsd:string ;
]
] .
这工作正常,但是如果我将 ex:colors
成员的预期数据类型更改为 xsd:float
,生成的验证报告如下:
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-Syntax-ns#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
_:genid1
a <http://www.w3.org/ns/shacl#ValidationResult> ;
ns0:resultSeverity ns0:Violation ;
ns0:sourceConstraintComponent ns0:DatatypeConstraintComponent ;
ns0:sourceShape _:genid2 ;
ns0:focusNode _:genid3 ;
ns0:value "yellow" ;
ns0:resultPath (
_:genid5
rdf:first
) ;
ns0:resultMessage "Value does not have datatype <http://www.w3.org/2001/XMLSchema#float>" .
_:genid2
ns0:path (
_:genid5
rdf:first
) ;
ns0:datatype xsd:float .
_:genid5 ns0:zeroOrMorePath rdf:rest .
_:genid3
ns0:path <http://www.example.com/rdf#label> ;
ns0:datatype xsd:string .
_:genid7
a ns0:ValidationResult ;
ns0:resultSeverity ns0:Violation ;
ns0:sourceConstraintComponent ns0:DatatypeConstraintComponent ;
ns0:sourceShape _:genid2 ;
ns0:focusNode _:genid3 ;
ns0:value "green" ;
ns0:resultPath (
_:genid5
rdf:first
) ;
ns0:resultMessage "Value does not have datatype <http://www.w3.org/2001/XMLSchema#float>" .
_:genid8
a ns0:ValidationResult ;
ns0:resultSeverity ns0:Violation ;
ns0:sourceConstraintComponent ns0:DatatypeConstraintComponent ;
ns0:sourceShape _:genid2 ;
ns0:focusNode _:genid3 ;
ns0:value "red" ;
ns0:resultPath (
_:genid5
rdf:first
) ;
ns0:resultMessage "Value does not have datatype <http://www.w3.org/2001/XMLSchema#float>" .
[]
a ns0:ValidationReport ;
ns0:conforms false ;
ns0:result _:genid1,_:genid7,_:genid8 .
我的问题是没有关于在我的形状 (sh:path ex:colors
) 上失败的属性的路径是什么的信息,只有使用的“子属性”(sh:path ( [ sh:zeroOrMorePath rdf:rest ] rdf:first )
) 的路径描述列表。
有没有办法检索这些信息?是否应该对形状进行不同的定义?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)