Thursday, May 18, 2006

Java 1.5 update broke my xalan

Slightly against my better judgement, I allowed the mac to update Java from 1.4 to 1.5 the other day. Everything seemed OK at first. Then I tried using xalan for some XSL Transformations and they failed.

I'm a bit puzzled by this, as the copy of xalan I'm pointing to is from fop (0.20.4), which I have installed. I could understand that if I had been using the copy of xalan supplied with Java 1.4 and upgraded, its behaviour might have changed --- especially since xalan isn't supplied with Java 1.5. But it seems odd for the behaviour of xalan, sitting in a fixed jar file to change.

Anyway, what happened was that some XSLT code that I've used successfully with lots of different XSLT processors (xalan, xt, xsltproc etc.) suddenly barfed with the following error:


XSLT Error (javax.xml.transform.TransformerException):
Can not convert #RTREEFRAG to a NodeList!

After googling, it seems that the abandoned XSLT 1.1 and the new-ish XSLT 2.0 have both removed the XSLT 1.0 result tree fragments, which was the former type of parameters and variables.

In my case, the solution, rather oddly, was to convert this:


 <xsl:call-template name="showlink">
     <xsl:with-param name="link">
         <value-of select="."/>
     </xsl:with-param>
 </xsl:call-template>

to this:


 <xsl:call-template name="showlink">
     <xsl:with-param name="link" select="."/>
 </xsl:call-template>

Clearly, in this case, the working code is shorter, but I'm not looking forward to all the conversions. And I still don't understand why merely upgrading java has somehow changed fop's xalan to xslt-1.1 or xslt-2.0 or whatever.

Wednesday, May 17, 2006

Using Spotlight from the Command Line

There's an excellent article from here from Mohit Muthanna about how to use Spotlight from the mac command line.

At its simplest, you just use the mdfind command with what you want to search for as the argument. e.g.

mdfind purplecow

Not only is it a lot less typing than the find command, it's considerably faster.

And if you want to restrict it to a directory, you can use the -onlyin flag, so that

mdfind -onlyin ~ purplecow

is pretty much functionally equivalent to


find ~ -name "*purplecow*" -print

It seems as if the path for mdfind, needs to be absolute, however, so ~ and `pwd` are OK, but . isn't.

Getting a Hash Symbol on a UK Mac keyboard

ALT-3 is the key for #.

Adding readline to Python

Python without readline is painful.

But all you have to do to add it on the mac is:

python `python -c "import pimp; print pimp.__file__"` -i readline

And life is better . . .

Thanks to Bill Bumgarner in this post.

Broken FTP

Sometimes FTP (from the command line) doesn't work on the mac. It just hangs. This drove me mad for a while, for example when uploading to my ISP (PlusNet). It usually says something like

229 Entering Extended Passive Mode (|||4169|)

Then I found this post by Dave Taylor. It seems that all you have to type is epsv

ftp> epsv EPSV/EPRT on IPv4 off

Who knew?

Welcome to Mac Zero

This is a blog about Apple Macs. It is really just a place for me to collect together information I am not confident I will remember about that Mac. But perhaps it will be useful to others. That would be good.

It will be extremely sporadic...