Thursday, January 20, 2005

XML - even more aaargh

I was right. That Java-calls-Python code I wrote about did indeed get complex enough that I was spending too much effort writing code to parse data coming in via a single pipe (the stdout of my Python program). I needed to pass error codes, as well as "real" data, and the real data had multiple data types.

Oh, well. Why write a home-grown parser of my own? Java supports XML, so I grit my teeth...

As expected, converting the Python program to write XML is easy. Ten minutes, max. So let's grab all those neat Java XML libraries, and enter a world of standards-based heaven. Or not. SAX seems to be the obvious choice, but that seems to imply that I have to write my own state machine code to handle the SAX events. So remind me - why is writing my own state machine easier than writing my own parser? I hate writing state machines, I always get the end conditions wrong :-(

Maybe I'll try DOM. Who knows, it may be easier. It's ugly and verbose in other languages, but I'm getting used to the concept that everything is ugly and verbose in Java, so maybe it'll seem fine.

Sorry, but I needed that rant. We now return you to your scheduled program.


Post a Comment

<< Home