SparQL and subquerying

So more into XMP data issues and handling this properly. Parsing the formatted data from ExifTool I realize isn’t going to be a reliable method for this system. So this meant having to export the full tag in binary from Exiftool utilizing something like: exiftool -xmp -b sample.jpg > sample.metadata sample image comes from Douglas Hackney (thanks!)

import string, os
from rdflib import ConjunctiveGraph as Graph, Namespace

DC = Namespace(”http://purl.org/dc/elements/1.1/”)
RDF = Namespace(”http://www.w3.org/1999/02/22-rdf-syntax-ns#”)
EXIF = Namespace(”http://ns.adobe.com/exif/1.0/”)

ns = dict(dc=DC, rdf=RDF, exif=EXIF)
g = Graph()
g.parse(”sample.metadata”, format=”xml”)

for x in g.query(’SELECT ?bExifVersion WHERE {?x exif:ExifVersion ?bExifVersion }’,
initNs=ns):
print “Exif Version is: %s” % x

The problem line is the SparQL query which works for ExifVersion because it exists in the primary rdf:Description node and is listed properly in the metadata like exif:ExifVersion but because the Dublin Core Metadata has its own nodes I get blank nodes if I do something like SELECT ?acreator WHERE {?x dc:creator ?acreator }. After validating the metdata via W3.org and getting validation that the rdf is fine I am not sure how to handle this. Is it possible to do sub-queries with SparQL or how does one handle the extra node stuff. Can someone from the w3 comment?

Nevermind: I’m doing it wrong :-) Will update this entry when i’m complete.

Leave a Reply

You must be logged in to post a comment.