Three Strikes
I removed my Netflix queue display sidebar item temporarily. Netflix has apparently altered the format of its feeds. Though the parser/translator continued to work, the footprint of the output is bigger than I would like. (Not to mention all the images, geez.)
It'll come back after I've revisited the formatting. This might be the time to look into an XSL tranformation for RSS feeds, to coerce them into the sidebar format, then style them with CSS. Right now, it's all done with hardcoded, feed-specific python code.
This follows the software design rule of threes. I wrote it once for Netflix, then again for last.fm. Now, I have to do it again for Netflix. It's probably time to produce a general feed-to-xhtml solution.
Comments: 0
Stupid XSL Trick
As Chris observed, and I pointed out in previous entries, I've been immersing myself in LISP lately. I speculated out loud that the structure of an XML document is equivalent to an s-expression. Chris responded by creating a LISP program that converts an s-expression into an HTML document.
I wondered if it would be possible to produce an XSL transformation that could convert XML into an s-expression; to use Chris's example, a transformation that converts this:
<html>
<head>
<title>Hello world</title>
</head>
<body>
<blink>
<span style="color:red">Testing.</span>
Still blinking.
</blink>
</body>
</html>
Into this:
'(html
(head
(title "Hello world"))
(body
(blink
(span (attributes (style "color:red")) "Testing.") "
Still blinking.
")))
What I came up with is an XSL transformation that can transform an arbitrary XML document into an s-expression. (It transformed the HTML above.) It still has a few problems: it can transform qualified names, but the colon-separated identifies cause problems for LISP, as it looks for a matching package. Also, deliberately empty text nodes are problematic. Otherwise, though, it works pretty well.
The transformation: sexp.xsl
The command line: $ xsltproc sexp.xsl sexp.xsl
The result: sexp.lsp
Comments: 0