我有一些工作代码用于获取层次结构中术语的所有祖先。下列的:
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX skos-xl: <http://www.w3.org/2008/05/skos-xl#>
PREFIX rdf: <http://www.w3.org/2000/01/rdf-schema#>
select ?grandparentliteralform (count(?parent) as ?distance)
{ ?iri skos:broader+ ?parent .
?parent skos:broader* ?grandparent .
?grandparent skos-xl:prefLabel ?grandparentlabel .
?grandparentlabel skos-xl:literalForm ?grandparentliteralform .
}
group by ?grandparent
order by DESC(?distance)
当 IRI 的更广泛的谓词是子属性 ( ?p rdf:subPropertyOf skos:broader
) 时,它会中断所以现在我这样做是为了捕获所有子属性谓词:
select ?grandparentliteralform (count(?parent) as ?distance)
{ ?iri ?p ?parent .
?parent skos:broader* ?grandparent .
?grandparent skos-xl:prefLabel ?grandparentlabel .
?grandparentlabel skos-xl:literalForm ?grandparentliteralform .
?p rdf:subPropertyOf skos:broader .
}
group by ?grandparent
order by DESC(?distance)
我真正想做的是:
select ?grandparentliteralform (count(?parent) as ?distance)
{ ?iri ?p+ ?parent .
?parent ?p* ?grandparent .
?grandparent skos-xl:prefLabel ?grandparentlabel .
?grandparentlabel skos-xl:literalForm ?grandparentliteralform .
?p rdf:subPropertyOf skos:broader .
}
group by ?grandparent
order by DESC(?distance)
但使用?p+
或?p*
抛出错误。
Unexpected token syntax error, unexpected <variable>, expecting <decimal literal> or <double literal> or <integer literal>
如何将*
/+
与变量一起使用?