SHACL:要求SH:财产成为URI
我想知道是否有一种方法可以指定给定的sh:属性
有望在没有任何特定类的情况下具有URI的值。
在下面的示例SHACL中,属性meta:value
只允许URI,尽管我不知道在SHACL中表示它的方法。
示例SHACL
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix meta: <metadata#> .
@prefix meta_sh: <metadata/shacl#> .
meta_sh:Entry
a sh:NodeShape;
sh:targetClass meta:Entry;
sh:property [
sh:path meta:value;
# Value expected to be a URI
sh:minCount 1; # Required; 1 or more
];
sh:property [
sh:path meta:time;
sh:datatype xsd:dateTime;
sh:minCount 1; sh:maxCount 1; # Required; 1
];
.
示例数据
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix meta: <metadata#> .
@prefix data: <data#> .
data:Entry_001
a meta:Entry;
meta:value data:ProductListing_459; # URI
meta:value data:RentalListing_934; # URI
meta:time "2022-06-15T06:20:31Z"^^xsd:dateTime;
.
I was wondering if there's a way to specify that a given sh:property
is expected to have a value of a URI without any particular class.
In the example SHACL below, the property meta:value
would only allow URIs, although I don't know of a way to represent it in SHACL.
Example SHACL
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix meta: <metadata#> .
@prefix meta_sh: <metadata/shacl#> .
meta_sh:Entry
a sh:NodeShape;
sh:targetClass meta:Entry;
sh:property [
sh:path meta:value;
# Value expected to be a URI
sh:minCount 1; # Required; 1 or more
];
sh:property [
sh:path meta:time;
sh:datatype xsd:dateTime;
sh:minCount 1; sh:maxCount 1; # Required; 1
];
.
Example Data
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix meta: <metadata#> .
@prefix data: <data#> .
data:Entry_001
a meta:Entry;
meta:value data:ProductListing_459; # URI
meta:value data:RentalListing_934; # URI
meta:time "2022-06-15T06:20:31Z"^^xsd:dateTime;
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这应该有效:
this should work:
是的,您是对的,
sh:nodekind
必须成为属性形状的一部分。它仍然无法使用的原因:定义前缀的方式。它们不是完整的URIS,因此SHACL处理器添加了一些零件(也许是文件的磁盘位置取决于)。结果:形状中的
meta
在数据中与meta
不匹配。这起作用:
SHACL
数据
Yes, you are right, the
sh:nodeKind
has to be part of the property shape.The reason why it still not worked: the way you defined the prefixes. They were no full URIs so the SHACL processor added some parts (maybe the disk location of the file, depends). The result: the
meta
in the shapes never matched themeta
in the data.This works:
SHACL
Data