0

我想 RDFising 数据,我需要使用 SPARQL 查询(我正在使用 SPIN)构造一个具有两个属性(标题和作者)的对象(书)。所有书籍都有“标题”,但有时没有“作者”。

发生这种情况时,它不会创建这本“书”,我想用“标题”创建它。

我正在使用 GraphDB,这是查询:

prefix spif: <http://spinrdf.org/spif#>
prefix pres: <http://example.com/pruebardf/>

CONSTRUCT {
    ?rdfIRI a           pres:Book ;
            pres:Author ?author   .
}
WHERE {
     SERVICE <http://localhost:7200/rdf-bridge/1683716393221> {
         ?bookRow a                <urn:Row> ;
                  <urn:col:Author> ?author   ;
                  <urn:col:Title>  ?title    .
     }
     BIND(IRI(CONCAT("http://example.com/", spif:encodeURL(?title))) AS ?rdfIRI)
}

有解决办法吗?我可以使用其他 SPARQL 语法。

4

1 回答 1

0

OPTIONALSERVICE零件中使图案在<urn:col:Author>缺失时不会失效。

然后CONSTRUCT将根本不放在?rdfIRI pres:Author ?author三元组中,而是包括?rdfIRI a pres:Book.

如果您想在数据中缺少 ?author 时设置它,请查看 using COALESCE

于 2017-03-13T12:52:07.753 回答