我有这个数据文件:
@prefix ex: <http://example.com/ns#> .
ex:John
a ex:Person ;
a ex:parent ;
a ex:male .
这个形状文件:
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix ex: <http://example.com/ns#> .
ex:RuleOrderExampleShape
a sh:NodeShape ;
sh:targetClass ex:Person ;
sh:rule [
a sh:SPARQLRule;
rdfs:label "Construct a father if someone is a parent and a male";
sh:prefixes ex: ;
sh:construct """
CONSTRUCT {
$this a ex:uncle .
}
WHERE {
$this a ex:parent .
$this a ex:male .
}
"""
] .
我的代码目前是:
Model dataModel = ModelFactory.createDefaultModel();
dataModel.read(data);
Model shapeModel = ModelFactory.createDefaultModel();
shapeModel.read(shape);
Resource reportResource = ValidationUtil.validateModel(dataModel, shapeModel, true);
如何获得包含新三元组的模型(例如:John a ex:father)?