printf v. API

Interesting conversation on the XSL developer list. This started when the Microsofties on the list pooh-poohed Eliotte Rusty Harold’s new XML API for Java, XOM. Examples of .NET and C# ease-of-use were trundled out, and several readers commented on how they were akin to the desperate Perl/VB/PHP hacker trick of writing out an XML stream using printf. (Don’t laugh, we’ve all used this.)

And that brings up a major annoyance I have with PHP: out of the box, PHP doesn’t have an XML writer/producer which you can do:

$doc = new document ($myCharset,[$myDTD|$myScheme]);

$doc.addChild (”foo”);

etc.

without rebuilding PHP with libxml (which is not a cakewalk on Mac OS X). Whereas you can do something similar in Perl, Java and Python without painful rebuilding/testing of the core.

As pointed out in the thread, the printf/document.write () trick works until the system gets something unparsable handed to it.

So, as I’m writing my presentation for ApacheCon, I think this is going to become one of my bullet points. And I’m going to look deep and hard at Python as a path out of PHP unless Zeev and company bring us a native XML writer.

More like this: , , .