Client-Side XSLT

I’ve been playing with XSLT in the Browser. It appears simple enough: Just add an xml-stylesheet processing instruction to the top of your XML, pointing at your XSLT.

  <?xml-stylesheet href="stylish.xsl" type="text/xsl"?>

But there’s one more condition that needs to be met: Inside the stylesheet itself, you have to say <xsl:output type="html"/>. Not xml. Not leaving out the xsl:output tag. It has to be present and set to html or you don’t get any useful output.

My thanks to XSLT in Gecko : Generating HTML on the lovely devmo for pointing out the error of my ways to me.


Typo 4.0ish

I’ve upgraded this blog to typo 4.0.1(ish). The process was slightly less harrowing than previously as I decided to switch to using svk to manage mirroring the typo trunk. Previously, I had been using subversion vendor branches, but a couple of odd fluctuations in the typo source made that choke (files that turned into directories and vice versa). SVK appears to be more intelligent. Hurrah.

Anyway, typo 4 definitely appears to be shinier than the last release by a long way. It’s got tags (which I’ve had for a while), a revamped admin interface, better support for draft articles and lots more. It also appears that it’s less inclined to spout reams of garbage into the logs, which is nice.

As usual, please let me know if something is acting up. I’ll do my best to fix it.


Unicode for Rails — accepted

I had a little note today to say that my talk on “Unicode for Rails” has been accepted for RailsConf Europe 2006. Yay!

Now I have to write the thing. This is going to be interesting. I have only a few weeks to go, and most of those weekends are already taken…


Lexical Attributes

A week or two ago, I took an idea from Aristotle about “shortcut” functions and made it into a little module: Attribute-Shortcut. Aristotle pointed out in the comments that the attributes should also work on coderefs as well as named subs. i.e.

  sub basename :Shortcut { s!.*/!! for @_ };
  my $basename = sub :Shortcut { s!.*/!! for @_ };

However, I can’t seem to find a way to make this work. Attribute::Handlers passes you the string “ANON” instead of a glob reference.

Looking deeper at the documentation for attributes, it seems to imply that attributes on lexical variables aren’t really very well supported anyway.

I think I may have to conclude that this isn’t going to work for now…


Log Rotation

I hate log rotation. It’s a pain to configure on my FreeBSD server. Just look at newsyslog.conf. That, and my experiences of the utter non-portability of log rotation programs between different Unixes have led me to believe that programs should probably handle their own log rotation. It just makes life easier having one less thing to integrate with the Operating System.

So, I’ve switched my Apache over to using cronolog in order to get date based logfiles automatically. I’ve used it on a project at work recently and it really works a treat.

I also noticed that PostgreSQL has grown the ability to take care of its own log files in recent versions. So I’ve switched that to doing date based logging with automatic rotation as well. Lovely.

All is not perfect of course. Oh no, that would be far too simple. There’s still the issue of removing old logfiles and/or compressing them. But that seems to be a smaller integration problem.

Of course the trigger for all this activity was finding a 220Mb access_log lying around. Doh!


Java Verbosity

I’ve been doing quite a bit of Java over the last fortnight. It’s much easier with eclipse of course, but it’s still pretty verbose. But I dunno, maybe it’s just me, a whingy old Perl coder. But then again, look what I’ve just found in the Java Cookbook:

  public class Ls {
    public static void main(String argh_my_aching_fingers[]) {
      // ...

Glad to know I’m not the only one. :-)


Conflicting views on microformats

It seems like not everybody thinks the same about microformats. This is a view of my feed reader this morning:


Conflicting opinions through

Interesting juxtaposition, I thought. I still haven’t made my mind up on the matter. Mostly because I haven’t had a need for any of the things that microformats offer so far.

The two articles themselves:


ruby postgres gem issues

I’m trying to install PostgreSQL support into Rails. This should be fairly simple. Unfortunately, there are a couple of “oopsies” along the way.

First up, there are several gems to pick along the way:

  • postgres
  • postgres-pr
  • ruby-postgres

If you’ve a compiler installed, you want ruby-postgres. It’s a fork of the postgres gem, which knows how to find the postgres libraries and headers through pg_config. The postgres-pr gem is a pure-ruby version.

Being foolish, I tried to install the postgres gem:

  % gem install ruby-postgres-

Sadly, this is what happens:

  Building native extensions.  This could take a while...
  ruby extconf.rb install -l ruby-postgres-
  make install
  make: Nothing to be done for `install'.

Weird1. So I tried putting make into debug mode (set MAKEFLAGS=-d in the environment).

    Finished prerequisites of target file `/opt/domtest/lib/ruby/gems/1.8/gems/ruby-postgres-'.
    Prerequisite `' is older than target `/opt/domtest/lib/ruby/gems/1.8/gems/ruby-postgres-'.
   No need to remake target `/opt/domtest/lib/ruby/gems/1.8/gems/ruby-postgres-'.
  Finished prerequisites of target file `install-so'.

Basically, the freshly-compiled is older than the installed version. Which isn’t installed, BTW. I checked. How can this be?

After much messing around, I discovered that the reason is that ruby gems compiles in place. So when it comes to install time, it ends up comparing the compiled file to itself. Naturally, nothing happens.

But then, ruby gems runs make clean, causing it to be removed. Grrr! How on earth has this ever worked for anybody?

Anyway, at this point, I’m going to give up and use the postgres-pr gem instead.

[1] I’m not the first to see this—see ruby postgres problems.


d.Construct 2006

Registration for d.Construct 2006 is now open. Get your tickets whilst there are still some left, by the looks of things. It promises to be a grand day. I’m particularly looking forward to the talks on Web Services and APIs in the morning.

I’m also intrigued by Aral Balkan’s talk on flash. I remember him talking about it at last years d.Construct and being very impressed by the kind of things that are happening in the flash space. It’s really good to try and understand things that are going on outside your immediate sphere.

This is why, even though I’m normally far more concerned with backend software, I’m still curious to hear about topics like accessibility. It might not be what I do directly, but it’s still going to be a part of the product I help to create. Having an holistic appreciation of the product can only help.

It’s a real treat to have an event like this in Brighton. I can’t thank the guys at Clearleft enough for putting this together. Presumably thanks can be purchased in beer, post-event. ;-)


JUnit 4, the downfall

Sadly, after my excitement about Junit 4, I’ve found the downfall: it doesn’t work with ant yet.

However, there does appear to be a workaround. Add this to each class:

  public static junit.framework.Test suite() {
    return new junit.framework.JUnit4TestAdapter(SimpleTest.class);

However, that’s now causing my tests to fail with NullPointerExceptions inside HttpUnit. Yet they work fine in Eclipse. Wonder what I’m doing wrong?

Update: It’s entirely my own fault—my ant task was forgetting to copy over non-java artifacts into the classpath. So adding suite() makes things work just fine.