Showing posts with label XML. Show all posts
Showing posts with label XML. Show all posts

Sunday, July 01, 2007

New stuff has been learned... Old things have become new.

So, all the problem I was working through yesterday have been figured out.  Kind of disappointing in some ways.  Sort of like reading a really good short story.  Great entertainment but so short, hardly worth the effort.

I mentioned, or alluded yesterday that I had been playing around with IDE support trying to get my dtd converted into beans.  One of the places I discovered while pursuing the NetBeans route was the Schema2Beans plug-in.  Although I never got it to work inside of NetBeans I was able to pull out the libraries of the plug-in and invoke them from the command line (and from Eclipse). 

So my big nasty DTD did have some "issues" you could say, that didn't really help anything but with a little help from an XML validator and some creative hacking I got it all working.  It works quite beautifully actually.  The XML generation isn't quite as cool as my decorator but it will work.

The funny thing is as I was writing the test case I recognized the code I had written was almost identical to the way IBM's generated beans work.  So there is a [small] chance in H3ll that the old applications can migrate to this version when IBM finally deprecates their dtd converter.

Not the weekend I should have had but it was a fun little problem that didn't turn out to be that difficult thanks to those fine fellows over at NetBeans.

-Aaron

Saturday, June 30, 2007

New Project == New things to learn

So, I just finished the design for a service (I'll try to keep the names out of this to protect the guilty).  Basically this service plays the middle man between an EJB layer (A) and another EJB layer (B).  We do love our EJB's where I work...

Anyway, EJB Layer B receives XML requests and does magic on them and sends back an answer (or a failure) as XML.  We have the magic DTD and a Schema to help us figure out how to create the right question and how to parse the answer correctly.

As you no doubt know right XML is trivial.  I got a little creative this time and used a decorator pattern to generate the XML, so that was kind of fun... 

Parsing out the XML has been incredibly simple I'm using the Digester library from the jakarta-commons project by apache and the parsing and object instantiation has been a breeze. 

The only problem is that I don't want to have to hand write all of the objects that get populated via the digester.  I initially tried to go the IDE route, I was researching some plugins and found this article it looked pretty promising except I don't have a version of eclipse 3.1 lying around and I can't bring myself to download it.

I have found 3 solutions so far:

  • IBM's XSD-Beans given a DTD or XSD it will auto generate POJO's for you.  But then you are tied to IBM's runtime.   We do run on IBM's WebSphere app server so that's not horrible, but it is kind of yucky.
  • XML Spy from Altova.  This was the easiest by far.  The Enterprise Edition costs $990.00 though, and once the process is done you get your java beans tied to Altova's runtime.   Not so good.
  • Lastly I have tried PlainXML from softAMIS which is a library written on top of JAXB (B for binding).  It eventually worked I did have to do a bit of troubleshooting, no doubt due to my nasty DTD but I did eventually get my java files built.  But they were tied to the PlainXML runtime...

I guess my next steps are to look at JAXB without any wrappers and actually try to figure out what the heck is going on...  All I really want is a set of very simple POJO's that I can initialize out of the digester process, not tied to a specific XML library just simple getters and setters...

<sigh>

Wish me luck.

-Aaron