Archive for November, 2008

Friday, November 28th, 2008

Fun with xdmp:value()

Lately I’ve been playing with some more advanced XQuery. One thing nearly every XQuery engine supports is some kind of eval() function. MarkLogic has several, but my favorite is xdmp:eval. It’s lightweight because it reuses the entire calling context, so for instance you can write let $v := 5 return xdmp:value("$v"). Not too useful, but if the expression passed in comes from a variable, it gets interesting.

Now, quite a few standards based on XPath depend on the context node being set to some particular node. This turns out to be easy too, using the path operator: $context/xdmp:value($expr). According to the definition of the XPath path operator, the expression to the right is evaluated with the results of the expression on the left setting the context node.

OK, how about setting the context size and position? More difficult, but one could use a sequence on the left-hand side of the path operator, with the desired $context node in somewhere in the middle. Then last() will return the length of the sequence, and position() will return, well, the position of $context in the sequence. But it’s kind of hacky to manufacture a bunch of temporary nodes, only to throw them away in the next step of the path.

I’m curious if anyone else has done something similar. Comments? -m

Tuesday, November 25th, 2008

MarkLogic 4.0 review

Kurt Cagle has a thorough review of MarkLogic 4.0, worth a read itself. But check out the comments: one poster says he interviewed with the company and didn’t get reimbursed. The MarkLogic CEO responds personally with an offer to make it right. Why can’t more companies be like this? -m

Friday, November 21st, 2008

Geek Thoughts: today’s yahoo turnaround plan

So, Yahoo! is looking for a new CEO.

Bill Gates just retired.


More collected Geek Thoughts at

Wednesday, November 19th, 2008

Geek Thoughts: writing contest

To celebrate the unlamented demise of Valleywag, use as many of the ten insulting words you should know (along with any other appropriate words) as you can in a single short paragraph. Post in the comments below. This site is for geeks of all ages, so keep things PG. All right, PG-13. My favorite will be announced later.

More collected Geek Thoughts at

Tuesday, November 11th, 2008

No NaNoWriMo for me this year

I’ve successfully completed the National Novel Writing Month challenge–to write 50,000 words during the month of November–for three years running, and now I have three draft novels sitting around. At some point, racking up mere drafts gets to be pathetic, so this November I’m picking one to dig into with a heavy editing pass. I’m stocked up on red pens and ready to go, and maybe a third of the way through at this moment. Other writing efforts, like say this blog, get back-burnered for a few weeks.

The key to editing long works, by the way, is momentum. If you get stuck in one place, you quickly get burned out on it, like melting celluloid in an old-skool movie projector. Onward. -m

Sunday, November 9th, 2008

Bronze Medal at California State Homebrew Competition

I won a bronze medal (white ribbon actually) in the Mixed Styles category for my Dusseldorf Altbier, the first non-mead-related beverage I’ve ever entered. It’s a deep copper-colored ale made with a special Alt yeast and with a strong balance of clean malt and hops. There are very few bottles of it left at this point.

The competition itself was a blast–I got to spend the day judging barleywines, including a spectacular one that went on to win the category. Official results should be posted soon. -m

Friday, November 7th, 2008

Sign of the times

I got a call today from a pushy recruiter. That’s nothing new. What’s different is that she was not looking for the usual resume, but rather desperately trying to place candidates. (Or maybe it was just social engineering…)

Is anyone else seeing a reversal in recruiter cold-call strategies? How flooded is the tech job market at this point? -m

Thursday, November 6th, 2008

Geek Thoughts: “I screwed up”

A special comment. My most vivid memory of my late Grandpa.

Even after retiring, Grandpa needed to do small jobs around town to make ends meet. One was cleaning a small sporting goods store. Once, with all the excitement of visiting family from out of town (that would be us), he forgot to clean one night. The next day, the shopkeeper was understandably irate, and waited around to speak face-to-face. “I screwed up,” Grandpa simply said. A short exchange followed, with typical Midwestern bluntness and politeness, the resolution being that it would never happen again. The shop got exceptionally well cleaned that day. Crisis averted.

That’s been a powerful lesson for me. When you screw something up, admit it, fix it the best you can, and move on.


P.S. No, I haven’t done any major screw-ups lately, at least any that I know about. I was reminded of this by a much-publicized interview on Letterman.

Tuesday, November 4th, 2008

XiX: Details about XForms in XQuery

I was asked offline for more details about what I have in mind around XiX.

Take a simple piece of XML, like this: <root><a>3</a><b>4</b><total/></root>.

An XForms Model can be applied, in an out-of-line fashion, to that instance. This is done through a bind element, with XPath to identify the nodes in question, plus other “model item properties” to annotate the instance. The calculate property is a good one: <bind nodeset="total" calculate="../a + ../b"/>. When called upon to refresh the instance, as you would expect, the result contains the node <total>7</total>.

Like lots of algorithms, though, XForms is defined in a thoroughly procedural manner. Functional programming has a stricture against assignment operators, like setting the value “7” into the calculated node above. So the challenge is coming up with an implementation that works within these bounds. For example, perhaps a function that takes an original instance as input, and returns a newly-created updated instance. Simple enough for the example here, but in more complex cases with different and interacting model item properties, regenerating the entire instance frequently has performance penalties.

So, I’m trying to find the right expression of the XForms Model in a functional guise. (As with RDFa). I’m curious about what anyone else has come up with in this area. -m