Andrew Channels Dexter Pinion

Wherein I write some stuff that you may like to read. Or not, its up to you really.

May 27, 2004

XML Transforms

I'm running Debian, I'm playing with XML and I would really, really like to convert my nice valid document into a popular document format. The format of choice would be RTF. Any suggestions? Java solutions are out, mainly for political reasons, sorry folks.

Posted by Andy Todd at 09:41 PM | Comments (0)

May 24, 2004

Editing XML in VIM

Whilst I'm sharing the XML love, here is a nice VIM plugin to help edit XML, HTML, and SGML documents. If you want to get fully into the XML groove I've found this howto very useful.

Posted by Andy Todd at 05:51 PM | Comments (0)

Validating an XML document against its DTD

Well, after the disappointment of the dead tree documentation I still wanted to validate my XML document against its DTD.

Luckily, there is a Python Cookbook recipe that shows us how to achieve it with xmlproc.

<Update> If you don't want to perform your validation in Python (although I can't think why myself) check out the XMLStarlet command line XML tookit </Update>

<Update (2)> Of course, the truly hardcore will use xmllint. It's part of libxml2 and is therefore officially Mark Pilgrim friendly. </Update (2)>

Posted by Andy Todd at 02:18 PM | Comments (3)

May 21, 2004

Python and XML

I have to admit that I really don't like this book, published by O'Reilly and authored by Christopher A Jones and Fred L Drake Jr. There are a few reasons, the prose is pedestrian, the examples not very useful and the structure somewhat confusing.

Taking my last point first, the book gives an explanation of both Python and XML (good), outlines (far too briefly) the available toolkits. Then it explains that there are two different approaches to manipulating XML documents and attempts to explain each (primarily SAX and DOM). In quite a few cases the book reads like a precis of the official (or definitive) specification without enough detail to be worth reading. At these points there is generally a pointer to an (unreadable in my opinion) W3C specification.

A weakness of the book is that it doesn't at any point suggest what each approach's strengths and weaknesses are. Nor, really, do they attempt to address what XML is best used for, or what Python adds to the mix.

There are a number of implicit assumptions, I think, in the book. The first and most significant is that you approach it with a specific task or problem domain in mind. If you are searching for answers to "why" type questions (why should I use SAX? for instance) you will be sadly dissapointed. The how questions are addressed though.

The single thing that would improve this book though is some decent examples. My preference is for meaningful, incremental examples throughout technical books like this. They are hard to do though. But how hard would it be, for instance, to mention that XML is often used for configuration (e.g. in wxPython) and suggesting a few different ways of building and parsing these type of files?

Finally, and I'm sorry that this is so negative, the book is just plain wrong in a number of places. Today I wanted to find a way of validating an XML file against it's DTD. I looked it up in the book and the subject is mentioned in the index. Turning to page 151 I see a section on validating DTDs. There is no explanation of the principle though, just a suggestion that you use a utility script which is part of the xmlproc parser that ships with the PyXML utilities. Except it doesn't. There is no shipped with version 0.8.3 (the current release) and frankly I can't be bothered looking in previous releases. This is also the only mention of xmlproc in the book, which is strange because it it the first thing mentiond on the PyXML home page, but obviously not important enough to feature in the book at all.

My advice? If you want to learn about XML and the ways it can be written, read and manipulated go to and if you want to work with XML in Python you can't beat the effbot's ElementTree toolkit. Which naturally isn't mentioned in the book.

Posted by Andy Todd at 07:34 PM | Comments (5)

May 19, 2004

Getting Better Every Day

I've just discovered pydiction . Its a VIM plugin which provides auto-completion when editing Python scripts.


Posted by Andy Todd at 02:45 PM | Comments (0)

May 17, 2004

UK Hosting

My sister in law has roped me in to build a web site for her daughter's creche. Since they won't want to rely on me to maintain it for them I need to set up a simple, single page brochure site hosted in the UK (they have a .uk domain) which is easy to maintain. Did I mention that it will need to be easy to maintain because the people looking after it aren't technical at all? I did, good.

After I've developed the site for them I'm probably going to suggest they use CityDesk for maintenance. They will need somewhere to host the site though. Does anyone have any suggestions? The site will be small and the bandwidth minimal. The creche is a registered charity, so if we can find someone who does free hosting for non-profit organisations all the better.

Posted by Andy Todd at 03:18 PM | Comments (2)

May 10, 2004

Conference Attendance

Having singularly failed to attend PyCon 2004 and the UK Python conference, whilst the chances of attending EuroPython 2004 diminish by the day, I quite fancy a trip to NotCon 2004.

It has the advantage of being local, only a day, and within the realms of possibility for getting a baby sitter. I bet Simon will be there as well, it sounds right up his street.

Posted by Andy Todd at 10:51 PM | Comments (1)