使用 SHACL 验证 RDF 时如何忽略导入图中的节点?

How to ignore nodes from imported graphs when validating RDF with SHACL?

这个形状

selfref:NodeShape
  rdf:type sh:NodeShape ;
  sh:property [
      rdf:type sh:PropertyShape ;
      sh:path sh:property ;
      sh:maxCount 0 ;
      sh:minCount 0 ;
      sh:nodeKind sh:BlankNode ;
    ] ;
  sh:targetSubjectsOf sh:property .

由符合 SHACL 规范的引擎正确处理,它确实验证了自己。问题是来自导入图表的所有节点,包括 SHACL 词汇表也被处理。如何排除通过 owl:imports 连接的所有内容?

据我所知,这取决于实现。 SHACL spec 表示:

Shapes graphs can be reusable validation modules that can be cross-referenced with the predicate owl:imports. As a pre-validation step, SHACL processors should extend the originally provided shapes graph by transitively following and importing all referenced shapes graphs through the owl:imports predicate. The resulting graph forms the input shapes graph for validation and must not be further modified during the validation process.

因此,兼容 SHACL 的处理器应该扩展原始形状图,但他们不需要这样做。