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 xvcmd.py 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 XML.com 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 May 21, 2004 07:34 PM