I wish I could rave about Relaxer as David has. Unfortunately, either I inhabit some fringe of the universe that doesn't get visited often, or (worse) some of these products don't stand up to real-world needs.
In the applications my company develops, we need to read XML from and write XML to external systems. The schemata are defined by an industry consortium, so we don't have much control over their definition. To date, I've been using hand-written code to map XML structures to Java objects and back, all of which was written long before I'd heard of JAXB or any mapping tools like Relaxer. Now, however, a new version of the schemata definition is out, so I'm looking for a way to make my life easier.
Unfortunately, Relaxer won't do the job. For one thing, it won't read XSchema, which is how the schemata are defined. I downloaded the RELAX NG Converter from Sun and converted a sample xsd to RELAX NG, but then Relaxer refused to compile it, throwing an InternalError without any diagnostics. (And good luck finding much documentation on their website, or even a mailing list with a searchable archive.) Part of the problem may be that the XSchema as we get it from the industry consortium is of poor quality (for example, there are embedded URLs that reference "localhost"), but as I said before, there's not much we can do about that.
I also tried the Castor XML Source Code Generator, also to no avail. At least it provided some diagnostics by which I could attempt to patch around the deficiencies in the XSchema, but ultimately it ended up generating code that wouldn't compile.
There's light at the end of the tunnel (and this long blog post). I fed one of the more complex schemata into XMLBeans, and it generated Java source and compiled it to classes just fine. I have yet to find out whether the classes are actually usable, but that's a topic for a later post. (And perhaps a presentation. :-)
No comments:
Post a Comment