Readable regexs

May 2, 2007

Excellent post on XSL-List by Abel Braaksma on creating readable regex expressions in XSLT 2.0. He suggests always defining regular expressions in the content of a <xsl:variable>, using normal XML comments to annotate the different parts of the regex, and then using the x flag to ignore the extraneous whitespace that you’ve introduced.

Matching templates, named templates or for-each? My rules of thumb

May 1, 2007

More rules of thumb: these are about when to use matching templates, when to use named templates, and when to use for-each. These have as much bearing in XSLT 1.0 as they do in XSLT 2.0.

Functions or templates? My rules of thumb

Apr 29, 2007

In XSLT 2.0, functions and templates have very similar behaviour: both can accept arguments/parameters and return sequences of any kind. The difference is in how they’re called: functions can be called concisely from within expressions and patterns, and arguments are passed by position; whereas templates have to be called using <xsl:call-template>, and parameters are passed by name. Also, there’s no context node for functions, but there is one for templates. I’ve built up some rules of thumb about which to use when:

The future of computer interfaces

Apr 28, 2007

My dad (Hello Barry!) has much more time to surf than I do, and often sends me interesting links. One that he sent recently was a video presentation of a multi-touch interface that’s really worth checking out. I thought I’d just write down a few of my thoughts on that and one of the talks at DocEng 2006 on interactive paper, since they’re both about how we might interact with computers in more intuitive ways in the future.

MSXML serialisation of empty elements

Apr 25, 2007

The problem: You’re using MSXML (and therefore XSLT 1.0). You’re outputting XHTML (and therefore using the xml method). You want to output an empty <a> element for an anchor, but want to make sure that you get a start tag and and end tag (<a id="foo"></a>) rather than an empty element tag (<a id="foo"/>).

Is the only solution disable-output-escaping?