Pipe Dreams


Yesterday I had a whole lot of trouble trying to put our office contact info onto our project wiki. The contact info was saved in everybody’s favorite format Word “.doc”. I never put a table on our wiki before so I had to experiment and figure out how tables worked using our wiki software, SnipSnap. After figuring out that I needed pipe delimited text in a SnipSnap table tag (in normal people speak that means I needed every column to be separated by one of those funny little vertical bar characters “|” while pressing the return key after each line.) I went to the next step, conversion. My initial attempt was to open the Word doc in OpenOffice (I run Linux so the OpenOffice logo is what shows on my screen whenever I click to open a Word document. (Oh, I also have my desktop set to open files on a single click partly because I’m lazy and partly because I wanna be different.)), save the file as XHTML and perform some magic using my favorite toy, Groovy. That’s where I hit the wall. That really cool XmlSlurper started to rip into my XHTML while it’s internal parser caught a chicken bone in its throat and started complaining about a network connection failure. Because I’m the smarterest debugger guy in town I immediately diagnosed the problem as originating from our evil HTTP proxy. (That dang proxy has been the source of more drama than I care to imagine! It’s evil, I tell you!)

In short, here’s what happened. Mr. XML-Parser saw a DTD declaration in the XHTML and said, “Hey, wouldn’t that be cool if I went all the way out to the w3 consortium and retrieved the description of this file? Hey yeah, then we could like know which tags to expect and be prepared in case any pornographic came our way because we don’t know what Mr. Cliff downloads from his office computer!”
Roz Mrs. Http-Proxy responded with something like, “Wazowski! You don’t have your paperwork do you? No net play without your paperwork!” So now I’m ping-ponging messages back and forth on the Nabble Groovy mailing list with the, “why ain’t my stuff working?” The list was coming back with stuff like, “Sometimes it gotsta be dat way. Give the parser what it wants, everything it wants. Either you drive out to the w3 consortium and print out the DTDs yourself or you have to give it your HTTP proxy authentication, your social security card, your date of birth, your highest/lowset scores on the ASVAB and SAT exams and $3.25 in Canadian currency.” So I did what any law abiding American would do in my situation. I took a shortcut. I pulled the table I was interested in out of the XHTML and I parsed it into my Groovy Console with a two liner Groovy snippet. I threw the code away but I believe it was something like this:

def list = new XmlSlurper().parse(new File('/home/ccc/contact-list.xhtml'))
list.tr.each { it.td.each {println it << '|'}; println ""; }

After that I was staring at some pretty looking pipe-delimited text which I merrily copied into the wiki edit text field. And we all lived happily ever after. The End.

(To hear more stories like the above please send a self addressed stamped envelope including a check made out to Cliff for the the aount of $19.95 to this address: 2495 Pipedream Lane, Anderson, SC 29623 Three dollars of your payment will be included as a donation to the Make-A-Wish Foundation.)

Disclaimer: There is no Pipedream Lane in Anderson SC and any payment will be silently returned to sender. Remember, it’s just jokes!

One thought on “Pipe Dreams

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s