XSLT and HTTP
Going from a MS Word user to coding my own software tools has often been a frustrating experience. Every so often, however, I have an “ah ha†moment in which the world opens up; where I solve a tricky problem in a way that has implications for solving other problems.
About a week ago I had one of those moments when trying to work out how to modify my citation formatting stylesheets to grab the necessary bibliographic data from outside the document. I first tackled the fairly simple problem of reading in flat files. So, I scan the document for citation references, and then use that to suck the MODS records into a temporary tree. In other words, I create an in-memory copy of the document in which only the necessary MODS records are inserted into the DocBook bibliography element.
This was a useful step forward. The “ah ha†moment, however, came when I asked Wolfgang Meier how I get this basic strategy working such that I access the MODS data not from flat files, but from the eXist XML DB. Answer: send an HTTP query to eXist.
Ah ha; it actually worked! In the first approach, I just sent a new request for each unique citation reference. This is sort of slow and doesn’t scale well. So, Wolfgang and I instead worked out a way to grab all of the records with a single query by sending a simple XQuery request. Once Wolfgang fixed a bug in eXist that was slowing things down, we got it working. And it’s fast!
The implications of this are, to my mind, huge. In the case of my stylesheets, they can be integrated into any environment that supports queries over HTTP to return MODS records (like SRU/CQL). There’s no need for additional code. More broadly, just imagine the sort of dynamic database driven transformation processing this approach can enable.
Creative Commons License