The easiest and best way to move metadata around between systems is with XML. Media partners exchange XML packages to describe content, photographers user XML to package images and just about everybody interacts with XML metadata when you look for something on the web.
But, to a large degree, the tools behind these processes are traditional applications with a relational database heart.
This has lead to a lot of systems that ingest XML, turn it into objects, manipulate it to make data and store it.
Then, to produce XML, they take it out of the database, put it into objects, manipulate the objects to get the parts they want, turn the objects into XML and then transform that XML into the required XML schema for delivery.
Along the way there is a bunch of true business logic (what app servers were built for) like security, session, etc - but its all mixed in with this object processing to create content.
This can look something like this:
How can XQuery help?
Well first of all, XQuery operates directly against XML in its native format. And if you are using a server like MarkLogic Server, you can store, manage and maintain that XML just like a database . . . except that you don't need to do anything to the XML. Its real native storage.
Furthermore you can work against multiple schemas at once. So you can ingest several types of XML (say from partners) and then use XQuery to access all of them and transform the resulting, new, XML into a the output format.
So now we have a system where we can ingest XML as-is and retieve, manipulate and transform it all in XQuery to deliver our XML.
This looks something like this:
I've had the chance to work with metadata in both formats and the simple fact of fewer moving parts has a HUGE effect on productivity. If any one of the app server layers goes wrong you are in a tailspin.
Meanwhile, using XQuery, to package up some content (like the plays from the tutorial) you get to create and maintain code that looks like:
<package>
{
for $play in /PLAY
return
<item>
<title>{$play/TITLE}</title>
<speeches>{count($play//SPEECH)}</speeches>
<actors>{count($play//PERSONA)}</actors>
<blood>{if (cts:contains($play//SPEECH,"blood")) then "yes" else "no"}</blood>
</item>
}
</package>
And that is ALL you have to do!
Metadata + XML are already a match - meet their new partner, XQuery.
P.S. I cheated a bit and used a MarkLogic search built-in. You could start to do the same thing with native XQuery like this: <blood>{if (contains(fn:string-join($play//SPEECH/text(), ""),"blood")) then "yes" else "no"}</blood>. But you'd have to enhance this a LOT to take into account the various string matching possibilities (punctuation, spacing, tags . . . oye!) and its just easier to use MarkLogic Server :)