我正在尝试编写一个用于 RDF 数据图验证的 SHACL 形状。我对使用哪个命名空间来声明形状名称有点困惑。我看到了 SHACL 文档。其中声明了以下命名空间。
rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns#
rdfs: http://www.w3.org/2000/01/rdf-schema#
sh: http://www.w3.org/ns/shacl#
xsd: http://www.w3.org/2001/XMLSchema#
ex: http://example.com/ns#
在编写形状时,他们使用“ex”作为命名空间来声明形状的名称,如下所示:
ex:PersonShape
a sh:NodeShape ;
sh:targetClass ex:Person ; # Applies to all persons
sh:property [ # _:b1
sh:path ex:ssn ; # constrains the values of ex:ssn
sh:maxCount 1 ;
sh:datatype xsd:string ;
sh:pattern "^\\d{3}-\\d{2}-\\d{4}$" ;
]
我不确定它是如何决定使用哪个命名空间来声明形状的名称的。有人可以指导我吗?
谢谢, 阿杰
正如 IS4 所提到的,命名空间并不 super 重要,但如果你想使用本体的命名空间 - 没有人会抱怨。通常将本体 和 形状组合在同一个文件中,这是这种做法更有意义的地方。