首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在SHACL中验证没有数据类型定义的文字值?

如何在SHACL中验证没有数据类型定义的文字值?
EN

Stack Overflow用户
提问于 2022-01-11 14:20:37
回答 1查看 135关注 0票数 0

我假设没有任何数据类型与使用xsd:string作为数据类型是隐式相同的,但是SHACL给出了一个验证错误。我的假设是错误的,还是没有包括在SHACL中?在后一种情况下,如何验证数据类型是否为空或xsd:string?

string.ttl

代码语言:javascript
复制
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.

<message> <title> "Hello World"@en.

shacl.ttl

代码语言:javascript
复制
@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.

错误

代码语言:javascript
复制
$ 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
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-01-12 00:05:39

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

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70668384

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档