Trang is the gift that just keeps on giving. Ever since I started using James Clark's nXML mode for Emacs, I've also been using his Trang tool to convert DTDs to Relax NG compact schema. This allows nXML to validate your XML as you type it! It's really a great Emacs mode that also features tag completion.

However, I just discovered another great thing about Trang. I am writing an application that I need a configuration file for. I decided that I would make the configuration file XML and use Jakarta Commons Digester to read the file in and turn it into Java Beans. I mocked up my XML, and it turned out to be a little complex but workable. Since an administrator will edit the configuration file with an editor, I want the Digester to validate it using a DTD to make things more bulletproof.

SO, I was faced with creating a DTD for my XML file. Ugh. At least it's not a Schema. But, I still didn't want to do it. I remembered that Trang had different input and output options, and I wondered if it would create a DTD from my sample XML as a starting point.

Being brave and lazy, I fired up Trang against the XML and told it to spit out a DTD. VOILA! Within a second I had a working first cut at a DTD!!!

Thank you Trang, from the bottom of my lazy heart!!!

No comments: