0

我假设没有任何数据类型与作为数据类型隐含相同xsd:string,但是 SHACL 给了我一个验证错误。我的假设是错误的还是 SHACL 没有涵盖?在后一种情况下,我如何验证数据类型是空的还是 xsd: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
4

1 回答 1

2

在您的示例中,数据包含一个 rdf:langString 文字,它与 xsd:string 的数据类型不同 - 您会看到 @en 语言标记。您可能指的是以下内容等价的事实:“Hello World”和“Hello World”^^xsd:string。所以上面的 pyshacl 结果对我来说是正确的。

于 2022-01-12T00:05:39.403 回答