SPARQL Construct. How to assign the value of an RD

2019-07-27 10:23发布

My query (excerpt) is roughly this.

CONSTRUCT {
?publication fb:type ?type;
fb:publicationType ?publicationType;
}
WHERE 
{
?publication a bibo:Document .
?publication vitro:mostSpecificType ?publicationType .
}

And it returns output similar to...

<rdf:Description rdf:about="https://abcd.fgh/individual/publication12345">
    <fb:publication>Example pub title</fb:publication>
    <fb:publicationType rdf:resource="http://purl.org/ontology/bibo/AcademicArticle"/>
</rdf:Description>

Perhaps a beginner-esque question, but how do I tweak the query such that the output is:

<rdf:Description rdf:about="https://abcd.fgh/individual/publication12345">
    <fb:publication>Example pub title</fb:publication>
    <fb:publicationType>Academic Article</fb:publicationType>
</rdf:Description>

Thanks

1条回答
对你真心纯属浪费
2楼-- · 2019-07-27 11:10

On the assumption that the bibo ontology is in the store you're querying, you can use its rdfs:label property in a property path:

CONSTRUCT {
  ?publication fb:type ?type;
    fb:publicationType ?publicationType;
} WHERE {
  ?publication a bibo:Document ;
    vitro:mostSpecificType/rdfs:label ?publicationType .
  FILTER (LANG(?publicationType) = "en")
}

The ?a vitro:mostSpecificType/rdfs:label ?b is shorthand for ?a vitro:mostSpecificType ?something. ?something rdfs:label ?b, without binding the intermediate term.

查看更多
登录 后发表回答