This nice bit of XQuery comes from my colleague Kelly Stirman:
The idea is that when you start a photo shoot you put into the camera the location, subject and even the rights associated with the photos.
Then each image is embedded with this information and, as it is passed around, systems can make use of the information without anyone having to enter the meta-data again.
It’s really cool and a huge time and headache saver for people who handle photos.
And it’s even cooler that, using XQuery and the standard MarkLogic extensions, you can load the image into MarkLogic and Query the XMP directly:
Step 1: Load an image with XMP.
How about this picture a boat
I took in
Using the MarkLogic update extenstions to XQuery, you can just go ahead and pull it from my blog and upload it into the MarkLogic Server you have set up in the Tutorial:
declare namespace tiff="http://ns.adobe.com/tiff/1.0/"
declare namespace rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
declare namespace x="adobe:ns:meta/"
(: get the image :)
let $doc := doc("/xmp/maine-boat.jpg")
(: make a string out of the image using the MarkLogic Server extension xdmp:quote :)
let $node := xdmp:quote($doc/node())
(: isolate the <x:xmpmeta> node in the string using substring-before and substring-after :)
let $xmp := substring-after($node,"<x:xmpmeta")
let $xmp := substring-before($xmp,"</x:xmpmeta>")
(: put back the stuff we took out with out after and before :)
Very nice! We are
storing the original binary (you can display it as an image any time) and are
easily able to unlock the content contained within it.
Welcome to the new world of self-describing content!