You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

pyShacl验证sh:hasValue规则报错但Apache Jena验证通过的问题求助

pyShacl验证sh:hasValue规则报错但Apache Jena验证通过的问题求助

我最近在做RDF数据的SHACL验证,碰到一个特别费解的问题——同样的三元组和验证规则,用Apache Jena能顺利通过,但用pyShacl却总是报hasValue约束违反,实在摸不着头脑,来请教下各位大佬!

待验证的RDF三元组

@prefix atold: <http://publications.europa.eu/resource/authority/> .

# 省略其他无关内容
:property dct:language <http://publications.europa.eu/resource/authority/language/DEU>

所用的SHACL验证规则

sh:LanguageProp
a sh:PropertyShape ;
sh:path         dct:language ;
sh:property [
    sh:hasValue <http://publications.europa.eu/resource/authority/language> ;
    sh:nodeKind sh:IRI ;
    sh:path skos:inScheme
] ;
sh:nodeKind     sh:IRI ;
sh:minCount     1 .

pyShacl返回的报错信息

Constraint Violation in HasValueConstraintComponent (http://www.w3.org/ns/shacl#HasValueConstraintComponent):
Severity: sh:Violation
Source Shape: [ sh:hasValue atold:language ; sh:nodeKind sh:IRI ; sh:path skos:inScheme ]
Focus Node: http://publications.europa.eu/resource/authority/language/DEU
Result Path: skos:inScheme
Message: Node http://publications.europa.eu/resource/authority/language/DEU->skos:inScheme does not contain a value in the set: ['http://publications.europa.eu/resource/authority/language']

确认数据正确性

我已经仔细检查过,<http://publications.europa.eu/resource/authority/language/DEU>的三元组里确实存在这条语句:

<skos:inScheme rdf:resource="http://publications.europa.eu/resource/authority/language"/>

而且所有需要依赖的本体都已经正确加载了,Jena验证完全没问题,只有pyShacl报错。有没有朋友遇到过类似的问题,或者能帮我排查下原因?

备注:内容来源于stack exchange,提问作者unicorn

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.21 12:04:33