J2SE 6 has some interesting new XML functionality called JAXB. Using JAXB, you can take an XSD file and compile it into Java classes. You can then add those classes to your project, create an Unmarshaler object, feed it some XML which meets the XSD, and it will pass you back a tree of appropriate POJOs you can mess with.The only problem is that the XML file my source application generates refers to a DTD which JAXB tries to load via xerxes, causing epic fail.
Clearly I could rewrite the XML on the fly, perhaps even using XSLT to make the code even more enterprisey. However, I can’t help thinking that there should be a simpler way to either make xerxes/JAXB ignore the DTD (which, after all, it doesn’t need), or tell it how to find it.
Anyone happen to know?
[And yes, this is horribly enterprisey, but the benefit of being able to unmarshal a large population of XML-represented objects in only 20 lines of code is too good to pass up. Plus, I already know that the bottleneck in the intended application will be database speed.]
Liked this post? Follow this blog to get more.