I don’t know why I was being so determined about developing a good XSL runner app with Groovy. My problem originated when I needed to test an XSL stylesheet and couldn’t do so because it needed to execute from within our application. In other words, I had to completely deploy our monsterous EJB application fire up my installed Swing client, make a series of selections and click some buttons to get my stylsheet to do anything useful. Sounds like the classic problem of rigid code which TDD was designed to prevent. Well I finally came to the conclusion that my XSL runner groovy app, while very cool, was not the best allocation of my time and efforts. I needed to test my stylesheets, not play with them. I needed to refactor and apply XP principles to break out the part I was interested in so it could run in isolation; so that it could be tested in isolation. I forgot that I could use JUnit to validate XML documents which meant I could use JUnit to test my XSL. And why not? executing a stylesheet was just a matter of a few lines of Java code to pick up the stylesheet and input XML as classpath resource streams, set up a TRAX transformer, and pass in the collected streams wrapped in StreamSource objects. The output would be XML which is, as I said earlier, easily validated by XMLUnit. (Did I say JUnit before? I meant XMLUnit, ahem.) So now my question is this… why didn’t you tell me already???!!! Yes you, my loyal reader (by now my hit counter has dwindled reflecting only one loyal vistor each day, you). You visit often enough, you haven’t left a comment yet, what are you here for? No, wait, don’t navigate to slashdot just yet. I apologize. Lets get to know one another better. You see I started off on the wrong foot, I thought this little corner would blow up like Joel or Rory. I’m really not as naive as I sound, but if you could spread the word a little, maybe to your next door neighbor then I can stop pretending like I’m talking to more than one person.
Anyway, back on topic.Where was I…? Oh yeah, I was discussing XMLUnit and testing stylesheets. The moral to my short story is use unit testing tools to test code, don’t reinvent the wheel with a convetional eyeball testing approach as I began to or else you’ll be spinning your wheels. Wheeling and dealing with different technologies to do something that is natural another technology can lead to trouble. So get your wheels screwed on tight and… what the hell am I saying? It must be Friday already. Happy Memorial day weekend party people. Wheel see ya’ later and I’ll holler… (Ok, the wheel thing was real corny and overplayed but I gotta try something different in each post or else my stuff won’t get read and I ever won’t be able to mention my custom product on my site and make $millions in sales revenue.)