Trang and XMLBeans are totally cool
Have you ever had a bunch of XML documents and
wish you had Java objects? Now you can!
These two tools work together so well that they
should be integrated into one wonderful package. Just recently, as I was trying
to rid myself of all references to WebLogic in a personal project, I used them
for about the fifth time in concert. As a side note, most utilities for
building enterprise applications can be found in various WebLogic packages,
including weblogic.utils, weblogic.xml and weblogic.servlet.internal, too bad
they aren't public. I found this out the hard way and have been scrambling for
replacements. While stripping out a dependency on the WLS StaX implementation,
I decided to get rid of all the direct XML code for reading and writing
configuration files. So I had a collection of config files and a bunch of
custom code for reading and writing them. First I erased all that code. What a
waste of brain power that was. Next I downloaded Trang and
ran it against all of the config files that I was using as test cases for the
old system to produce an schema (xsd). If I had had good code coverage I
wouldn't have needed to edit the files, but unfortunately, there were some
things that I missed. So I fixed up the schema a bit and ran it through XMLBeans 1.0.3 to produce a .jar
file of classes that I could use to read and write the configuration
files.That was almost it. After
converting the application to use the new config file system I did go back and
refactor the schema a bit
to add some abstraction. I wonder when the IDEs will be able to do that
themselves?
Posted: Mon - October 4, 2004 at 10:59 PM
|