At the Mark Logic sales kickoff a couple of weeks ago I set up a late night demo jam so people could show off what they are doing with XQuery (and MarkLogic Server).
From dynamic time lines and mapping overlays for search and discovery applications to new content presentations (not saying anything ... but I'd keep an eye on the ever innovative markmail) to the XQuery powered Facebook app called Kick-it everyone had something super cool to show. The crowd kept its part of the bargain with appropriate level of rowdiness and cheering.
As the person with the bright idea to do this, I had to come up set the presentation order. I'd done this once before and simply picked names out of a hat. But this time I thought that, since this is all about what XQuery can do, we should pick the order with XQuery.
So while everyone was getting demos ready and the crowd was setting in, I hooked up the projector and tapped out this bit of XQuery in a CQ window. It uses the MarkLogic Server built-in xdmp:random() in a very neat trick that my colleague James Clippinger came up with as I was attempting far less elegant ways of getting it done. (His suggestion rising above the other 'input' I was getting from the crowd.)
<demo-order>{
(: create presenter list - this is just a subset :)
let $presenters := ("Paul", "Pete", "David", "Danny", "Jay")(: sort the list using random. Each item in the FLOWR expression gets
assigned a sort key and when random() is used in the order by, it assigns a
random number to each item and creates a random sorting of the sequence :)let $sorted-presenters :=
for $presenter in
order by xdmp:random()
return
$presenter(: we then take that new order and go through it really just to get the
number. Using 'at' gets the order of the original sequence *before* the order
by clause so we have to create sorted sequence first then display that :)for $presenter at $pos in $sorted-presenters
return(: output the final list with the order number :)
<presenter>
<order>{$pos}</order>
<name>{$presenter}</name>
</presenter>}</demo-order>
To kick off the event I ran this code and picked the unlucky (or maybe lucky?) presenter to go first.
It was tons of fun to see a bunch of long time XQuery folks get truly excited about what it can do. And by excitied, I mean really excitied: we had everyone vote on the demos with crowd noise (measured with a dB meter of course). The winner's cheers were measured at 107dB!!
That puts really good XQuery demo in between a Snowmobile and a Power Saw on this chart of decibel levels.
Not bad for a programming language!
Comments