问题
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:
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.
来源:https://stackoverflow.com/questions/50510748/sparql-construct-how-to-assign-the-value-of-an-rdf-attribute-to-an-actual-rdf-v