For a single item, this is a fairly simple query using the SPARQL 1.1 subqueries. The trick is to order the changes that have this property by their date and accept the value from the latest version. The values form is used only to indicate the elements that you select. If you need to request additional elements, you can add them to the values block.
prefix mymeta: <http://www.mymeta.com/meta/> prefix dc: <http://purl.org/dc/elements/1.1/> select ?item ?title ?format ?extent where { values ?item { <urn:ITEMID:12345> }
$ sparql --data data.n3 --query query.rq ---------------------------------------------------------------------------------- | item | title | format | extent | ================================================================================== | <urn:ITEMID:12345> | "Improved Product Name"@en | "4 x 6 x 1 in"@en | "200"@en | ----------------------------------------------------------------------------------
If you really need to do this for all elements, you can use a different subquery to select the elements. That is, instead of values ?item { ... } use:
{ select ?item { ?item a mymeta:item } }
Although it was not mentioned in the original question, it appears in the comments , if you are interested in getting the latest property values ββfor all properties, you can subquery like the following, which is based on How to limit the size of a SPARQL solution group?
select ?item ?property ?value { values ?item { <urn:ITEMID:12345> } ?item mymeta:itemchange [ ?property ?value ; dc:issued ?date ]
--------------------------------------------------------------- | item | property | value | =============================================================== | <urn:ITEMID:12345> | dc:issued | "2007-06-01"@en | | <urn:ITEMID:12345> | dc:title | "Improved Product Name"@en | | <urn:ITEMID:12345> | dc:extent | "200"@en | | <urn:ITEMID:12345> | dc:format | "4 x 6 x 1 in"@en | ---------------------------------------------------------------
source share