我假设没有任何数据类型与使用xsd:string作为数据类型是隐式相同的,但是SHACL给出了一个验证错误。我的假设是错误的,还是没有包括在SHACL中?在后一种情况下,如何验证数据类型是否为空或xsd:string?
string.ttl
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.
<message> <title> "Hello World"@en.shacl.ttl
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.
@prefix sh:<http://www.w3.org/ns/shacl#> .
:TitleShape rdf:type sh:NodeShape;
sh:targetObjectsOf <title>;
sh:datatype xsd:string;
sh:closed true.错误
$ pyshacl string.ttl -s shacl.ttl
Validation Report
Conforms: False
Results (1):
Constraint Violation in DatatypeConstraintComponent (http://www.w3.org/ns/shacl#DatatypeConstraintComponent):
Severity: sh:Violation
Source Shape: :TitleShape
Focus Node: Literal("Hello World", lang=en)
Value Node: Literal("Hello World", lang=en)
Message: Value is not Literal with datatype xsd:string发布于 2022-01-12 00:05:39
在您的示例中,数据包含一个rdf:langString文字,它与xsd:string的数据类型不同--您可以看到@en语言标记。您可能会引用以下内容是等效的:"Hello“和"Hello”^xsd:string。所以在我看来,上面的pyshacl结果是正确的。
https://stackoverflow.com/questions/70668384
复制相似问题